/* ==========================================================================
   Biblioteca Digital - Instituto American Jiliu
   Tema visual elegante con títulos 3D animados
   ========================================================================== */

:root {
    --primary: #d62e58;
    --primary-dark: #a81f42;
    --primary-light: #ff5d84;
    --secondary: #555353;
    --accent: #7c3aed;
    --gold: #f5b301;
    --bg: #f4f6fb;
    --bg-soft: #ffffff;
    --surface: #ffffff;
    --text: #1b2340;
    --text-muted: #6b7391;
    --border: rgba(18, 24, 48, .09);
    --shadow: 0 18px 45px -20px rgba(18, 24, 48, .35);
    --radius: 20px;
    --nav-bg: rgba(255, 255, 255, .82);
    --nav-text: #1b2340;
}

html[data-theme="dark"] {
    --bg: #0c1020;
    --bg-soft: #141a2e;
    --surface: #161d33;
    --text: #e8ecf5;
    --text-muted: #9aa6c4;
    --border: rgba(255, 255, 255, .08);
    --shadow: 0 18px 45px -18px rgba(0, 0, 0, .75);
    --nav-bg: rgba(12, 16, 32, .82);
    --nav-text: #e8ecf5;
}

* { box-sizing: border-box; }

body {
    font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
    transition: background .4s ease, color .4s ease;
}

a { text-decoration: none; }

/* Fondo decorativo animado */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(60vw 60vw at 12% -10%, rgba(214, 46, 88, .16), transparent 60%),
        radial-gradient(50vw 50vw at 100% 0%, rgba(124, 58, 237, .14), transparent 55%),
        radial-gradient(40vw 40vw at 50% 120%, rgba(13, 94, 244, .12), transparent 60%);
    animation: fluirFondo 18s ease-in-out infinite alternate;
}

@keyframes fluirFondo {
    0% { transform: translate3d(0, 0, 0) scale(1); }
    100% { transform: translate3d(0, -24px, 0) scale(1.06); }
}

/* ------------------------------ Navbar ------------------------------ */
.navbar-jiliu {
    background: var(--nav-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 8px 30px -22px rgba(0, 0, 0, .6);
    padding: .55rem 0;
}

.navbar-jiliu .navbar-brand {
    color: var(--text);
    font-weight: 800;
    letter-spacing: .2px;
    display: flex;
    align-items: center;
    gap: .65rem;
}

.navbar-jiliu .navbar-brand .brand-logo {
    height: 48px;
    filter: drop-shadow(0 6px 12px rgba(214, 46, 88, .35));
}

.navbar-jiliu .brand-text small {
    display: block;
    font-size: .62rem;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--primary);
    line-height: 1;
}

.navbar-jiliu .nav-link {
    color: var(--nav-text);
    font-weight: 600;
    border-radius: 12px;
    padding: .5rem .9rem !important;
    transition: all .25s ease;
}

.navbar-jiliu .nav-link:hover,
.navbar-jiliu .nav-link.active {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -12px var(--primary);
}

.btn-jiliu {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    font-weight: 700;
    border-radius: 50px;
    box-shadow: 0 14px 26px -14px var(--primary);
    transition: transform .25s ease, box-shadow .25s ease;
}
.btn-jiliu:hover { color: #fff; transform: translateY(-2px); box-shadow: 0 20px 32px -14px var(--primary); }

.btn-outline-jiliu {
    border: 2px solid var(--primary);
    color: var(--primary);
    font-weight: 700;
    border-radius: 50px;
    transition: all .25s ease;
}
.btn-outline-jiliu:hover { background: var(--primary); color: #fff; }

.theme-toggle {
    width: 42px; height: 42px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%; border: 1px solid var(--border);
    background: var(--surface); color: var(--text);
    transition: transform .3s ease;
}
.theme-toggle:hover { transform: rotate(-18deg) scale(1.08); }

/* --------------------------- Título 3D ------------------------------ */
.hero-3d {
    position: relative;
    padding: 4.6rem 0 3.4rem;
    text-align: center;
    perspective: 900px;
}

.titulo-3d {
    font-weight: 900;
    line-height: 1.02;
    letter-spacing: -.5px;
    font-size: clamp(2.3rem, 6vw, 4.8rem);
    color: #fff;
    text-transform: uppercase;
    transform-style: preserve-3d;
    animation: tituloFlota 6s ease-in-out infinite;
    text-shadow:
        0 1px 0 #b32146, 0 2px 0 #a81f42, 0 3px 0 #9c1c3d,
        0 4px 0 #8f1938, 0 5px 0 #821633, 0 6px 0 #75132e,
        0 7px 0 #680f29, 0 8px 0 #5b0c24, 0 9px 0 #4e091f,
        0 14px 22px rgba(0, 0, 0, .45),
        0 26px 40px rgba(214, 46, 88, .35);
}

.titulo-3d .linea-2 {
    display: block;
    background: linear-gradient(90deg, #ffd36e, #f5b301, #ff8a3d, #f5b301, #ffd36e);
    background-size: 250% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    -webkit-text-stroke: 1px rgba(0, 0, 0, .18);
    animation: brilloOro 4s linear infinite, tituloFlota 6s ease-in-out infinite;
    text-shadow: 0 10px 24px rgba(245, 179, 1, .35);
}

@keyframes tituloFlota {
    0%, 100% { transform: rotateX(6deg) translateY(0); }
    50% { transform: rotateX(6deg) translateY(-12px); }
}

@keyframes brilloOro {
    0% { background-position: 0% center; }
    100% { background-position: 250% center; }
}

.hero-sub {
    color: var(--text-muted);
    font-size: clamp(.95rem, 1.6vw, 1.15rem);
    font-weight: 500;
    max-width: 720px;
    margin: 1.1rem auto 0;
}

.hero-chips { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; margin-top: 1.6rem; }
.hero-chips .chip {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 50px;
    padding: .45rem 1.05rem;
    font-size: .82rem;
    font-weight: 600;
    box-shadow: var(--shadow);
    animation: subirEntrada .7s backwards;
}
.hero-chips .chip i { color: var(--primary); }
.hero-chips .chip:nth-child(1) { animation-delay: .1s; }
.hero-chips .chip:nth-child(2) { animation-delay: .2s; }
.hero-chips .chip:nth-child(3) { animation-delay: .3s; }
.hero-chips .chip:nth-child(4) { animation-delay: .4s; }

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

/* ---------------------------- Buscador ------------------------------ */
.buscador-wrap {
    max-width: 760px;
    margin: 1.9rem auto 0;
    position: relative;
}
.buscador {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: .45rem .55rem .45rem 1.35rem;
    box-shadow: var(--shadow);
}
.buscador input {
    border: none; outline: none; background: transparent;
    flex: 1; padding: .7rem .5rem; color: var(--text);
    font-size: 1rem;
}
.buscador input::placeholder { color: var(--text-muted); }
.buscador .icono { color: var(--primary); font-size: 1.1rem; }

.sugerencias {
    position: absolute;
    top: calc(100% + 8px);
    left: 0; right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow);
    z-index: 1200;
    max-height: 420px;
    overflow-y: auto;
}
.sugerencias a {
    display: flex; gap: .8rem; align-items: center;
    padding: .65rem .9rem; color: var(--text);
    border-bottom: 1px solid var(--border);
}
.sugerencias a:hover { background: rgba(214, 46, 88, .07); }
.sugerencias img { width: 38px; height: 50px; object-fit: cover; border-radius: 6px; }

/* ------------------------- Sección / títulos ------------------------ */
.seccion-titulo {
    font-weight: 800;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: .6rem;
}
.seccion-titulo .barra {
    width: 6px; height: 30px; border-radius: 6px;
    background: linear-gradient(180deg, var(--primary), var(--accent));
}

.titulo-seccion-3d {
    font-weight: 800;
    color: var(--text);
    text-shadow: 0 1px 0 rgba(255,255,255,.5);
    letter-spacing: -.3px;
}

/* --------------------------- Book cards ----------------------------- */
.book-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    height: 100%;
    transition: transform .35s cubic-bezier(.2,.7,.3,1), box-shadow .35s ease;
    transform-style: preserve-3d;
}
.book-card:hover {
    transform: translateY(-10px) rotateX(4deg);
    box-shadow: 0 30px 50px -24px rgba(18, 24, 48, .55);
}
.book-cover {
    position: relative;
    aspect-ratio: 2 / 3;
    overflow: hidden;
    background: #0f1424;
}
.book-cover img {
    width: 100%; height: 100%; object-fit: cover;
    transition: transform .5s ease;
}
.book-card:hover .book-cover img { transform: scale(1.07); }

.book-overlay {
    position: absolute; inset: 0;
    background: linear-gradient(180deg, rgba(12,16,32,.05) 30%, rgba(12,16,32,.92));
    display: flex; flex-direction: column; justify-content: flex-end; gap: .5rem;
    padding: 1rem;
    opacity: 0; transition: opacity .35s ease;
}
.book-card:hover .book-overlay { opacity: 1; }

.badge-tipo {
    position: absolute; top: .7rem; left: .7rem;
    background: rgba(12, 16, 32, .82);
    color: #fff; font-size: .68rem; font-weight: 700;
    padding: .28rem .6rem; border-radius: 50px;
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255,255,255,.18);
}
.badge-tipo i { margin-right: .25rem; }

.book-body { padding: 1rem 1.05rem 1.25rem; }
.book-title {
    font-size: .95rem; font-weight: 700; color: var(--text);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; min-height: 2.6em; margin-bottom: .3rem;
    line-height: 1.3;
}
.book-author { font-size: .78rem; color: var(--text-muted); }
.book-author i { color: var(--primary); }

/* ------------------------------ Programas ---------------------------- */
.programa-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    height: 100%;
    position: relative;
    transition: transform .3s ease, box-shadow .3s ease;
}
.programa-card:hover { transform: translateY(-8px); box-shadow: var(--shadow); }
.programa-card .franja { height: 8px; }
.programa-card .ico {
    width: 62px; height: 62px; border-radius: 18px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem; color: #fff;
    box-shadow: 0 14px 26px -14px currentColor;
}
.programa-card:hover .ico { animation: latido 1.1s ease-in-out infinite; }
@keyframes latido { 0%,100% { transform: scale(1); } 50% { transform: scale(1.1); } }

/* ------------------------------ Filtros ------------------------------ */
.filtro-chip {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 50px;
    padding: .4rem 1rem;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s ease;
    white-space: nowrap;
}
.filtro-chip:hover, .filtro-chip.activo {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff; border-color: transparent;
}

/* ------------------------------- Panel ------------------------------- */
.sidebar-admin {
    background: linear-gradient(180deg, #141a2e, #0c1020);
    color: #cdd5e8;
    min-height: 100vh;
    width: 260px;
    position: fixed;
    top: 0; left: 0;
    padding: 1.2rem 1rem;
    z-index: 1040;
    transition: transform .3s ease;
}
.sidebar-admin .marca { display: flex; align-items: center; gap: .7rem; padding: .4rem .4rem 1.2rem; }
.sidebar-admin .marca img { height: 46px; }
.sidebar-admin .marca span { font-weight: 800; color: #fff; line-height: 1.1; font-size: .95rem; }
.sidebar-admin a.nav-enlace {
    display: flex; align-items: center; gap: .8rem;
    color: #aab4cf; padding: .7rem .85rem; border-radius: 12px;
    font-weight: 600; font-size: .9rem; margin-bottom: .22rem;
    transition: all .2s ease;
}
.sidebar-admin a.nav-enlace:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-admin a.nav-enlace.activo {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff; box-shadow: 0 12px 22px -14px var(--primary);
}
.sidebar-admin .nav-enlace i { width: 20px; text-align: center; }
.contenido-admin { margin-left: 260px; min-height: 100vh; transition: margin .3s ease; }

@media (max-width: 991px) {
    .sidebar-admin { transform: translateX(-100%); }
    .sidebar-admin.abierto { transform: translateX(0); }
    .contenido-admin { margin-left: 0; }
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.3rem;
    position: relative;
    overflow: hidden;
    transition: transform .3s ease;
}
.stat-card:hover { transform: translateY(-6px); }
.stat-card .valor { font-size: 2rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-card .etiqueta { color: var(--text-muted); font-size: .82rem; font-weight: 600; }
.stat-card .ico-f {
    position: absolute; right: 1rem; top: 1rem;
    width: 52px; height: 52px; border-radius: 15px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; color: #fff;
}

.card-jiliu {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.table-jiliu thead th {
    background: rgba(214, 46, 88, .08);
    color: var(--text);
    font-weight: 700;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    border: none;
}
.table-jiliu td { vertical-align: middle; color: var(--text); border-color: var(--border); }
.table-jiliu { color: var(--text); }

.form-control, .form-select {
    background: var(--bg-soft); color: var(--text);
    border: 1px solid var(--border); border-radius: 12px;
    padding: .6rem .85rem;
}
.form-control:focus, .form-select:focus {
    background: var(--bg-soft); color: var(--text);
    border-color: var(--primary);
    box-shadow: 0 0 0 .2rem rgba(214, 46, 88, .2);
}
.form-label { font-weight: 600; font-size: .85rem; color: var(--text); }

/* ------------------------------ Lectura ------------------------------ */
.lector-marco {
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    background: #0c1020;
}
.lector-marco iframe, .lector-marco embed, .lector-marco video, .lector-marco img {
    width: 100%; display: block; border: none;
}
.lector-marco iframe { height: 82vh; }
.contenido-lectura { transition: filter .4s ease; }
.modo-sepia .contenido-lectura { filter: sepia(.85) contrast(1.08) brightness(.95); }
.modo-noche .contenido-lectura { filter: invert(.92) hue-rotate(180deg) brightness(1.05) contrast(1.15); }

.bloque-bloqueado {
    background: linear-gradient(135deg, rgba(214,46,88,.08), rgba(124,58,237,.08));
    border: 1px dashed var(--primary);
    border-radius: var(--radius);
    padding: 3rem 1.5rem;
    text-align: center;
}

/* ------------------------------ Footer ------------------------------- */
.footer-jiliu {
    background: linear-gradient(180deg, transparent, rgba(214, 46, 88, .06));
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    margin-top: 4rem;
}
.footer-jiliu a { color: var(--text-muted); }
.footer-jiliu a:hover { color: var(--primary); }

/* ------------------------------- Extras ------------------------------ */
.aos-init { opacity: 0; }

.form-login {
    max-width: 460px;
    margin: 3rem auto;
}
.form-login .icono-cab {
    width: 84px; height: 84px; border-radius: 26px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 2.2rem; margin: 0 auto 1rem;
    box-shadow: 0 20px 36px -18px var(--primary);
    animation: latido 2.4s ease-in-out infinite;
}
.avatar-inicial {
    width: 44px; height: 44px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff; display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700;
}
.pill-estado { font-size: .72rem; font-weight: 700; padding: .25rem .65rem; border-radius: 50px; }
.pill-aprobado { background: rgba(40,167,69,.15); color: #28a745; }
.pill-pendiente { background: rgba(245,179,1,.18); color: #b8860b; }
.pill-rechazado { background: rgba(220,53,69,.15); color: #dc3545; }

.hover-lift { transition: transform .28s ease, box-shadow .28s ease; }
.hover-lift:hover { transform: translateY(-4px); box-shadow: 0 22px 40px -22px rgba(18,24,48,.5); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(214,46,88,.4); border-radius: 20px; }
::-webkit-scrollbar-track { background: transparent; }

.text-primary-jiliu { color: var(--primary) !important; }
.bg-primary-jiliu { background: var(--primary) !important; }
