/* Books page — matches programs / site styling */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #E87511;
    --secondary: #F4A524;
    --dark: #C25E0A;
    --white: #ffffff;
    --light-bg: #FFF9F3;
    --text-dark: #1a1a2e;
    --text-muted: #5a5a6e;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-dark);
    background: var(--white);
    line-height: 1.6;
    overflow-x: hidden;
}

h1, h2, h3, h4 {
    font-family: 'Poppins', sans-serif;
    line-height: 1.3;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Nav */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--white);
    box-shadow: var(--shadow-sm);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
}

.nav-logo {
    font-family: 'Poppins', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-links li a {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-dark);
    transition: var(--transition);
}

.nav-links li a:hover,
.nav-links li a.active {
    color: var(--primary);
    background: var(--light-bg);
}

.btn-login {
    background: var(--primary) !important;
    color: var(--white) !important;
}

.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text-dark);
    transition: var(--transition);
}

/* Hero */
.hero {
    position: relative;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--white);
    padding: 80px 24px 72px;
    text-align: center;
    overflow: hidden;
}

.hero-pattern {
    position: absolute;
    inset: 0;
    opacity: 0.08;
    background-image: radial-gradient(circle at 20% 50%, white 1px, transparent 1px),
        radial-gradient(circle at 80% 20%, white 1px, transparent 1px);
    background-size: 40px 40px;
}

.hero-content {
    position: relative;
    max-width: 720px;
    margin: 0 auto;
}

.hero-title {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    margin-bottom: 16px;
}

.hero-subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
    line-height: 1.7;
}

/* Books section */
.books-section {
    padding: 64px 0 80px;
    background: var(--light-bg);
}

.filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 24px;
}

.filter-btn {
    padding: 10px 22px;
    border: 2px solid transparent;
    border-radius: 999px;
    background: var(--white);
    color: var(--text-dark);
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.filter-btn:hover,
.filter-btn.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.books-search-wrap {
    max-width: 480px;
    margin: 0 auto 32px;
}

.books-search {
    width: 100%;
    padding: 14px 18px;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    font-size: 1rem;
    background: var(--white);
    transition: var(--transition);
}

.books-search:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(232, 117, 17, 0.15);
}

.books-status {
    text-align: center;
    color: var(--text-muted);
    padding: 32px 16px;
}

.books-table-wrap {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.books-table {
    width: 100%;
    border-collapse: collapse;
}

.books-table th,
.books-table td {
    padding: 16px 18px;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
}

.books-table th {
    background: #fff7ed;
    font-family: 'Poppins', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--dark);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.books-table tbody tr:hover {
    background: #fffbf5;
}

.books-table tbody tr:last-child td {
    border-bottom: none;
}

.books-index {
    font-weight: 700;
    color: var(--primary);
    font-family: 'Poppins', sans-serif;
}

.books-title-cell {
    font-weight: 600;
    color: var(--text-dark);
}

.books-author-cell {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.books-type-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.books-type-badge.ebooks {
    background: #fef3c7;
    color: #92400e;
}

.books-type-badge.articles {
    background: #dbeafe;
    color: #1e40af;
}

.btn-open-pdf {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: var(--white);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-open-pdf:hover {
    background: var(--dark);
}

.btn-open-pdf:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Mobile cards (shown on small screens) */
.books-grid {
    display: none;
    grid-template-columns: 1fr;
    gap: 16px;
}

.book-card {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.book-card-index {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--light-bg);
    color: var(--primary);
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.book-card-title {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    margin-bottom: 4px;
}

.book-card-meta {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* Login dialog */
.books-login-dialog {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.books-login-dialog[hidden] {
    display: none;
}

.books-login-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
}

.books-login-panel {
    position: relative;
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 36px 32px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-md);
}

.books-login-close {
    position: absolute;
    top: 12px;
    right: 14px;
    border: none;
    background: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}

.books-login-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.books-login-panel h2 {
    font-size: 1.4rem;
    margin-bottom: 10px;
}

.books-login-panel p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.books-login-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn {
    display: inline-block;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-align: center;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--dark);
}

.btn-secondary {
    background: #f1f5f9;
    color: var(--text-dark);
}

.btn-secondary:hover {
    background: #e2e8f0;
}

/* PDF viewer (minimal from dashboard) */
.pdf-viewer-overlay {
    position: fixed;
    inset: 0;
    background: #0f172a;
    z-index: 10000;
    display: none;
    flex-direction: column;
}

.pdf-viewer-overlay.active {
    display: flex;
}

.pdf-viewer-shell {
    width: 100%;
    height: 100%;
    background: #0f172a;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pdf-viewer-header,
.pdf-viewer-footer {
    flex-shrink: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.pdf-viewer-overlay.pdf-viewer-chrome-hidden .pdf-viewer-header {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}

.pdf-viewer-overlay.pdf-viewer-chrome-hidden .pdf-viewer-footer {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
}

.pdf-viewer-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #1e293b;
    color: #f8fafc;
}

.pdf-viewer-back,
.pdf-viewer-close {
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #f8fafc;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9rem;
}

.pdf-viewer-title-wrap h2 {
    font-size: 1rem;
    color: #f8fafc;
}

.pdf-viewer-title-wrap p {
    font-size: 0.8rem;
    color: #94a3b8;
}

.pdf-viewer-canvas-wrap {
    flex: 1;
    overflow: auto;
    background: #334155;
}

.pdf-viewer-pages {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 16px;
}

.pdf-viewer-page-canvas,
.pdf-viewer-canvas-wrap canvas {
    max-width: 100%;
    height: auto;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.pdf-viewer-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 10px;
    background: #1e293b;
    color: #f8fafc;
}

.pdf-viewer-loading,
.pdf-viewer-error {
    color: #cbd5e1;
    text-align: center;
    padding: 48px 24px;
}

.pdf-viewer-spinner {
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: pdf-spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

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

/* Footer */
.footer {
    background: var(--text-dark);
    color: #cbd5e1;
    padding: 56px 0 0;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 32px;
    padding-bottom: 40px;
}

.footer-logo {
    color: var(--white);
    font-family: 'Poppins', sans-serif;
    margin-bottom: 12px;
}

.footer-col h4 {
    color: var(--white);
    margin-bottom: 16px;
    font-size: 1rem;
}

.footer-col ul li {
    margin-bottom: 8px;
}

.footer-col a:hover {
    color: var(--secondary);
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 20px 0;
    text-align: center;
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 900px) {
    .hamburger {
        display: flex;
    }

    .nav-links {
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        background: var(--white);
        flex-direction: column;
        padding: 16px;
        box-shadow: var(--shadow-md);
        transform: translateY(-120%);
        opacity: 0;
        pointer-events: none;
        transition: var(--transition);
    }

    .nav-links.open {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .books-table-wrap {
        display: none !important;
    }

    .books-grid {
        display: grid !important;
    }

    .books-table th:nth-child(3),
    .books-table td:nth-child(3) {
        display: none;
    }
}

@media (min-width: 901px) {
    .books-grid {
        display: none !important;
    }
}
