/* ==============================================
   Mi Biblioteca — Dark Literary Theme
   "Biblioteca Oscura" — candlelit reading room
   ============================================== */

:root {
    /* Core palette */
    --bg: #0B0F1A;
    --bg-card: #111827;
    --bg-card-hover: #162035;
    --bg-input: #0F1724;

    /* Accent colors */
    --gold: #E8B563;
    --gold-dark: #C99440;
    --gold-light: #F7D89A;
    --teal: #5DB8A8;
    --teal-light: #7ED8C8;

    /* Text */
    --text: #EDE8E0;
    --text-muted: #7A8BA0;
    --text-dim: #2D4060;

    /* Borders */
    --border: #1A2840;
    --border-light: #243550;

    /* Shadows */
    --shadow-gold: rgba(232, 181, 99, 0.18);
    --shadow-card: rgba(0, 0, 0, 0.4);

    /* Status */
    --overdue: #F87171;
    --overdue-bg: rgba(248, 113, 113, 0.1);
    --due-soon: #FBBF24;
    --due-soon-bg: rgba(251, 191, 36, 0.1);

    /* Radii */
    --radius: 14px;
    --radius-sm: 8px;
    --radius-lg: 20px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    /* Subtle dot grid for depth */
    background-image: radial-gradient(circle, rgba(232, 181, 99, 0.055) 1px, transparent 1px);
    background-size: 28px 28px;
}

.container {
    max-width: 920px;
    margin: 0 auto;
    padding: 2.5rem 1.25rem;
}

/* ==============================================
   Header
   ============================================== */

header {
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
}

/* Ambient glow behind header */
header::before {
    content: '';
    position: absolute;
    top: -2rem;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    height: 220px;
    background: radial-gradient(ellipse at center, rgba(232, 181, 99, 0.09) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* Gold rule under header */
header::after {
    content: '';
    display: block;
    width: 80px;
    height: 1.5px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    margin: 1.25rem auto 0;
}

.header-deco {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    position: relative;
    z-index: 1;
}

.deco-book {
    font-size: 1.75rem;
    animation: float 3.5s ease-in-out infinite;
    filter: drop-shadow(0 0 10px rgba(232, 181, 99, 0.55));
}

.deco-book:nth-child(1) { animation-delay: 0s; }
.deco-book:nth-child(2) { animation-delay: 0.65s; }
.deco-book:nth-child(3) { animation-delay: 1.3s; }

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50%       { transform: translateY(-9px) rotate(2deg); }
}

header h1 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 3.4rem;
    font-weight: 900;
    color: var(--gold);
    text-shadow: 0 0 50px rgba(232, 181, 99, 0.28);
    letter-spacing: -0.02em;
    margin-bottom: 0.4rem;
    line-height: 1.1;
    position: relative;
    z-index: 1;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    position: relative;
    z-index: 1;
}

/* ==============================================
   User tabs
   ============================================== */

.user-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    justify-content: center;
}

.user-tab {
    padding: 0.55rem 1.5rem;
    font-size: 0.88rem;
    font-family: inherit;
    font-weight: 700;
    border: 1.5px solid var(--border-light);
    border-radius: 20px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.25s ease;
    letter-spacing: 0.03em;
}

.user-tab:hover {
    border-color: var(--gold);
    color: var(--gold);
    background: rgba(232, 181, 99, 0.07);
}

.user-tab.active {
    background: rgba(232, 181, 99, 0.12);
    color: var(--gold);
    border-color: var(--gold);
    box-shadow: 0 0 16px rgba(232, 181, 99, 0.2), inset 0 0 8px rgba(232, 181, 99, 0.05);
}

/* ==============================================
   Search
   ============================================== */

.search-section {
    margin-bottom: 1.25rem;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 1.1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    pointer-events: none;
    opacity: 0.45;
}

.search-box {
    width: 100%;
    padding: 0.9rem 1.25rem 0.9rem 3rem;
    font-size: 0.95rem;
    font-family: inherit;
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    transition: all 0.3s ease;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.search-box::placeholder {
    color: var(--text-dim);
}

.search-box:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(232, 181, 99, 0.12), 0 2px 12px rgba(0, 0, 0, 0.25);
}

/* ==============================================
   Sort & Filter
   ============================================== */

.sort-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.filter-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.sort-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.sort-btn,
.filter-toggle-btn {
    padding: 0.35rem 0.8rem;
    font-size: 0.78rem;
    font-family: inherit;
    font-weight: 600;
    border: 1.5px solid var(--border-light);
    border-radius: 20px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.02em;
}

.sort-btn:hover {
    border-color: var(--gold);
    color: var(--gold);
    background: rgba(232, 181, 99, 0.06);
    transform: translateY(-1px);
}

.sort-btn.active {
    background: rgba(232, 181, 99, 0.12);
    color: var(--gold);
    border-color: var(--gold);
    box-shadow: 0 0 12px rgba(232, 181, 99, 0.15);
}

.filter-toggle-btn:hover {
    border-color: var(--overdue);
    color: var(--overdue);
    background: rgba(248, 113, 113, 0.06);
    transform: translateY(-1px);
}

.filter-toggle-btn.active {
    background: rgba(248, 113, 113, 0.1);
    color: var(--overdue);
    border-color: var(--overdue);
    box-shadow: 0 0 12px rgba(248, 113, 113, 0.15);
}

.sort-arrow {
    font-size: 0.65rem;
    opacity: 0.8;
}

/* ==============================================
   Author filter indicator
   ============================================== */

.author-filter-indicator {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1.2rem;
    margin-bottom: 1rem;
    background: rgba(93, 184, 168, 0.07);
    border: 1.5px solid rgba(93, 184, 168, 0.45);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    color: var(--teal-light);
}

.author-filter-clear {
    padding: 0.25rem 0.75rem;
    font-size: 0.78rem;
    font-family: inherit;
    font-weight: 700;
    border: 1.5px solid rgba(93, 184, 168, 0.5);
    border-radius: 6px;
    background: rgba(93, 184, 168, 0.12);
    color: var(--teal-light);
    cursor: pointer;
    transition: all 0.2s ease;
}

.author-filter-clear:hover {
    background: rgba(93, 184, 168, 0.25);
}

/* ==============================================
   Stats bar
   ============================================== */

.stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.7rem 1.25rem;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
    border: 1.5px solid var(--border-light);
}

.stats-text {
    font-weight: 700;
    font-size: 0.86rem;
    color: var(--gold);
}

.last-update {
    color: var(--text-muted);
    font-size: 0.78rem;
}

/* ==============================================
   Book list & cards
   ============================================== */

.book-list {
    display: grid;
    gap: 0.875rem;
}

.book-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: 0 2px 16px var(--shadow-card);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
    border: 1.5px solid var(--border);
    border-left: 4px solid var(--gold);
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    animation: slideIn 0.4s ease-out both;
    position: relative;
    overflow: hidden;
}

/* Subtle glow line at top of card */
.book-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 4px;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, rgba(232, 181, 99, 0.35), transparent 60%);
    pointer-events: none;
}

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

.book-card:nth-child(1) { animation-delay: 0.04s; }
.book-card:nth-child(2) { animation-delay: 0.08s; }
.book-card:nth-child(3) { animation-delay: 0.12s; }
.book-card:nth-child(4) { animation-delay: 0.16s; }
.book-card:nth-child(5) { animation-delay: 0.20s; }
.book-card:nth-child(6) { animation-delay: 0.24s; }

.book-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55), 0 0 0 1px var(--border-light);
    background: var(--bg-card-hover);
}

.book-card.overdue {
    border-left-color: var(--overdue);
}

.book-card.overdue::before {
    background: linear-gradient(90deg, rgba(248, 113, 113, 0.35), transparent 60%);
}

.book-card.due-soon {
    border-left-color: var(--due-soon);
}

.book-card.due-soon::before {
    background: linear-gradient(90deg, rgba(251, 191, 36, 0.35), transparent 60%);
}

/* Book cover */
.book-cover {
    width: 78px;
    height: 108px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    box-shadow: 4px 4px 16px rgba(0, 0, 0, 0.55);
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.book-cover:hover {
    transform: scale(1.07) rotate(-1deg);
    box-shadow: 6px 6px 24px rgba(0, 0, 0, 0.65);
}

.book-info {
    flex: 1;
    min-width: 0;
}

/* Title row */
.book-title-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.book-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.08rem;
    font-weight: 700;
    color: var(--text);
    flex: 1;
    min-width: 0;
    line-height: 1.3;
}

.user-badge {
    font-size: 0.62rem;
    font-weight: 800;
    padding: 0.15rem 0.55rem;
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 0.2rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.user-badge-1 {
    background: rgba(232, 181, 99, 0.14);
    color: var(--gold);
    border: 1px solid rgba(232, 181, 99, 0.3);
}

.user-badge-2 {
    background: rgba(93, 184, 168, 0.14);
    color: var(--teal-light);
    border: 1px solid rgba(93, 184, 168, 0.3);
}

/* Author */
.book-author {
    font-size: 0.87rem;
    color: var(--teal);
    font-weight: 600;
    margin-bottom: 0.25rem;
    cursor: pointer;
}

.author-link {
    transition: color 0.2s ease;
    border-bottom: 1px dashed transparent;
}

.book-author:hover .author-link {
    color: var(--teal-light);
    border-bottom-color: var(--teal-light);
}

/* Collection badge */
.book-coleccion {
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    padding: 0.15rem 0.6rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    display: inline-block;
    letter-spacing: 0.02em;
}

/* Meta row */
.book-meta {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
}

.book-meta-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.due-date {
    font-weight: 700;
}

.due-date.overdue {
    color: var(--overdue);
}

.due-date.due-soon {
    color: var(--due-soon);
}

/* ==============================================
   Lightbox
   ============================================== */

.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.92);
    justify-content: center;
    align-items: center;
    cursor: pointer;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.lightbox.active {
    display: flex;
}

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

.lightbox-img {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: 10px;
    box-shadow: 0 0 0 1px rgba(232, 181, 99, 0.2), 0 20px 70px rgba(0, 0, 0, 0.8);
    cursor: default;
    animation: zoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes zoomIn {
    from { transform: scale(0.82); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.lightbox-close {
    position: absolute;
    top: 1.25rem;
    right: 1.5rem;
    background: rgba(232, 181, 99, 0.1);
    border: 1.5px solid rgba(232, 181, 99, 0.35);
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gold);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.85;
    transition: all 0.2s ease;
}

.lightbox-close:hover {
    opacity: 1;
    background: rgba(232, 181, 99, 0.2);
    transform: scale(1.1);
}

/* ==============================================
   Loading & empty states
   ============================================== */

.loading {
    text-align: center;
    padding: 4rem;
    color: var(--text-muted);
    font-weight: 600;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border-light);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.empty-state h3 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.error {
    background: rgba(248, 113, 113, 0.08);
    border: 1.5px solid rgba(248, 113, 113, 0.3);
    border-radius: var(--radius);
    padding: 1.5rem;
    color: var(--overdue);
    margin-bottom: 1rem;
}

/* ==============================================
   Footer
   ============================================== */

footer {
    text-align: center;
    margin-top: 3.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.85rem;
}

footer a {
    color: var(--gold);
    text-decoration: none;
    font-weight: 700;
    transition: color 0.2s ease, text-shadow 0.2s ease;
}

footer a:hover {
    color: var(--gold-light);
    text-shadow: 0 0 14px rgba(232, 181, 99, 0.4);
}

/* ==============================================
   Mobile
   ============================================== */

@media (max-width: 640px) {
    header h1 {
        font-size: 2.4rem;
    }

    .header-deco {
        gap: 0.5rem;
    }

    .deco-book {
        font-size: 1.5rem;
    }

    .container {
        padding: 1.25rem 1rem;
    }

    .book-card {
        padding: 1rem;
        gap: 0.875rem;
    }

    .book-cover {
        width: 62px;
        height: 88px;
    }

    .book-title {
        font-size: 1rem;
    }

    .stats-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .lightbox-img {
        max-width: 95vw;
        max-height: 80vh;
    }

    .lightbox-close {
        top: 0.75rem;
        right: 0.75rem;
        width: 2rem;
        height: 2rem;
        font-size: 1.1rem;
    }
}
