/* ============================================
   BASE STYLES - Común a todos los temas
   ============================================ */

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

@keyframes pulseGlow {
    0% {
        box-shadow: 0 0 10px var(--primary-dim);
    }
    50% {
        box-shadow: 0 0 25px var(--primary-dim);
    }
    100% {
        box-shadow: 0 0 10px var(--primary-dim);
    }
}

@keyframes gridMove {
    0% { background-position: 0 0, 0 0, 0 0, 0 0; }
    100% { background-position: 0 0, 0 0, 50px 50px, 50px 50px; }
}

@keyframes flare {
    0% { transform: translateY(-100%) rotate(45deg); }
    100% { transform: translateY(100%) rotate(45deg); }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Hanken Grotesk', sans-serif;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-dim) transparent;
}

html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    position: relative;
}

body {
    min-height: 100vh;
    line-height: 1.6;
    background: var(--bg-main) fixed;
    color: var(--text-main);
    display: flex;
    transition: background 0.5s ease;
}

.glass {
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.8) 0%, rgba(15, 23, 42, 0.4) 100%);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.glass::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    opacity: 0.5;
}

header {
    padding: 1.25rem 3rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}

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

.logo-box {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--glow);
}

.brand-name {
    font-weight: 900;
    font-size: 1.5rem;
    letter-spacing: 0.05em;
    font-family: 'Space Mono', monospace;
}

.brand-name span {
    color: var(--primary);
    font-weight: 400;
}

.sys-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    font-weight: 800;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    letter-spacing: 0.05em;
    transition: all 0.3s ease;
    cursor: pointer;
    font-family: 'Space Mono', monospace;
}

.sys-status:hover {
    border-color: var(--primary-dim);
}

.sys-status.active-ipc {
    border-color: var(--primary);
    color: var(--text-main);
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.2);
}

.sys-status.active-avaluo {
    border-color: var(--warning);
    color: var(--text-main);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.2);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.main-wrapper {
    max-width: 1700px;
    margin: 0 auto;
    padding: 2.5rem 3rem;
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 2.5rem;
}

.kpi-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 0.5rem;
}

.kpi-card {
    padding: 1.8rem;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    animation: fadeIn 0.6s ease-out backwards;
    position: relative;
}

.kpi-card:nth-child(1) {
    animation-delay: 0.1s;
    border-left: 3px solid var(--primary);
}

.kpi-card:nth-child(2) {
    animation-delay: 0.2s;
    border-left: 3px solid var(--success);
}

.kpi-card:nth-child(3) {
    animation-delay: 0.3s;
    border-left: 3px solid var(--text-dim);
}

.kpi-card:nth-child(4) {
    animation-delay: 0.4s;
    border-left: 3px solid var(--warning);
}

.kpi-card:hover {
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.6);
    border-color: var(--primary-light);
}

.kpi-label {
    color: var(--text-dim);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 0.75rem;
    font-family: 'Space Mono', monospace;
}

.kpi-val {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.25rem;
    font-family: 'Space Mono', monospace;
    letter-spacing: -0.05em;
}

.kpi-sub {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

.panel-header h2 {
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: 0.1em;
    color: var(--text-main);
    font-family: 'Space Mono', monospace;
}

.input-area {
    padding: 2.5rem;
    animation: fadeIn 0.8s ease-out backwards;
    animation-delay: 0.5s;
}

textarea {
    width: 100%;
    height: 240px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    color: var(--primary);
    font-family: 'Space Mono', monospace;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s;
    line-height: 1.7;
    resize: vertical;
}

textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.action-bar {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
}

.btn-zenith {
    flex: 1;
    padding: 1.1rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #020408;
    border: none;
    border-radius: 8px;
    font-weight: 800;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    transition: all 0.3s;
    letter-spacing: 0.1em;
    font-family: 'Space Mono', monospace;
    text-transform: uppercase;
}

.btn-zenith:hover {
    filter: brightness(1.2);
    box-shadow: var(--glow);
}

.table-panel {
    margin-top: 3rem;
    overflow: hidden;
    animation: fadeIn 1s ease-out;
}

.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    padding: 1.25rem 1.5rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    font-family: 'Space Mono', monospace;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

td {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s;
    font-size: 0.95rem;
}

tr:hover td {
    background: rgba(0, 242, 254, 0.05);
}

.val-num {
    font-weight: 700;
    font-family: 'Space Mono', monospace;
    font-size: 1.05rem;
}

.val-upd-cell {
    color: var(--success);
}

.pct-badge {
    color: var(--primary);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 800;
    font-family: 'Space Mono', monospace;
    border: 1px solid var(--border);
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    animation: fadeIn 0.8s ease-out backwards;
    animation-delay: 0.6s;
}

.stat-box {
    padding: 2rem;
    position: relative;
}

.chart-container {
    height: 260px;
    margin-top: 1.5rem;
}

.tech-note {
    border-left: 3px solid var(--primary);
    padding: 1.5rem;
    border-radius: 0 8px 8px 0;
    font-size: 0.85rem;
    color: var(--text-dim);
    line-height: 1.8;
}

.theme-switcher {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.theme-btn {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.4);
    color: var(--text-dim);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.3s;
    font-family: 'Space Mono', monospace;
}

.theme-btn:hover,
.theme-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(0, 242, 254, 0.1);
}

    /* --- Mobile Fixes for Small Screens --- */
    @media (max-width: 380px) {
        .brand-box h1 { font-size: 0.75rem !important; }
        .segment { display: none !important; } /* Hide 'TERMINAL' etc on tiny screens */
        .status-dot { width: 6px; height: 6px; }
        .status-pill { font-size: 0.6rem; padding: 0.3rem 0.5rem; }
        .kpi-big { font-size: 1.2rem !important; }
        .kpi-label { font-size: 0.55rem; }
    }

    @media (max-width: 320px) {
        .theme-selector { scale: 0.8; }
        .nav-logo { display: none; } /* Only icons on 5S/SE width */
        .sidebar-nav { padding: 0 0.5rem; }
    }




@media (max-width: 1300px) {
    .main-wrapper {
        grid-template-columns: 1fr;
    }
    .kpi-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    header {
        padding: 1rem 1.5rem;
        flex-direction: column;
        gap: 1rem;
    }
    .main-wrapper {
        padding: 1.5rem;
    }
}

/* --- [E.V.A. V3] ULTRA-MINIMALIST MONOLITH HUB --- */
#eva-monolith-pool {
    position: fixed;
    top: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    pointer-events: none;
}

.eva-mono-entry {
    background: rgba(10, 15, 26, 0.4);
    backdrop-filter: blur(25px) saturate(200%);
    -webkit-backdrop-filter: blur(25px) saturate(200%);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    height: 38px;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1.5rem;
    color: var(--text-main);
    transform: translateY(-20px) scale(0.98);
    opacity: 0;
    transition: 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 15px 30px rgba(0,0,0,0.3);
}

.eva-mono-entry.phase-in {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.mono-bar {
    width: 2px;
    height: 12px;
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary);
}

.eva-mono-entry.warning .mono-bar { background: var(--warning); box-shadow: 0 0 8px var(--warning); }
.eva-mono-entry.info .mono-bar { background: var(--accent); box-shadow: 0 0 8px var(--accent); }

.mono-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-family: 'Space Mono', monospace;
}

.mono-tag {
    font-size: 0.55rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 2px;
    opacity: 0.6;
}

.mono-msg {
    font-size: 0.7rem;
    font-weight: 400;
    letter-spacing: 0.5px;
}

/* --- Session Ledger Trash Can Styles --- */
.history-item {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: 0.3s var(--ease);
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.02);
}

.h-main { flex: 1; }

.h-del {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.05);
    background: rgba(244, 63, 94, 0.03);
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.3s var(--ease);
    opacity: 0.3;
}

.h-del:hover {
    opacity: 1;
    background: rgba(244, 63, 94, 0.1);
    color: #f43f5e;
    border-color: rgba(244, 63, 94, 0.3);
}

.h-del i { width: 14px; height: 14px; }

@media (max-width: 600px) {
    .eva-mono-entry { width: calc(100vw - 40px); justify-content: center; padding: 0 1rem; }
}


/* ============================================
   PROFESSIONAL FORENSIC PRINT LAYOUT
   Optimized for Legal/Judicial Documentation
   ============================================ */
@media print {
    @page {
        margin: 2cm;
        size: letter portrait;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        text-shadow: none !important;
        box-shadow: none !important;
    }

    body {
        background: #ffffff !important;
        color: #000000 !important;
        font-size: 10pt;
        display: block !important;
    }

    /* Hide UI Elements */
    .sidebar-nav, 
    header, 
    .nav-item, 
    .theme-selector, 
    .sys-log, 
    .cta-group, 
    .btn-zenith, 
    .btn-ghost, 
    .btn-pdf,
    .log-card,
    #sessionHistory,
    .info-insight,
    .pulse-dot,
    .nav-logo,
    .step-nav,
    .header-right,
    #pdfBtn,
    .h-del,
    i[data-lucide="trash-2"] {
        display: none !important;
    }

    .app-container {
        padding: 0 !important;
        height: auto !important;
        overflow: visible !important;
    }

    .dashboard-main {
        display: block !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .glass-card {
        background: #ffffff !important;
        border: 1px solid #000000 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        padding: 1.5rem !important;
        margin-bottom: 2rem !important;
        break-inside: avoid;
    }

    .section-header h2 {
        color: #000 !important;
        border-bottom: 2px solid #000;
        padding-bottom: 5px;
        margin-bottom: 1rem;
    }

    /* Table Formatting */
    .table-canvas {
        background: #fff !important;
        border: 2px solid #000 !important;
        border-radius: 0 !important;
        overflow: visible !important;
    }

    table {
        width: 100% !important;
        border-collapse: collapse !important;
    }

    th {
        background: #eeeeee !important;
        color: #000 !important;
        border: 1px solid #000 !important;
        font-weight: bold !important;
        text-transform: uppercase;
        font-size: 8pt;
    }

    td {
        background: #fff !important;
        color: #000 !important;
        border: 1px solid #999 !important;
        font-size: 9pt !important;
        padding: 8px !important;
    }

    .num, .upd, .delta {
        color: #000 !important;
        font-weight: bold !important;
    }
    
    .delta {
        border: 1px solid #ccc !important;
        background: #f9f9f9 !important;
    }

    /* Outcome HUD Optimization */
    .outcome-card {
        border: 3px solid #000 !important;
        text-align: center;
    }

    .outcome-value {
        font-size: 32pt !important;
        color: #000 !important;
    }

    /* Document Branding */
    body::before {
        content: "REPORTE TÉCNICO DE VALORACIÓN - ALGORITMO E.V.A. v3.1.0";
        display: block;
        text-align: center;
        font-weight: bold;
        border-bottom: 1px solid #000;
        margin-bottom: 1cm;
        font-size: 10pt;
    }

    body::after {
        content: "Este documento es parte integral de un proceso de valoración pericial. Datos procesados mediante el Motor de Cálculo E.V.A. PRO © DGZ Engineering Lab. Factor de Indexación IPC Zenith: 1.5226.";
        display: block;
        position: fixed;
        bottom: 0;
        width: 100%;
        text-align: center;
        font-size: 8pt;
        border-top: 1px solid #ccc;
        padding-top: 5mm;
        color: #666;
    }

    .trace-icon { display: none !important; } /* No icons on paper */
}

/* --- [E.V.A. V4] ADVANCED ANALYTICS GRID --- */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    animation: fadeIn 0.8s ease-out;
}

.analytics-grid .full-width {
    grid-column: 1 / -1;
}

.chart-container-fixed {
    height: 300px;
    margin-top: 1rem;
    position: relative;
}

.metrics-card {
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.9) 0%, rgba(30, 41, 59, 0.6) 100%);
}

.kpi-mini-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-top: 1.5rem;
}

.mini-kpi {
    padding: 0.8rem 1rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    transition: 0.3s var(--ease);
}

.mini-kpi:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--primary);
    transform: translateY(-3px);
}

.mini-kpi .l {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-dim);
    font-weight: 700;
}

.mini-kpi .v {
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--text-main);
    font-family: 'Space Mono', monospace;
}

/* --- [E.V.A. V4] PREMIUM NOTIFICATIONS --- */
.eva-mono-entry {
    background: rgba(10, 15, 23, 0.7) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    height: 48px !important;
    padding: 0 1.8rem !important;
    border-radius: 24px !important;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5), inset 0 1px 1px rgba(255,255,255,0.1) !important;
}

.eva-mono-entry.success { border-left: 3px solid var(--success) !important; }
.eva-mono-entry.warning { border-left: 3px solid var(--warning) !important; }
.eva-mono-entry.info { border-left: 3px solid var(--primary) !important; }

.mono-tag {
    background: rgba(255,255,255,0.05);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    color: var(--text-main) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-family: 'Space Mono', monospace;
}

/* --- [E.V.A. V5] FORENSIC SEARCH & AUDITOR UI --- */
.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.eva-search {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.4rem 1rem;
    padding-left: 2rem;
    font-size: 0.75rem;
    color: var(--text-main);
    width: 150px;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    font-family: 'Space Mono', monospace;
}

.eva-search:focus {
    width: 220px;
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.1);
    outline: none;
}

.search-wrapper::before {
    content: '🔍';
    position: absolute;
    left: 0.8rem;
    font-size: 0.7rem;
    opacity: 0.5;
}

/* Custom Switch Zenith */
.switch-zenith {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 20px;
}

.switch-zenith input { opacity: 0; width: 0; height: 0; }

.slider-zenith {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255,255,255,0.05);
    transition: .4s;
    border-radius: 20px;
    border: 1px solid var(--border);
}

.slider-zenith:before {
    position: absolute;
    content: "";
    height: 12px; width: 12px;
    left: 4px; bottom: 3px;
    background-color: #64748B;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider-zenith { background-color: rgba(244, 63, 94, 0.1); border-color: #f43f5e; }
input:checked + .slider-zenith:before {
    transform: translateX(18px);
    background-color: #f43f5e;
    box-shadow: 0 0 8px #f43f5e;
}

/* Forensic Auditor Highlighting */
.auditor-flag {
    outline: 1.5px solid #f43f5e !important;
    background: rgba(244, 63, 94, 0.1) !important;
    animation: alertPulse 2s infinite;
}

@keyframes alertPulse {
    0% { outline-color: rgba(244, 63, 94, 0.4); }
    50% { outline-color: rgba(244, 63, 94, 1); }
    100% { outline-color: rgba(244, 63, 94, 0.4); }
}

/* Projects Management List */
.history-pool {
    max-height: 400px;
    overflow-y: auto;
    margin-top: 1rem;
    scrollbar-width: none;
}
.history-pool::-webkit-scrollbar { display: none; }

/* Combined Analytics Dashboard */
.analytics-double-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 0.75rem 0 0 0;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.chart-box {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chart-sub-title {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    text-align: center;
    font-family: 'Space Mono', monospace;
    opacity: 0.8;
}

@media (max-width: 900px) {
    .analytics-double-grid {
        grid-template-columns: 1fr;
    }
}

/* Forensic Traceability Icon Visibility */
.trace-icon {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    color: var(--primary) !important;
    cursor: pointer;
    margin-right: 8px;
    opacity: 0.7;
    transition: all 0.3s var(--ease);
    vertical-align: middle;
}

.trace-icon:hover {
    opacity: 1;
    transform: scale(1.2);
    filter: drop-shadow(0 0 5px var(--primary));
}

.trace-icon svg {
    width: 14px !important;
    height: 14px !important;
    stroke-width: 2.5px !important;
}
