/* ========================================
   Sistema de Firma Digital - Estilos
   ======================================== */

:root {
    --primary: #667eea;
    --primary-dark: #5568d3;
    --secondary: #764ba2;
    --success: #667eea;
    --danger: #764ba2;
    --warning: #ffc107;
    --info: #667eea;
    --light: #f8f9fa;
    --dark: #343a40;
    --white: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-body, #f5f5f5);
    min-height: 100vh;
    line-height: 1.6;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ========================================
   Login & Forms
   ======================================== */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    padding: 40px;
    width: 100%;
    max-width: 450px;
}

.login-box h1 {
    text-align: center;
    color: var(--primary);
    margin-bottom: 10px;
    font-size: 28px;
}

.login-box .subtitle {
    text-align: center;
    color: #6c757d;
    margin-bottom: 30px;
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23333' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 40px;
}

/* ========================================
   Buttons
   ======================================== */

.btn {
    display: inline-block;
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    text-align: center;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #63408a;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(118, 75, 162, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
}

.btn-block {
    width: 100%;
    display: block;
}

.btn-sm {
    padding: 6px 15px;
    font-size: 14px;
}

/* ========================================
   Dashboard Layout
   ======================================== */

.dashboard {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.1);
    overflow: hidden;
    margin: 20px auto;
}

.dashboard-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.dashboard-header h1 {
    font-size: 28px;
    margin: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info span {
    opacity: 0.9;
}

.dashboard-nav {
    background: #f8f9fa;
    padding: 20px 30px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.nav-btn {
    padding: 10px 20px;
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    color: #333;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s;
    font-size: 14px;
}

.nav-btn:hover, .nav-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.dashboard-content {
    padding: 30px;
}

/* ========================================
   Stats Cards
   ======================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.stat-card.success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.stat-card.warning {
    background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
}

.stat-card.danger {
    background: linear-gradient(135deg, #dc3545 0%, #e83e8c 100%);
}

.stat-card h3 {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 10px;
    font-weight: 600;
}

.stat-card .number {
    font-size: 36px;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-card .label {
    font-size: 12px;
    opacity: 0.8;
}

/* ========================================
   Tables
   ======================================== */

.table-container {
    overflow-x: auto;
    background-color: var(--bg-card, #ffffff);
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

table {
    width: 100%;
    border-collapse: collapse;
}

table thead {
    background: #f8f9fa;
}

table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #dee2e6;
    font-size: 14px;
}

table td {
    padding: 15px;
    border-bottom: 1px solid #f1f3f5;
}

table tbody tr:hover {
    background: #f8f9fa;
}

table tbody tr:last-child td {
    border-bottom: none;
}

/* ========================================
   Badges & Status
   ======================================== */

.badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
}

.badge-info {
    background: #d1ecf1;
    color: #0c5460;
}

/* ========================================
   Alerts
   ======================================== */

.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border-color: #28a745;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border-color: #dc3545;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border-color: #ffc107;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border-color: #17a2b8;
}

/* ========================================
   Signature Page Specific
   ======================================== */

.signature-container {
    max-width: 900px;
    margin: 20px auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
    animation: fadeIn 0.5s;
}

.signature-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 40px 30px;
    text-align: center;
}

.signature-header h1 {
    font-size: 32px;
    margin-bottom: 10px;
}

.signature-content {
    padding: 40px;
}

@media (max-width: 768px) {
    .signature-content {
        padding: 20px;
    }

    .signature-header {
        padding: 30px 20px;
    }

    .signature-header h1 {
        font-size: 24px;
    }
}

.document-viewer {
    border: 2px solid #dee2e6;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 30px;
    background: #f8f9fa;
    max-height: 500px;
    overflow-y: auto;
}

.signature-pad {
    border: 3px solid var(--primary);
    border-radius: 12px;
    cursor: crosshair;
    display: block;
    margin: 0 auto;
    background: #fafbfc;
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 300px;
    touch-action: none;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.signature-pad:hover {
    background: white;
    box-shadow: inset 0 2px 8px rgba(102, 126, 234, 0.1), 0 0 0 1px var(--primary);
}

.signature-pad-container {
    width: 100%;
    max-width: 100%;
    margin: 15px auto;
    padding: 0;
    overflow: hidden;
    position: relative;
}

.signature-pad-container::before {
    content: "✍️ Dibuja tu firma aquí";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #adb5bd;
    font-size: 18px;
    pointer-events: none;
    z-index: 0;
    opacity: 0.5;
    font-weight: 500;
}

@media (max-width: 768px) {
    .signature-pad {
        min-height: 250px;
    }

    .signature-pad-container::before {
        font-size: 14px;
    }
}

.signature-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.signature-controls .btn {
    padding: 10px 25px;
    font-size: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.card {
    background-color: var(--bg-card, #ffffff);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    margin-bottom: 25px;
    border: 1px solid var(--card-border, #e9ecef);
    transition: all 0.3s;
}

.card:hover {
    box-shadow: 0 4px 15px rgba(0,0,0,0.12);
}

/* ========================================
   Modal
   ======================================== */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 15px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: slideIn 0.3s;
}

.modal-header {
    padding: 20px 30px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    color: var(--primary);
}

.close-modal {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6c757d;
}

.modal-body {
    padding: 30px;
}

.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ========================================
   Animations
   ======================================== */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {
    /* Containers y contenido principal */
    .container {
        padding: 12px !important;
        margin: 0 !important;
    }

    .dashboard {
        margin: 10px;
        border-radius: 12px;
    }

    .dashboard-header {
        flex-direction: column;
        text-align: center;
        padding: 20px 15px;
    }

    .dashboard-nav {
        justify-content: center;
        padding: 12px 10px;
    }

    .dashboard-content {
        padding: 15px !important;
    }

    /* Tarjetas - Sombras mínimas en móvil */
    .card {
        padding: 15px !important;
        margin-bottom: 15px !important;
        box-shadow: 0 1px 3px rgba(0,0,0,0.06) !important;
        border-radius: 10px !important;
    }

    /* Stats grid */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 18px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }

    /* Tablas */
    .table-container {
        border-radius: 8px;
        box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    }

    table {
        font-size: 13px;
    }

    table th, table td {
        padding: 8px;
    }

    /* Firma */
    .signature-pad {
        width: 100% !important;
        min-height: 220px;
    }

    .signature-container {
        margin: 0;
        border-radius: 0;
        width: 100%;
    }

    .signature-content {
        padding: 15px !important;
    }

    .signature-header {
        border-radius: 0;
    }

    /* Formularios */
    .login-box {
        padding: 25px 20px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    }

    /* Botones */
    .btn {
        padding: 10px 20px;
        font-size: 15px;
    }

    /* Modales */
    .modal-content {
        width: 95%;
        margin: 10px;
    }

    .modal-body, .modal-header, .modal-footer {
        padding: 20px;
    }
}

/* Móviles pequeños - Optimización extra */
@media (max-width: 480px) {
    .container {
        padding: 10px !important;
    }

    .card {
        padding: 12px !important;
        margin-bottom: 12px !important;
    }

    .dashboard-header h1 {
        font-size: 22px;
    }

    .stat-card .number {
        font-size: 28px;
    }

    table {
        font-size: 12px;
    }

    table th, table td {
        padding: 6px;
    }

    .btn {
        padding: 9px 18px;
        font-size: 14px;
    }
}

/* ========================================
   Utilities
   ======================================== */

.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.p-20 { padding: 20px; }
.hidden { display: none; }

.flex {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid rgba(102, 126, 234, 0.3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
