/* ==========================================================
   iLibro.pe - Sistema de Diseño SISSA PERÚ
   Paleta oficial: Booking.com Blue (#0071C2), Azul Profundo (#00224F), Amarillo (#FFB700)
   Tipografías oficiales: Bree Peru & Clan OT
   ========================================================== */

/* --- FUENTES PROPIAS (CARPETA /fonts/) --- */
@font-face {
    font-family: 'Bree Peru';
    src: url('/fonts/BreePeru_Regular.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Bree Peru';
    src: url('/fonts/BreePeru_Bold.otf') format('opentype');
    font-weight: bold;
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Clan OT';
    src: url('/fonts/FF-Clan-OT-News.woff') format('woff'),
         url('/fonts/FF_Clan_OT_News.otf') format('opentype');
    font-weight: normal;
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Clan OT';
    src: url('/fonts/FF-Clan-OT-Bold.woff') format('woff'),
         url('/fonts/FF_Clan_OT_Bold.otf') format('opentype');
    font-weight: bold;
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* --- VARIABLES GLOBALES PALETA BOOKING.COM --- */
:root {
    /* Primarios Booking */
    --booking-blue:        #0071C2;
    --booking-blue-dark:   #003B95;
    --booking-blue-deep:   #00224F;
    --booking-blue-mid:    #003580;
    --booking-blue-hover:  #005494;
    --booking-blue-border: #004b9e;
    --booking-gold:        #FFB700;
    --booking-gold-light:  #FFF3CD;

    /* Retrocompatibilidad con código anterior */
    --sissa-orange:        #0071C2;
    --sissa-orange-dark:   #005494;
    --sissa-orange-light:  #dbeafe;
    --sissa-dark:          #00224F;
    --sissa-dark-card:     #003B95;
    --sissa-dark-sidebar:  #00224F;
    --sissa-bg:            #f0f4f9;

    --peru-red:            #0071C2;
    --peru-red-dark:       #005494;
    --peru-red-light:      #60a5fa;
    --peru-gold:           #FFB700;
    --peru-dark:           #00224F;
    --peru-bg:             #f0f4f9;

    --font-heading: 'Bree Peru', sans-serif;
    --font-body: 'Clan OT', sans-serif;

    /* Responsive layout */
    --sidebar-width: 275px;
    --header-height-mobile: 64px;
}

/* --- RESET Y BASE --- */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

/* --- APLICACIÓN GLOBAL DE TIPOGRAFÍAS --- */
* {
    font-family: 'Clan OT', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

h1, h2, h3, h4, h5, h6, .font-bree {
    font-family: 'Bree Peru', 'Clan OT', sans-serif;
}

.font-clan {
    font-family: 'Clan OT', sans-serif;
}

/* --- LAYOUT PRINCIPAL (SIDEBAR + CONTENIDO) --- */
.panel-layout {
    display: flex;
    min-height: 100vh;
}

/* Contenido principal con margen para sidebar */
.main-content {
    flex: 1;
    min-width: 0;
    transition: margin-left 0.3s ease;
}

@media (min-width: 1024px) {
    .main-content {
        margin-left: var(--sidebar-width);
    }
}

/* Padding top en mobile para el header fijo */
@media (max-width: 1023px) {
    body > .main-content,
    #mainContent,
    .content-wrapper {
        padding-top: var(--header-height-mobile);
    }
}

/* --- SIDEBAR --- */
#sidebar {
    width: var(--sidebar-width);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar.open {
    transform: translateX(0) !important;
}

/* --- CLASES DE UTILIDAD PALETA BOOKING --- */
.bg-booking-blue    { background-color: var(--booking-blue) !important; }
.bg-booking-dark    { background-color: var(--booking-blue-deep) !important; }
.bg-booking-gold    { background-color: var(--booking-gold) !important; }

.text-booking-blue  { color: var(--booking-blue) !important; }
.text-booking-dark  { color: var(--booking-blue-deep) !important; }
.text-booking-gold  { color: var(--booking-gold) !important; }

.border-booking-blue { border-color: var(--booking-blue) !important; }

/* Retrocompatibilidad */
.bg-sissa-orange    { background-color: var(--booking-blue) !important; }
.bg-sissa-dark      { background-color: var(--booking-blue-deep) !important; }
.bg-sissa-sidebar   { background-color: var(--booking-blue-deep) !important; }
.text-sissa-orange  { color: var(--booking-blue) !important; }
.border-sissa-orange{ border-color: var(--booking-blue) !important; }

.shadow-sissa-orange {
    box-shadow: 0 10px 25px -5px rgba(0, 113, 194, 0.35) !important;
}

.glow-blue {
    box-shadow: 0 0 30px -5px rgba(0, 113, 194, 0.4);
}

.glow-orange {
    box-shadow: 0 0 30px -5px rgba(0, 113, 194, 0.4);
}

.glow-gold {
    box-shadow: 0 0 30px -5px rgba(255, 183, 0, 0.35);
}

/* --- GLASSMORPHISM --- */
.glass-panel {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(226, 232, 240, 0.8);
}

.glass-panel-blue {
    background: rgba(0, 34, 79, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 113, 194, 0.3);
}

.glass-panel-dark {
    background: rgba(0, 34, 79, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 75, 158, 0.5);
}

/* Tarjeta sobre fondo azul */
.glass-card {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 1rem;
}

/* --- LAZY LOADING OPTIMIZADO & EFECTO SHIMMER --- */
img[data-src], img.lazy-img {
    opacity: 0;
    transition: opacity 0.35s ease-in-out, transform 0.35s ease-out;
    background-color: #f1f5f9;
}

img.lazy-loaded {
    opacity: 1 !important;
}

img.lazy-loading {
    position: relative;
    background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
    background-size: 200% 100%;
    animation: shimmerLoader 1.5s infinite linear;
}

@keyframes shimmerLoader {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* --- ANIMACIONES --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.animate-fade-in    { animation: fadeIn 0.4s ease forwards; }
.animate-slide-in   { animation: slideInLeft 0.3s ease forwards; }
.animate-pulse-badge{ animation: pulse-badge 2s ease-in-out infinite; }

/* --- TARJETAS (CARDS) --- */
.card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    box-shadow: 0 1px 3px 0 rgba(0,0,0,0.06), 0 1px 2px -1px rgba(0,0,0,0.06);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 16px -2px rgba(0, 59, 149, 0.12), 0 2px 6px -1px rgba(0,0,0,0.06);
}

.card-blue {
    background: linear-gradient(135deg, #003B95 0%, #00224F 100%);
    color: white;
    border: 1px solid rgba(0, 113, 194, 0.3);
    border-radius: 1rem;
    box-shadow: 0 4px 20px -4px rgba(0, 59, 149, 0.4);
}

/* --- BOTONES --- */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: var(--booking-blue);
    color: #fff;
    font-family: 'Bree Peru', sans-serif;
    font-weight: 700;
    font-size: 0.8125rem;
    border-radius: 0.75rem;
    border: none;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
    box-shadow: 0 2px 8px rgba(0,113,194,0.3);
}

.btn-primary:hover  { background: var(--booking-blue-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,113,194,0.4); }
.btn-primary:active { transform: scale(0.97); }

.btn-gold {
    background: var(--booking-gold);
    color: #1a1a2e;
    font-family: 'Bree Peru', sans-serif;
    font-weight: 900;
}

.btn-gold:hover { background: #e6a500; }

/* --- BADGES Y ETIQUETAS --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.badge-blue   { background: rgba(0,113,194,0.1); color: #0071C2; border: 1px solid rgba(0,113,194,0.25); }
.badge-gold   { background: rgba(255,183,0,0.15); color: #b37d00; border: 1px solid rgba(255,183,0,0.35); }
.badge-green  { background: rgba(16,185,129,0.1); color: #059669; border: 1px solid rgba(16,185,129,0.25); }
.badge-red    { background: rgba(239,68,68,0.1);  color: #dc2626; border: 1px solid rgba(239,68,68,0.25); }

/* --- SCROLLBAR PERSONALIZADO --- */
.custom-scrollbar::-webkit-scrollbar { width: 5px; height: 5px; }
.custom-scrollbar::-webkit-scrollbar-track { background: rgba(0, 34, 79, 0.08); }
.custom-scrollbar::-webkit-scrollbar-thumb { background: rgba(0, 113, 194, 0.35); border-radius: 4px; }
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: rgba(0, 113, 194, 0.65); }

/* Scrollbar claro (para sidebars oscuros) */
.scrollbar-dark::-webkit-scrollbar { width: 4px; }
.scrollbar-dark::-webkit-scrollbar-track { background: transparent; }
.scrollbar-dark::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }
.scrollbar-dark::-webkit-scrollbar-thumb:hover { background: rgba(255,183,0,0.5); }

/* --- RESPONSIVE: TABLAS --- */
.responsive-table {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.responsive-table table {
    min-width: 600px;
}

/* --- RESPONSIVE: GRIDS --- */
@media (max-width: 640px) {
    .grid-responsive-2 { grid-template-columns: 1fr !important; }
    .grid-responsive-3 { grid-template-columns: repeat(2, 1fr) !important; }
    .grid-responsive-4 { grid-template-columns: repeat(2, 1fr) !important; }
    .hide-mobile { display: none !important; }
    .text-mobile-sm { font-size: 0.75rem !important; }
}

@media (max-width: 768px) {
    .hide-tablet { display: none !important; }
    .stack-mobile { flex-direction: column !important; }
}

/* --- ACTIVE PILL (menu activo) --- */
.active-pill {
    position: relative;
}

.active-pill::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--booking-gold);
    border-radius: 0 4px 4px 0;
}

/* --- PROGRESS BAR --- */
.progress-bar-track {
    background: rgba(0, 113, 194, 0.12);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-bar-fill {
    background: linear-gradient(90deg, #0071C2, #003B95);
    border-radius: 9999px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-bar-fill-gold {
    background: linear-gradient(90deg, #FFB700, #e6a500);
}

/* --- STAT CARDS --- */
.stat-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    padding: 1.25rem;
    transition: all 0.2s ease;
}

.stat-card:hover {
    border-color: rgba(0, 113, 194, 0.3);
    box-shadow: 0 4px 16px rgba(0, 59, 149, 0.10);
}

.stat-card .stat-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-card .stat-value {
    font-family: 'Bree Peru', sans-serif;
    font-size: 1.75rem;
    font-weight: 900;
    color: #00224F;
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    margin-top: 0.25rem;
}

/* --- MOBILE BOTTOM NAV (alternativa al sidebar en móvil) --- */
.mobile-bottom-nav {
    display: none;
}

@media (max-width: 1023px) {
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 64px;
        background: #00224F;
        border-top: 1px solid rgba(0, 113, 194, 0.3);
        z-index: 45;
        align-items: center;
        justify-content: space-around;
        padding: 0 0.5rem;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .mobile-bottom-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 0.4rem 0.75rem;
        border-radius: 0.625rem;
        color: rgba(255,255,255,0.6);
        font-size: 0.6rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        transition: all 0.15s ease;
        text-decoration: none;
        min-width: 56px;
        text-align: center;
    }
    .mobile-bottom-nav a svg,
    .mobile-bottom-nav svg {
        width: 22px !important;
        height: 22px !important;
        min-width: 22px !important;
        min-height: 22px !important;
        max-width: 22px !important;
        max-height: 22px !important;
        flex-shrink: 0 !important;
        display: block !important;
    }

    .mobile-bottom-nav a.active,
    .mobile-bottom-nav a:active {
        color: #FFB700;
        background: rgba(255, 183, 0, 0.1);
    }

    .mobile-bottom-nav a:hover {
        color: white;
        background: rgba(255, 255, 255, 0.08);
    }

    /* Dar espacio para bottom nav en el body */
    body.has-bottom-nav main,
    body.has-bottom-nav .main-content,
    body.has-bottom-nav #mainContent {
        padding-bottom: 76px !important;
    }
}

/* --- INPUTS Y FORMULARIOS --- */
.form-input {
    width: 100%;
    padding: 0.6rem 0.875rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 0.75rem;
    font-size: 0.8125rem;
    color: #1e293b;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.form-input:focus {
    border-color: #0071C2;
    box-shadow: 0 0 0 3px rgba(0, 113, 194, 0.12);
}

/* --- PRINT MEDIA --- */
@media print {
    #sidebar, .mobile-bottom-nav, #mobileMenuBtn { display: none !important; }
    .main-content, #mainContent { margin-left: 0 !important; padding-top: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #e2e8f0 !important; }
}
