/* =========================================
   0. TEMA (UI)
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap');

:root {
    --bg: #0b1220;
    --bg2: #111a2e;
    --surface: rgba(255, 255, 255, 0.92);
    --surface2: rgba(255, 255, 255, 0.82);
    --border: rgba(15, 23, 42, 0.10);
    --text: #0f172a;
    --muted: #475569;
    --primary: #ea580c; /* orange-600 */
    --primary-2: #f97316; /* orange-500 */
    --blue: #2563eb; /* blue-600 */
    --green: #16a34a; /* green-600 */

/* Tabs scrollable (mobile) */
.tabs-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.tabs-scroll::-webkit-scrollbar { display: none; }

/* Mejoras móviles */
@media (max-width: 640px) {
    body { padding: 0 6px; }
    .surface { border-radius: 22px; }
    .surface-soft { border-radius: 20px; }
    .btn { padding: 0.65rem 0.9rem; font-size: 0.95rem; }
    .tabBtn { padding: 0.55rem 0.9rem; font-size: 0.95rem; flex: 0 0 auto; }
    table thead th, table tbody td { padding: 0.55rem 0.45rem; font-size: 0.85rem; }
    input.control, select.control, textarea.control { font-size: 0.95rem; }
    .grid > .surface-soft, .grid > .surface { margin-bottom: 4px; }
    .overflow-auto { -webkit-overflow-scrolling: touch; }
}
    --red: #dc2626; /* red-600 */
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.14);
    --shadow-sm: 0 10px 28px rgba(15, 23, 42, 0.10);
}

/* =========================================
   1. ESTILOS GENERALES Y FUENTES
   ========================================= */
body {
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: var(--text);
    background-color: #f7f8fb;
    background-image:
        radial-gradient(900px 500px at 10% 0%, rgba(249, 115, 22, 0.18), transparent 60%),
        radial-gradient(900px 500px at 90% 0%, rgba(37, 99, 235, 0.16), transparent 60%),
        radial-gradient(#e5e7eb 1px, transparent 1px);
    background-size: auto, auto, 24px 24px;
}

/* Superficies / tarjetas */
.surface {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.surface-soft {
    background: var(--surface2);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

/* Botones */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    font-weight: 700;
    border: 1px solid transparent;
    transition: transform 0.12s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
    user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.65; cursor: not-allowed; transform: none; }

.btn-primary { background: linear-gradient(135deg, var(--primary-2), var(--primary)); color: white; box-shadow: 0 10px 22px rgba(234, 88, 12, 0.22); }
.btn-primary:hover { box-shadow: 0 14px 28px rgba(234, 88, 12, 0.26); }
.btn-blue { background: linear-gradient(135deg, #3b82f6, var(--blue)); color: white; box-shadow: 0 10px 22px rgba(37, 99, 235, 0.20); }
.btn-blue:hover { box-shadow: 0 14px 28px rgba(37, 99, 235, 0.24); }
.btn-green { background: linear-gradient(135deg, #22c55e, var(--green)); color: white; box-shadow: 0 10px 22px rgba(22, 163, 74, 0.20); }
.btn-green:hover { box-shadow: 0 14px 28px rgba(22, 163, 74, 0.24); }
.btn-ghost { background: rgba(15, 23, 42, 0.04); color: var(--text); border-color: rgba(15, 23, 42, 0.08); }
.btn-ghost:hover { background: rgba(15, 23, 42, 0.06); }
.btn-danger { background: linear-gradient(135deg, #ef4444, var(--red)); color: white; box-shadow: 0 10px 22px rgba(220, 38, 38, 0.18); }

/* Inputs */
.control {
    border-radius: 0.85rem;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: rgba(248, 250, 252, 0.9);
    transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}
.control:focus {
    border-color: rgba(234, 88, 12, 0.40);
    box-shadow: 0 0 0 4px rgba(234, 88, 12, 0.12);
    transform: translateY(-1px);
    outline: none;
}

/* =========================================
   2. ANIMACIONES DEL FORMULARIO (WIZARD)
   ========================================= */
.form-section {
    display: none; /* Oculto por defecto */
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.form-section.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
    animation: slideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideIn {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Animación de error (sacudida) */
.shake {
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* =========================================
   3. INPUTS Y CONTROLES
   ========================================= */
input, select, textarea {
    transition: all 0.2s ease-in-out;
}

input:focus, select:focus, textarea:focus {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(234, 88, 12, 0.10), 0 2px 4px -1px rgba(234, 88, 12, 0.06);
}

/* Estado de Error */
.error {
    border-color: #ef4444 !important;
    background-color: #fef2f2 !important;
    animation: shake 0.3s ease-in-out;
}

/* Checkbox y Radio personalizados */
input[type="radio"], input[type="checkbox"] {
    accent-color: #ea580c; /* Naranja corporativo */
    width: 1.2rem;
    height: 1.2rem;
    cursor: pointer;
}

/* =========================================
   4. CANVAS DE FIRMA
   ========================================= */
#canvasFirma {
    background-color: #ffffff;
    background-image: linear-gradient(#f3f4f6 1px, transparent 1px), linear-gradient(90deg, #f3f4f6 1px, transparent 1px);
    background-size: 20px 20px;
    border: 2px dashed #d1d5db;
    border-radius: 0.5rem;
    cursor: crosshair;
    touch-action: none; /* Crucial para móviles: evita scroll al firmar */
}

#canvasFirma:active {
    border-color: #ea580c;
}

/* =========================================
   5. INDICADORES DE PASO (STEPPER)
   ========================================= */
.step-indicator {
    transition: all 0.3s ease;
    position: relative;
    z-index: 10;
    background: white;
}

.step-indicator.active {
    background-color: #ea580c; /* Orange-600 */
    color: white;
    border-color: #ea580c;
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(234, 88, 12, 0.2);
}

.step-indicator.completed {
    background-color: #10b981; /* Green-500 */
    color: white;
    border-color: #10b981;
}

/* =========================================
   6. ADMIN DASHBOARD Y TABLAS
   ========================================= */
/* Scrollbar personalizado */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f1f1; 
}
::-webkit-scrollbar-thumb {
    background: #c7c7c7; 
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8; 
}

/* Badges y Etiquetas */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge--green { background: rgba(22, 163, 74, 0.10); color: #166534; border: 1px solid rgba(22, 163, 74, 0.18); }
.badge--blue { background: rgba(37, 99, 235, 0.10); color: #1e40af; border: 1px solid rgba(37, 99, 235, 0.18); }
.badge--orange { background: rgba(234, 88, 12, 0.10); color: #9a3412; border: 1px solid rgba(234, 88, 12, 0.18); }
.badge--red { background: rgba(220, 38, 38, 0.10); color: #991b1b; border: 1px solid rgba(220, 38, 38, 0.18); }
.badge--gray { background: rgba(15, 23, 42, 0.06); color: #334155; border: 1px solid rgba(15, 23, 42, 0.10); }

/* Modales con fondo borroso */
.modal-overlay {
    backdrop-filter: blur(4px);
    transition: opacity 0.3s ease;
}

/* Tablas (mejor legibilidad) */
table thead th {
    font-weight: 800;
    color: #334155;
}
table tbody tr:hover {
    background: rgba(15, 23, 42, 0.03);
}
table tbody td {
    vertical-align: top;
}

/* Toasts */
.toast-root {
    position: fixed;
    right: 16px;
    bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    min-width: 260px;
    max-width: 420px;
    border-radius: 16px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(15, 23, 42, 0.12);
    box-shadow: var(--shadow-sm);
    animation: toastIn 180ms ease-out;
}
.toast-title { font-weight: 800; font-size: 0.95rem; }
.toast-body { margin-top: 2px; font-size: 0.85rem; color: #334155; }
.toast--ok { border-color: rgba(22, 163, 74, 0.22); }
.toast--error { border-color: rgba(220, 38, 38, 0.22); }
.toast--info { border-color: rgba(37, 99, 235, 0.22); }
@keyframes toastIn {
    from { transform: translateY(6px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Zona de Drag & Drop */
.upload-area {
    transition: all 0.3s ease;
    border-style: dashed;
}
.upload-area.dragover {
    background-color: #eff6ff; /* Blue-50 */
    border-color: #3b82f6; /* Blue-500 */
    transform: scale(1.02);
}

/* =========================================
   7. ESTILOS DE IMPRESIÓN
   ========================================= */
@media print {
    .no-print, 
    button, 
    nav, 
    .step-indicator, 
    #progressFill {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .main-container {
        box-shadow: none;
        max-width: 100%;
        padding: 0;
        margin: 0;
    }
    
    input, select, textarea {
        border: none;
        background: transparent;
        padding: 0;
    }
}
