@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --font-primary: 'Outfit', sans-serif;
    --bg-dark: #090a10;
    --bg-card: rgba(16, 18, 30, 0.45);
    --bg-card-hover: rgba(22, 26, 43, 0.6);
    --border-card: rgba(255, 255, 255, 0.07);
    --border-card-hover: rgba(139, 92, 246, 0.25);
    
    --color-primary: #8b5cf6; /* Neon Violet */
    --color-primary-glow: rgba(139, 92, 246, 0.4);
    --color-secondary: #06b6d4; /* Neon Cyan */
    --color-secondary-glow: rgba(6, 182, 212, 0.4);
    --color-success: #10b981; /* Neon Emerald */
    --color-danger: #ef4444; /* Neon Crimson */
    --color-warning: #f59e0b;
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-bright: #ffffff;
    --bg-inputs: rgba(255, 255, 255, 0.04);
    --bg-filter-box: rgba(0, 0, 0, 0.15);
}

/* LIGHT THEME OVERRIDES */
body.light-theme {
    --bg-dark: #f3f4f6;
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-card-hover: rgba(255, 255, 255, 0.95);
    --border-card: rgba(0, 0, 0, 0.06);
    --border-card-hover: rgba(139, 92, 246, 0.3);
    
    --text-main: #374151;
    --text-muted: #6b7280;
    --text-bright: #111827;
    
    --bg-inputs: #ffffff;
    --bg-filter-box: rgba(255, 255, 255, 0.9);
}

body.light-theme::before, body.light-theme::after {
    opacity: 0.08; /* Soften background blobs in light mode */
}

body.light-theme .glass-card {
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
}

body.light-theme .form-control {
    background: #ffffff;
    border-color: #d1d5db;
    color: #111827;
}

body.light-theme .form-control:focus {
    background: #ffffff;
}

body.light-theme .app-header {
    background: rgba(255, 255, 255, 0.7);
    border-bottom-color: rgba(0,0,0,0.05);
}


* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-primary);
}

body {
    background: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Background Glowing Orbits */
body::before, body::after {
    content: "";
    position: absolute;
    width: 450px;
    height: 450px;
    border-radius: 50%;
    z-index: -1;
    filter: blur(140px);
    opacity: 0.22;
    pointer-events: none;
    animation: pulseOrbits 12s infinite alternate ease-in-out;
}

body::before {
    top: 5%;
    left: 10%;
    background: var(--color-primary);
}

body::after {
    bottom: 10%;
    right: 10%;
    background: var(--color-secondary);
    animation-delay: 6s;
}

@keyframes pulseOrbits {
    0% { transform: scale(1) translate(0, 0); }
    100% { transform: scale(1.15) translate(30px, 40px); }
}

/* Custom Scrollbar using Modern API */
html {
    scrollbar-color: rgba(255, 255, 255, 0.12) rgba(255, 255, 255, 0.02);
    scrollbar-width: thin;
}

body.light-theme {
    scrollbar-color: rgba(0, 0, 0, 0.2) rgba(0, 0, 0, 0.05);
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary);
}

/* Glassmorphism Cards */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-card);
    border-radius: 20px;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.glass-card:hover {
    border-color: var(--border-card-hover);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
    transform: translateY(-3px);
}

/* Entrance Animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-entrance {
    animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}


/* Interactive Buttons */
.btn-primary, .btn-secondary {
    padding: 10px 22px;
    border-radius: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), #6d28d9);
    color: var(--text-bright);
    box-shadow: 0 4px 15px var(--color-primary-glow);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6);
    transform: translateY(-1px);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--color-secondary), #0891b2);
    color: var(--text-bright);
    box-shadow: 0 4px 15px var(--color-secondary-glow);
}

.btn-secondary:hover {
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.6);
    transform: translateY(-1px);
}

/* Login Overlay */
#login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: url('../img/bg-login.jpeg') center/cover no-repeat;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

#login-overlay::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(9, 10, 16, 0.85);
    backdrop-filter: blur(15px);
}

.login-split-card {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: row;
    width: auto;
    max-width: 95vw;
    height: 480px;
    background: rgba(15, 17, 26, 0.85);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    /* Premium Entrance Animation */
    animation: loginEntrance 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    transform: scale(0.9);
    opacity: 0;
}

.login-split-image {
    flex: none;
    height: 100%;
    background: #000;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.login-split-image img {
    height: 100%;
    width: auto;
    display: block;
    object-fit: contain;
}

.login-split-form {
    flex: 1;
    min-width: 400px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, rgba(9,10,16,0.6) 0%, rgba(23,25,38,0.9) 100%);
    position: relative;
}

@media (max-width: 900px) {
    .login-split-card {
        flex-direction: column;
        width: 90%;
        max-width: 450px;
        height: auto;
    }
    .login-split-image {
        display: none;
    }
}

.login-box {
    width: 100%;
    max-width: 420px;
    padding: 30px;
    position: relative;
    overflow: hidden;
}

/* Robotic Scan Line Effect */
.login-box::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--color-secondary), var(--color-primary), transparent);
    box-shadow: 0 0 15px var(--color-primary-glow), 0 0 25px var(--color-secondary-glow);
    z-index: 10;
    opacity: 0;
    animation: cyberScan 4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    pointer-events: none;
}

@keyframes cyberScan {
    0% { top: -10%; opacity: 0; }
    15% { opacity: 1; }
    85% { opacity: 1; }
    100% { top: 110%; opacity: 0; }
}

@keyframes loginEntrance {
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.login-title img {
    /* Subtle floating animation for the logo */
    animation: floatLogo 6s ease-in-out infinite;
    filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.2));
}

@keyframes floatLogo {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
    100% { transform: translateY(0px); }
}

.login-title {
    text-align: center;
    margin-bottom: 30px;
    font-size: 24px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--text-bright), var(--text-muted));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-muted);
    transition: color 0.3s ease, transform 0.3s ease;
    transform-origin: left;
}

.form-group:focus-within label {
    color: var(--color-primary);
    transform: scale(1.05);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    color: var(--text-bright);
    font-size: 14px;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15), 0 0 15px var(--color-primary-glow);
    transform: translateY(-2px);
}

/* App Header & Navigation */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-text h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.logo-text p {
    font-size: 11px;
    color: var(--text-muted);
}

.nav-links {
    display: flex;
    gap: 10px;
}

.nav-btn {
    padding: 8px 16px;
    border-radius: 10px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    color: var(--text-bright);
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
}

.nav-btn.active {
    color: var(--text-bright);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(6, 182, 212, 0.15));
    border-color: var(--border-card-hover);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}


/* Dropdown Submenu for Header */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: rgba(16, 18, 30, 0.95);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--border-card);
    border-radius: 14px;
    min-width: 210px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    margin-top: 10px;
    padding: 8px;
    flex-direction: column;
    gap: 4px;
}

/* Simple CSS hover activation */
.dropdown:hover .dropdown-content {
    display: flex;
}

/* Invisible bridge to prevent closing on hover gap */
.dropdown::after {
    content: '';
    position: absolute;
    height: 15px;
    width: 100%;
    bottom: -15px;
    left: 0;
}

.dropdown-item {
    padding: 10px 15px;
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    background: transparent;
    border: none;
    width: 100%;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-bright);
}

.dropdown-item i {
    width: 16px;
    text-align: center;
}

/* Dashboard Grid Layout */
.dashboard-container {
    padding: 30px 40px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Top Filters Row */
.filters-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* KPI Cards */
.kpis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
}

.kpi-card {
    padding: 24px;
    position: relative;
    overflow: hidden;
    border-bottom: 3px solid transparent;
}

.kpi-card::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, currentColor 0%, transparent 70%);
    opacity: 0.05;
    transform: translate(30%, -30%);
    border-radius: 50%;
    pointer-events: none;
}

.kpi-card.violet { border-bottom-color: var(--color-primary); }
.kpi-card.cyan { border-bottom-color: var(--color-secondary); }
.kpi-card.emerald { border-bottom-color: var(--color-success); }
.kpi-card.crimson { border-bottom-color: var(--color-danger); }

.kpi-card.violet:hover { box-shadow: 0 15px 30px rgba(139, 92, 246, 0.15); }
.kpi-card.cyan:hover { box-shadow: 0 15px 30px rgba(6, 182, 212, 0.15); }
.kpi-card.emerald:hover { box-shadow: 0 15px 30px rgba(16, 185, 129, 0.15); }

.kpi-title {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 1px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-bright);
    letter-spacing: -0.5px;
    background: linear-gradient(to bottom, #fff, #ccc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    transition: all 0.3s ease;
}
body.light-theme .kpi-value {
    background: none;
    -webkit-text-fill-color: initial;
    color: var(--text-bright);
}
.kpi-card:hover .kpi-value {
    transform: scale(1.02);
    transform-origin: left center;
}


/* Visualizer & Graphics Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 25px;
}

@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    padding: 24px;
}

/* Interactive Data Tables */
.table-card {
    padding: 25px;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.search-input {
    width: 250px;
}

.table-responsive {
    overflow-x: auto;
    max-height: 400px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

th, td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    white-space: nowrap;
}

.data-table th {
    background: rgba(255, 255, 255, 0.02);
    padding: 16px 20px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: sticky;
    top: 0;
    backdrop-filter: blur(10px);
}

.data-table td {
    padding: 14px 20px;
    font-size: 13.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: background 0.2s;
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

body.light-theme .data-table th {
    background: #f9fafb;
    color: #0369a1;
    border-bottom-color: #e5e7eb;
}

body.light-theme .data-table td {
    border-bottom-color: #f3f4f6;
}
body.light-theme .data-table tr:hover td {
    background: #f3f4f6;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
}

/* Floating AI Chat Widget */
.ai-widget {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 500;
}

.ai-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ai-toggle:hover {
    transform: scale(1.08);
}

.ai-panel {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 380px;
    height: 500px;
    display: none;
    flex-direction: column;
}

.ai-panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chat-msg {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
}

.chat-msg.user {
    background: var(--color-primary);
    color: var(--text-bright);
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.chat-msg.bot {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.chat-input-area {
    padding: 15px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 10px;
}

/* Sincronizador File Drop */
.dropzone {
    border: 2px dashed rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.02);
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--color-primary);
    background: rgba(139, 92, 246, 0.05);
}
/* AI INSIGHT WIDGET */
.ai-insight-card {
    border-left: 4px solid var(--color-primary) !important;
    background: linear-gradient(to right, rgba(139, 92, 246, 0.05), var(--bg-card)) !important;
    position: relative;
    overflow: hidden;
}
.ai-insight-card::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent 60%, rgba(139, 92, 246, 0.05) 100%);
    pointer-events: none;
}
.ai-insight-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
body.light-theme .ai-insight-header {
    border-bottom-color: rgba(0,0,0,0.05);
}
.ai-pulse-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-primary);
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.7);
    animation: aiPulse 2s infinite;
}
@keyframes aiPulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(139, 92, 246, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
}
.ai-insight-body {
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--text-main);
}
.ai-insight-body ul {
    padding-left: 20px;
    margin-top: 8px;
}
.ai-insight-body li {
    margin-bottom: 5px;
}
.ai-loading-placeholder {
    color: var(--text-muted);
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* PRINT OVERRIDES */
@media print {
    .no-print, .nav-links, .app-header, .glass-card:not(#dashboard-print-area .glass-card) {
        display: none !important;
    }
    body {
        background: #fff !important;
        color: #000 !important;
    }
    #dashboard-print-area {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    .glass-card {
        background: #fff !important;
        border: 1px solid #ddd !important;
        box-shadow: none !important;
        color: #000 !important;
    }
}

/* =========================================
   View Transitions API (Modern UX) 
   ========================================= */
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 0.4s;
    animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
}

::view-transition-old(root) {
    animation-name: fadeOut, slideOut;
}

::view-transition-new(root) {
    animation-name: fadeIn, slideIn;
}

@keyframes fadeOut {
    to { opacity: 0; }
}

@keyframes fadeIn {
    from { opacity: 0; }
}

@keyframes slideOut {
    to { transform: translateY(-10px) scale(0.98); }
}

@keyframes slideIn {
    from { transform: translateY(10px) scale(0.98); }
}

/* Responsive Overrides for Inline Styles */
@media (max-width: 1024px) {
    #dashboard-view, #matrix-view {
        flex-direction: column !important;
    }
    #dashboard-view > .glass-card:first-of-type, #matrix-view > .glass-card:first-of-type {
        flex: 1 1 auto !important;
        width: 100% !important;
        max-height: 350px !important;
        position: static !important;
    }
    #dashboard-view > div:nth-child(2), #matrix-view > div:nth-child(2) {
        width: 100% !important;
        flex: 1 1 auto !important;
    }
}

@media (max-width: 768px) {
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }
    .app-header {
        flex-direction: column;
        gap: 15px;
        padding: 15px 20px;
    }
}

/* Select Option Styling */
select.form-control option {
    background-color: #1f2937;
    color: #ffffff;
    padding: 8px;
}
body.light-theme select.form-control option {
    background-color: #ffffff;
    color: #1f2937;
}
