/* =============================================
   DESIGN SYSTEM — Eena Light Theme
   ============================================= */
:root {
    /* Page */
    --bg-page:        #f5f5f5;
    --card-bg:        #ffffff;
    --border-color:   #e5e7eb;

    /* Sidebar — light */
    --sidebar-bg:     #ffffff;
    --sidebar-text:   #4b5563;
    --sidebar-hover:  #f3f4f6;
    --sidebar-active-bg: #f3f4f6;
    --sidebar-active-text: #111827;

    /* Typography */
    --text-primary:   #111827;
    --text-secondary: #6b7280;

    /* Accent palette (Eena indigo/blue) */
    --indigo:   #4f46e5;
    --indigo-lt:#eef2ff;
    --blue:     #3b82f6;
    --blue-lt:  #eff6ff;
    --teal:     #06b6d4;
    --teal-lt:  #ecfeff;
    --green:    #22c55e;
    --green-lt: #f0fdf4;
    --orange:   #f97316;
    --red:      #ef4444;
    --purple:   #a855f7;

    /* GSC */
    --gsc-clicks:      #4f46e5;
    --gsc-impressions: #06b6d4;
    --gsc-ctr:         #ef4444;
    --gsc-position:    #f97316;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-page);
    color: var(--text-primary);
    overflow-x: hidden;
    font-size: 0.9rem;
}

/* =============================================
   SIDEBAR — light, clean
   ============================================= */
.sidebar {
    width: 230px;
    z-index: 1040;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    box-shadow: 2px 0 8px rgba(0,0,0,0.05);
}

.sidebar-heading {
    padding: 1.4rem 1.2rem 0.8rem;
    font-weight: 800;
    font-size: 1.15rem;
    color: #111827;
    display: flex;
    align-items: center;
    letter-spacing: -0.3px;
}

.sidebar-heading i { color: #111827; }

/* Section labels */
.nav-link.d-flex.align-items-center.text-muted.fw-bold.small.text-uppercase.mt-2.mb-1 {
    color: #94a3b8 !important;
    font-size: 0.65rem !important;
    letter-spacing: 1.4px !important;
    padding: 10px 20px 4px !important;
    margin: 0 !important;
    border-radius: 0 !important;
    background: none !important;
}

.sidebar .nav-link {
    border-radius: 10px;
    margin: 2px 10px;
    padding: 9px 14px;
    color: var(--sidebar-text);
    transition: all 0.15s;
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    font-weight: 500;
}

.sidebar .nav-link i { font-size: 1rem; }

.sidebar .nav-link:hover {
    color: var(--indigo);
    background-color: var(--sidebar-hover);
}

.sidebar .nav-link.active {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-active-text) !important;
    font-weight: 600;
    box-shadow: none;
}

.sidebar .nav-link.active i { color: var(--sidebar-active-text); }

/* Sub-nav */
.sidebar ul ul .nav-link {
    margin: 1px 10px 1px 28px;
    padding: 7px 12px;
    font-size: 0.83rem;
    font-weight: 400;
    color: #94a3b8;
}

.sidebar ul ul .nav-link:hover { color: var(--indigo); }

.sidebar ul ul .nav-link.active {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-active-text) !important;
    font-weight: 600;
    box-shadow: none;
}

/* Sidebar bottom */
.sidebar .mt-auto {
    border-top: 1px solid var(--border-color) !important;
    background: var(--sidebar-bg);
}

/* =============================================
   MAIN CONTENT
   ============================================= */
.main-content {
    margin-left: 230px;
    min-height: 100vh;
}

/* ---- Header ---- */
header {
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color) !important;
    padding: 0.9rem 1.75rem !important;
    margin-bottom: 0 !important;
}

header h1 {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary) !important;
}

/* =============================================
   CARDS
   ============================================= */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    color: var(--text-primary);
    transition: box-shadow 0.2s, transform 0.15s;
}

.card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}

.card-header {
    border-radius: 16px 16px 0 0 !important;
    background-color: #ffffff !important;
    border-bottom: 1px solid var(--border-color) !important;
    padding: 1rem 1.25rem;
}

/* KPI stat cards */
.stat-card { border-left-width: 3px !important; }

.stat-card .text-xs,
.card .text-xs {
    font-size: 0.67rem;
    text-transform: uppercase;
    letter-spacing: 1.1px;
    font-weight: 700;
    color: var(--text-secondary);
}

.stat-card .h5 {
    font-weight: 700;
    margin-top: 4px;
    margin-bottom: 0;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.border-left-primary { border-left: 3px solid var(--gsc-clicks) !important; }
.border-left-success { border-left: 3px solid var(--gsc-impressions) !important; }
.border-left-danger  { border-left: 3px solid var(--gsc-ctr) !important; }
.border-left-warning { border-left: 3px solid var(--gsc-position) !important; }

/* =============================================
   BUTTONS
   ============================================= */
.btn-primary {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.85rem;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #4338ca, #6d28d9);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
}

.btn-lime, .btn-warning {
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    color: #ffffff;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    font-size: 0.85rem;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.25);
}

.btn-lime:hover, .btn-warning:hover {
    background: linear-gradient(135deg, #4338ca, #0891b2);
    color: #fff;
}

.btn-outline-danger {
    border-color: var(--red);
    color: var(--red);
    border-radius: 10px;
    font-size: 0.85rem;
}

/* =============================================
   TABLES
   ============================================= */
.table { color: var(--text-primary); }

.table thead th {
    background-color: #f8f9ff;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.67rem;
    text-transform: uppercase;
    letter-spacing: 0.9px;
    font-weight: 700;
    padding: 12px 16px;
}

.table tbody td {
    border-bottom: 1px solid #f1f5ff;
    padding: 12px 16px;
    vertical-align: middle;
    font-size: 0.85rem;
}

.table-hover tbody tr:hover { background-color: #f8f9ff; }

.badge-position {
    background-color: var(--indigo-lt);
    color: var(--indigo);
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.78rem;
}

/* =============================================
   FORMS
   ============================================= */
.input-group-text {
    background-color: #f8f9ff !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-secondary);
    border-radius: 10px 0 0 10px !important;
}

.form-select, .form-control {
    background-color: #ffffff !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    border-radius: 10px !important;
    font-size: 0.875rem;
}

.form-select:focus, .form-control:focus {
    border-color: var(--indigo) !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12) !important;
}

/* =============================================
   BADGES
   ============================================= */
.badge {
    font-weight: 600;
    font-size: 0.72rem;
    border-radius: 6px;
    padding: 4px 9px;
}

/* =============================================
   ALERTS / ACTIVITY
   ============================================= */
.alert-item {
    background-color: #f8f9ff;
    border-radius: 12px;
    padding: 13px;
    margin-bottom: 8px;
    border-left: 3px solid transparent;
}

.alert-item.down { border-left-color: var(--red); }
.alert-item.up   { border-left-color: var(--green); }

/* =============================================
   TEXT UTILITIES
   ============================================= */
.text-lime { color: var(--indigo) !important; }

.text-muted {
    --bs-text-opacity: 1;
    color: var(--text-secondary) !important;
}

.xsmall { font-size: 0.72rem; }

/* =============================================
   SCROLLBAR
   ============================================= */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c7d2fe; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #a5b4fc; }

/* =============================================
   SECTION ANIMATION
   ============================================= */
.dashboard-section {
    animation: fadeIn 0.22s ease-out forwards;
    padding: 1.75rem;
}

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

/* =============================================
   LOGIN
   ============================================= */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f4f5f7;
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    z-index: 9999;
    padding: 24px;
}

.login-split-card {
    display: flex;
    flex-direction: row;
    width: 100%;
    max-width: 1040px;
    min-height: 580px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0,0,0,0.10);
}

.login-left {
    flex: 1;
    background: linear-gradient(160deg, #fdf8f0 0%, #f5f0ff 50%, #ede9fe 100%);
    padding: 56px 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-right: 1px solid #e9e4f0;
}

.login-left h2 {
    color: #111827;
    font-size: 1.4rem;
    margin-bottom: 8px;
}

.login-left > p {
    color: #6b5e7a;
    font-size: 0.88rem;
    line-height: 1.7;
    margin-bottom: 32px;
}

.login-features {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-features li {
    color: #4a4060;
    font-size: 0.86rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.login-features li i {
    color: #7c3aed;
    font-size: 1rem;
    flex-shrink: 0;
    width: 20px;
}

.login-features li strong {
    color: #111827;
}

.login-right {
    width: 480px;
    flex-shrink: 0;
    background: #ffffff;
    padding: 52px 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-box { background: #fff; border-radius: 22px; }
.login-logo { display: none; }
.login-box h3 { color: var(--text-primary) !important; }
.login-box .btn-primary { color: #fff !important; }

@media (max-width: 768px) {
    .login-left { display: none; }
    .login-split-card { max-width: 440px; flex-direction: column; }
    .login-right { width: 100%; padding: 40px 32px; }
}

/* =============================================
   HERO WELCOME CARD (dashboard)
   ============================================= */
#dashboardSection .card[style*="gradient"] {
    border: none !important;
    box-shadow: 0 10px 40px rgba(79, 70, 229, 0.2) !important;
}

/* =============================================
   MISC
   ============================================= */
.card.mb-4 { border-radius: 16px; }

#mainApp {
    background-color: var(--bg-page);
    min-height: 100vh;
}

#screamingFrogSection { display: none !important; }

.progress { border-radius: 6px; }
.progress-bar { background: linear-gradient(90deg, var(--indigo), var(--blue)); }

.blink { animation: blink 1.5s infinite; }
@keyframes blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.3; }
}

/* Dropdown — light */
.dropdown-menu-dark {
    background-color: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}

.dropdown-menu-dark .dropdown-item {
    color: #94a3b8;
    font-size: 0.85rem;
    border-radius: 8px;
    margin: 1px 4px;
}

.dropdown-menu-dark .dropdown-item:hover {
    background-color: rgba(79, 70, 229, 0.15);
    color: #e0e7ff;
}

/* Sticky table header */
.table thead.sticky-top th { top: 0; z-index: 1; }

/* WebCEO section buttons */
#webceoSection .btn-warning {
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
}

/* GSC Performance stat cards */
.stat-card.border-left-primary .h5 { color: var(--indigo); }
.stat-card.border-left-success .h5 { color: var(--teal); }
.stat-card.border-left-danger  .h5 { color: var(--red); }
.stat-card.border-left-warning .h5 { color: var(--orange); }

/* Header action buttons */
header .btn {
    border-radius: 10px !important;
    font-size: 0.82rem !important;
    font-weight: 500 !important;
}

/* =============================================
   Utility classes (extracted from inline styles)
   ============================================= */
.icon-box-48 { width: 48px; height: 48px; }
.icon-box-90 { width: 90px; height: 90px; }
.icon-box-130 { width: 130px; height: 130px; }

.badge-pill-translucent {
    background: rgba(255,255,255,0.18);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
}

.text-color-purple { color: #7c3aed; }

.fs-140 { font-size: 1.4rem; }
.fs-90  { font-size: 0.9rem; }
.fs-70  { font-size: 0.7rem; }
.fs-35  { font-size: 0.35rem; }

.scroll-box-sm { max-height: 220px; overflow-y: auto; }
.scroll-box-md { max-height: 420px; overflow-y: auto; }
.scroll-box-lg { max-height: 520px; overflow-y: auto; }

.gradient-hero {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #06b6d4 100%);
    box-shadow: 0 8px 32px rgba(79, 70, 229, 0.22);
}

/* =============================================
   PRINT / PDF
   ============================================= */
@media print {
    @page {
        margin: 12mm 10mm;
        size: A4 portrait;
    }

    /* Ocultar UI — sidebar, header, botones, login */
    #sidebar,
    #mainApp header,
    #loginScreen,
    #scanForm,
    .btn,
    button,
    nav,
    .dropdown,
    .spinner-border {
        display: none !important;
    }

    body, html {
        background: #fff !important;
        font-size: 10.5pt;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    #mainApp {
        display: block !important;
    }

    /* Quitar margin del sidebar — contenido full width */
    main.main-content {
        margin-left: 0 !important;
        padding: 0 8mm !important;
        width: 100% !important;
        max-width: 100% !important;
        min-height: unset !important;
    }

    /* Ocultar dashboard general — solo reportes con datos */
    #dashboardSection {
        display: none !important;
    }

    /* Ocultar formulario de entrada AI */
    #aiInputCard,
    #aiAnalysisSection > .d-flex.mb-4 {
        display: none !important;
    }

    /* Expandir contenedores con max-height (oportunidades PSI) */
    [style*="max-height"],
    .card-body[style*="overflow"] {
        max-height: none !important;
        overflow: visible !important;
    }

    /* Tarjetas sin sombra */
    .card {
        border: 1px solid #d1d5db !important;
        box-shadow: none !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* Separación entre secciones */
    .dashboard-section {
        margin-bottom: 8mm !important;
    }

    /* Tablas */
    table {
        font-size: 8.5pt;
        width: 100% !important;
        border-collapse: collapse !important;
    }

    th, td {
        padding: 3px 6px !important;
        border: 1px solid #d1d5db !important;
    }

    thead { background: #f8fafc !important; }

    /* Score cards PSI — 4 en fila */
    #psiResults .row {
        display: flex !important;
        flex-wrap: wrap !important;
    }

    #psiResults .col-6 {
        flex: 0 0 25% !important;
        max-width: 25% !important;
    }

    /* Análisis IA */
    #aiAnalysisContent {
        font-size: 10pt;
        line-height: 1.6;
    }

    /* Salto de página entre secciones grandes */
    #pagespeedSection,
    #aiAnalysisSection,
    #webceoSection {
        page-break-before: always;
    }

    #pagespeedSection:first-child {
        page-break-before: avoid;
    }
}
