/* ==============================================================================
   GAIT-IGM CLOUD SUITE | ESTILOS INSTITUCIONALES BLINDADOS
   Instituto Geográfico Militar del Ecuador (IGM)
   Paleta Oficial:
     - Modo Claro: #C3CA92, #A4B17B, #8bb74e
     - Modo Oscuro: #697E50, #4E653D, #354C2B, #0e1710
   Física Háptica: Apple HIG & Emil Kowalski Spring Curves
   ============================================================================== */

:root {
    --igm-green-light: #C3CA92;
    --igm-green-mid: #A4B17B;
    --igm-green-brand: #8bb74e;
    --igm-green-dark: #354C2B;
    --igm-forest-dark: #1f3317;
    --igm-night: #0a110a;

    --bg-primary: #f8faf5;
    --bg-surface: #ffffff;
    --border-color: rgba(164, 177, 123, 0.35);
    --text-main: #192615;
    --text-muted: #586950;

    --danger: #e11d48;
    --warning: #d97706;
    --info: #2563eb;
    --primary: #8bb74e;

    --radius-xl: 20px;
    --radius-lg: 14px;
    --radius-md: 10px;
    --radius-sm: 6px;

    --transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    --spring-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
    --bg-primary: #0a110a;
    --bg-surface: #141f14;
    --border-color: rgba(164, 177, 123, 0.2);
    --text-main: #eef3e8;
    --text-muted: #95a88c;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    user-select: none;
    -webkit-user-select: none;
}

/* ==============================================================================
   PANTALLA DE BLOQUEO / APP GATE (BÓVEDA CRIPTOGRÁFICA)
   ============================================================================== */
#gate-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: radial-gradient(circle at center, #1b2e15 0%, #080f08 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    transition: opacity 0.55s var(--spring-ease), visibility 0.55s;
}

#gate-overlay.unlocked {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.vault-card {
    background: rgba(25, 42, 22, 0.85);
    backdrop-filter: blur(28px) saturate(190%);
    -webkit-backdrop-filter: blur(28px) saturate(190%);
    border: 1px solid rgba(195, 202, 146, 0.35);
    border-radius: var(--radius-xl);
    padding: 2.75rem 2.25rem;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.7), inset 0 1px 1px 0 rgba(255, 255, 255, 0.2);
    text-align: center;
    animation: vaultPop 0.6s var(--spring-ease) both;
}

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

.vault-logo {
    width: 84px;
    height: auto;
    margin: 0 auto 1.25rem;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
}

.vault-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.5px;
    margin-bottom: 0.35rem;
}

.vault-header p {
    font-size: 0.875rem;
    color: #c3ca92;
    line-height: 1.4;
    margin-bottom: 2rem;
}

.vault-form {
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
}

.input-wrapper {
    position: relative;
    width: 100%;
}

.vault-input {
    width: 100%;
    padding: 0.95rem 1.15rem;
    padding-right: 3rem;
    background: rgba(8, 15, 8, 0.75);
    border: 1px solid rgba(164, 177, 123, 0.4);
    border-radius: var(--radius-lg);
    color: #ffffff;
    font-size: 0.95rem;
    font-family: 'JetBrains Mono', monospace;
    outline: none;
    transition: var(--transition);
}

.vault-input:focus {
    border-color: #8bb74e;
    box-shadow: 0 0 0 3px rgba(139, 183, 78, 0.3);
    background: rgba(8, 15, 8, 0.95);
}

.toggle-pwd {
    position: absolute;
    right: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #a4b17b;
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1.1rem;
}

.vault-btn {
    background: linear-gradient(135deg, #8bb74e 0%, #697E50 100%);
    color: #ffffff;
    border: none;
    padding: 0.95rem;
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 6px 20px -4px rgba(139, 183, 78, 0.5);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.vault-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -4px rgba(139, 183, 78, 0.7);
    filter: brightness(1.08);
}

.vault-btn:active {
    transform: translateY(0);
}

.vault-error {
    font-size: 0.85rem;
    color: #fda4af;
    background: rgba(225, 29, 72, 0.2);
    border: 1px solid rgba(225, 29, 72, 0.4);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    margin-top: 0.5rem;
    display: none;
}

.vault-footer {
    margin-top: 1.75rem;
    font-size: 0.75rem;
    color: rgba(195, 202, 146, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

/* ==============================================================================
   APLICACIÓN PRINCIPAL (POST-DESBLOQUEO)
   ============================================================================== */
#app-container {
    display: none;
    flex-direction: column;
    min-height: 100vh;
}

#app-container.visible {
    display: flex;
}

/* NAVBAR INSTITUCIONAL */
.navbar {
    background: var(--igm-green-dark);
    color: #ffffff;
    padding: 0.85rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(195, 202, 146, 0.25);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-logo {
    height: 38px;
    width: auto;
}

.brand-text h2 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    line-height: 1.1;
}

.brand-text span {
    font-size: 0.75rem;
    color: var(--igm-green-light);
    font-weight: 500;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.session-pill {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(195, 202, 146, 0.4);
    color: var(--igm-green-light);
    padding: 0.45rem 0.85rem;
    border-radius: 50px;
    font-size: 0.825rem;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.btn-pill {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    padding: 0.45rem 0.9rem;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: var(--transition);
}

.btn-pill:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.btn-pill.danger:hover {
    background: rgba(225, 29, 72, 0.3);
    border-color: var(--danger);
}

/* CONTENIDO Y HERO */
.main-wrapper {
    flex: 1;
    max-width: 1380px;
    margin: 0 auto;
    width: 100%;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.hero-banner {
    background: linear-gradient(135deg, var(--igm-forest-dark) 0%, var(--igm-green-dark) 100%);
    color: #ffffff;
    border-radius: var(--radius-xl);
    padding: 2.25rem 2.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 10px 30px -5px rgba(31, 51, 23, 0.25);
    border: 1px solid rgba(195, 202, 146, 0.3);
    position: relative;
    overflow: hidden;
}

.hero-banner::after {
    content: '';
    position: absolute;
    right: -40px;
    top: -40px;
    width: 220px;
    height: 220px;
    background: radial-gradient(circle, rgba(139, 183, 78, 0.25) 0%, transparent 70%);
    border-radius: 50%;
}

.hero-content h2 {
    font-size: 1.85rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.hero-content p {
    color: var(--igm-green-light);
    max-width: 650px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.hero-stats {
    display: flex;
    gap: 1.25rem;
}

.stat-box {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(195, 202, 146, 0.25);
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    text-align: center;
}

.stat-box .val {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: #ffffff;
}

.stat-box .lbl {
    font-size: 0.72rem;
    text-transform: uppercase;
    color: var(--igm-green-light);
    letter-spacing: 0.5px;
}

/* ZONA DE CARGA INTERACTIVA / DROPZONE */
.dropzone-card {
    background: var(--bg-surface);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-xl);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.dropzone-card:hover, .dropzone-card.dragover {
    border-color: var(--igm-green-brand);
    background: rgba(139, 183, 78, 0.04);
    transform: scale(1.005);
}

.drop-icon {
    font-size: 3rem;
    color: var(--igm-green-brand);
    margin-bottom: 1rem;
}

.dropzone-card h3 {
    font-size: 1.35rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.dropzone-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.btn-action {
    background: var(--igm-green-brand);
    color: #ffffff;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-lg);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.btn-action:hover {
    background: #7ca840;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -4px rgba(139, 183, 78, 0.4);
}

/* MODAL / BARRA DE PROCESAMIENTO EN CLIENTE */
.processing-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2.5rem 2rem;
    text-align: center;
    display: none;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.08);
}

.processing-spinner {
    width: 54px;
    height: 54px;
    border: 4px solid rgba(139, 183, 78, 0.2);
    border-top-color: var(--igm-green-brand);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin-bottom: 1.25rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.processing-card h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.processing-step {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    min-height: 22px;
}

.progress-track {
    width: 100%;
    max-width: 500px;
    height: 10px;
    background: rgba(164, 177, 123, 0.2);
    border-radius: 50px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #8bb74e 0%, #A4B17B 100%);
    border-radius: 50px;
    transition: width 0.3s ease;
}

.notice-banner {
    background: rgba(139, 183, 78, 0.08);
    border: 1px solid rgba(139, 183, 78, 0.25);
    border-radius: var(--radius-md);
    padding: 0.75rem 1.25rem;
    font-size: 0.85rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* DASHBOARD DE RESULTADOS */
.results-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.badges-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.15rem;
}

.kpi-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.kpi-info .lbl {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.5px;
}

.kpi-info .num {
    font-size: 2rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1.2;
    margin-top: 0.25rem;
}

.kpi-icon {
    font-size: 1.8rem;
    opacity: 0.85;
}

.kpi-card.kpi-e { border-left: 4px solid var(--danger); }
.kpi-card.kpi-e .num { color: var(--danger); }

.kpi-card.kpi-c { border-left: 4px solid var(--warning); }
.kpi-card.kpi-c .num { color: var(--warning); }

.kpi-card.kpi-x { border-left: 4px solid var(--info); }
.kpi-card.kpi-x .num { color: var(--info); }

.kpi-card.kpi-m { border-left: 4px solid var(--primary); }
.kpi-card.kpi-m .num { color: var(--primary); }

/* BARRA DE ACCIONES POST-AUDITORÍA Y DESCARGA AUTOMÁTICA */
.action-banner-card {
    background: linear-gradient(135deg, rgba(139, 183, 78, 0.12) 0%, rgba(164, 177, 123, 0.08) 100%);
    border: 1.5px solid var(--igm-green-brand);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1.25rem;
    box-shadow: 0 4px 16px rgba(105, 126, 80, 0.1);
    animation: fadeIn 0.4s ease;
}

.action-banner-info h4 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--igm-green-dark);
    margin-bottom: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.action-banner-info p {
    font-size: 0.875rem;
    color: var(--text-main);
    margin: 0;
}

.action-buttons-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-action {
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    border: none;
    outline: none;
    user-select: none;
}

.btn-action.success {
    background: linear-gradient(135deg, #8bb74e 0%, #697E50 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(105, 126, 80, 0.35);
}

.btn-action.success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(105, 126, 80, 0.45);
    filter: brightness(1.05);
}

.btn-action.secondary {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-action.secondary:hover {
    background: rgba(164, 177, 123, 0.15);
    border-color: var(--igm-green-brand);
    color: var(--igm-green-dark);
    transform: translateY(-1px);
}

/* NOTIFICACIONES TOAST FLOTANTES */
.gait-toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.gait-toast {
    background: #1f3317;
    color: #ffffff;
    border: 1px solid #8bb74e;
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: toastSlideIn 0.3s ease;
    pointer-events: auto;
    transition: opacity 0.3s ease;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* INVENTARIO DE DOCUMENTOS COMPLEMENTARIOS */
.package-inventory-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.inventory-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.inventory-header h4 {
    font-size: 1.05rem;
    font-weight: 600;
}

.badge-pill {
    background: rgba(139, 183, 78, 0.15);
    border: 1px solid var(--igm-green-brand);
    color: var(--igm-green-dark);
    padding: 0.25rem 0.65rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
}

.inventory-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.inventory-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.65rem;
}

.inventory-item {
    background: rgba(164, 177, 123, 0.08);
    border: 1px solid rgba(164, 177, 123, 0.25);
    padding: 0.65rem 0.95rem;
    border-radius: var(--radius-md);
    font-size: 0.825rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    word-break: break-all;
}

.inventory-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* TABLA DE DISCONFORMIDADES AUDITADAS */
.table-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
}

.table-header {
    padding: 1rem 1.5rem;
    background: rgba(164, 177, 123, 0.1);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.table-header h4 {
    font-size: 1.05rem;
    font-weight: 600;
}

.filter-bar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.search-input {
    padding: 0.45rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-main);
    font-size: 0.85rem;
    outline: none;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    text-align: left;
}

.data-table th {
    padding: 0.85rem 1.25rem;
    background: rgba(164, 177, 123, 0.06);
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

.data-table tr:hover {
    background: rgba(139, 183, 78, 0.05);
}

.badge-sev {
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    display: inline-block;
}

.badge-sev.e { background: rgba(225, 29, 72, 0.15); color: var(--danger); border: 1px solid var(--danger); }
.badge-sev.c { background: rgba(217, 119, 6, 0.15); color: var(--warning); border: 1px solid var(--warning); }
.badge-sev.x { background: rgba(37, 99, 235, 0.15); color: var(--info); border: 1px solid var(--info); }
.badge-sev.m { background: rgba(139, 183, 78, 0.2); color: var(--igm-green-dark); border: 1px solid var(--igm-green-brand); }

/* FOOTER */
.app-footer {
    background: var(--igm-forest-dark);
    color: var(--igm-green-light);
    padding: 1.5rem 2rem;
    font-size: 0.825rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid rgba(195, 202, 146, 0.2);
    margin-top: auto;
}
