/* ===== CSS VARIABLES - Dark Terminal Theme ===== */
:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #141824;
    --bg-card: #1a2035;
    --bg-elevated: #1e2540;
    --primary: #4f8ef7;
    --primary-hover: #3a7aed;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --text-primary: #ffffff;
    --text-secondary: #ffffff;
    --text-muted: #ffffff;
    --border: #1e2535;
    --border-hover: #2e3a55;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
}

/* ===== RESET & BASE ===== */
html { font-size: 14px; }
@media (min-width: 768px) { html { font-size: 16px; } }

* { box-sizing: border-box; }

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Segoe UI', 'Arial Hebrew', 'David', Arial, system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    margin: 0;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ===== NAVBAR ===== */
.navbar {
    background: rgba(20, 24, 36, 0.95) !important;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-brand {
    color: var(--primary) !important;
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: 0.5px;
}

.navbar-brand:hover { color: var(--primary-hover) !important; }

.nav-link {
    color: var(--text-secondary) !important;
    padding: 0.5rem 0.75rem !important;
    border-radius: var(--radius-sm);
    transition: color 0.2s, background 0.2s;
    font-size: 0.9rem;
}

.nav-link:hover, .nav-link.active {
    color: var(--text-primary) !important;
    background: rgba(79, 142, 247, 0.1);
}

.nav-admin { color: var(--warning) !important; }
.nav-user-info { color: var(--primary) !important; font-size: 0.85rem; cursor: default; }
.nav-logout { color: var(--text-muted) !important; }
.nav-logout:hover { color: var(--danger) !important; background: rgba(239, 68, 68, 0.1) !important; }

.btn-nav-register {
    color: var(--primary) !important;
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm) !important;
    margin-inline-start: 0.5rem;
}
.btn-nav-register:hover { background: var(--primary) !important; color: white !important; }

.navbar-toggler { border-color: var(--border); }
.navbar-toggler-icon { filter: invert(0.8); }

/* ===== BUTTONS ===== */
.btn { border-radius: var(--radius-sm); font-weight: 500; transition: all 0.2s; }

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

.btn-success { background: var(--success); border-color: var(--success); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #1a1a1a; }

.btn-outline-secondary {
    border-color: var(--border-hover);
    color: var(--text-secondary);
}
.btn-outline-secondary:hover {
    background: var(--bg-elevated);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

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

.btn:focus { box-shadow: 0 0 0 0.2rem rgba(79, 142, 247, 0.35); }

/* ===== FORM CONTROLS ===== */
.form-control, .form-select {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
}
.form-control:focus, .form-select:focus {
    background: var(--bg-secondary);
    border-color: var(--primary);
    color: var(--text-primary);
    box-shadow: 0 0 0 0.2rem rgba(79, 142, 247, 0.25);
}
.text-muted { color: #ffffff !important; }
.form-control::placeholder { color: rgba(255, 255, 255, 0.4); }

.input-group-text {
    background: var(--bg-elevated);
    border-color: var(--border);
    color: var(--text-secondary);
}

.form-label { color: var(--text-secondary); font-size: 0.875rem; margin-bottom: 0.3rem; }

/* ===== MAIN CONTENT ===== */
.main-content { min-height: calc(100vh - 120px); }

/* ===== FOOTER ===== */
.site-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ===== TOASTS ===== */
.site-toast {
    position: fixed;
    top: 80px;
    inset-inline-start: 20px;
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    animation: slideInToast 0.3s ease;
    max-width: 350px;
    font-size: 0.9rem;
    border: 1px solid;
}
.site-toast-success { background: rgba(34, 197, 94, 0.15); border-color: var(--success); color: var(--success); }
.site-toast-error { background: rgba(239, 68, 68, 0.15); border-color: var(--danger); color: var(--danger); }

.toast-fade-out { animation: slideOutToast 0.4s ease forwards; }

@keyframes slideInToast {
    from { transform: translateX(-120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOutToast {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(-120%); opacity: 0; }
}

/* ===== HERO SECTION ===== */
.hero-section {
    padding: 5rem 0 4rem;
    background: radial-gradient(ellipse at 50% 0%, rgba(79, 142, 247, 0.12) 0%, transparent 70%);
    text-align: center;
}

.hero-badge {
    display: inline-block;
    background: rgba(79, 142, 247, 0.15);
    border: 1px solid rgba(79, 142, 247, 0.3);
    color: var(--primary);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 2px;
}

.hero-title {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1.15;
    margin: 1.5rem 0 1rem;
    color: var(--text-primary);
}
@media (max-width: 768px) { .hero-title { font-size: 2rem; } }

.hero-highlight {
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 2rem;
    line-height: 1.7;
}

/* ===== STATS SECTION ===== */
.stats-section { padding: 3rem 0; }

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1rem;
    transition: border-color 0.2s, transform 0.2s;
}
.stat-card:hover { border-color: var(--primary); transform: translateY(-2px); }

.stat-icon { font-size: 1.5rem; color: var(--primary); margin-bottom: 0.5rem; }
.stat-number { font-size: 2rem; font-weight: 800; color: var(--text-primary); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

/* ===== BOOK CARDS ===== */
.featured-section, .categories-section { padding: 3rem 0; }

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-title { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); margin: 0; }
.section-link { color: var(--text-secondary); font-size: 0.9rem; }
.section-link:hover { color: var(--primary); }

.book-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.book-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.book-card-owned { border-color: rgba(79, 142, 247, 0.3); }

.book-cover {
    background: linear-gradient(135deg, rgba(79, 142, 247, 0.1), rgba(124, 58, 237, 0.1));
    border: 1px solid rgba(79, 142, 247, 0.2);
    border-radius: var(--radius-md);
    padding: 2rem;
    text-align: center;
    margin-bottom: 1rem;
    font-size: 2.5rem;
    color: var(--primary);
}

.book-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.book-category-badge {
    background: rgba(79, 142, 247, 0.15);
    color: var(--primary);
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.book-rating { color: var(--warning); font-size: 0.8rem; }
.book-rating .far { color: var(--text-muted); }

.book-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
    line-height: 1.4;
}

.book-author { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 0.75rem; }

.book-description {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.6;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.book-pages-info { color: var(--text-muted); font-size: 0.8rem; margin-bottom: 0.75rem; }
.book-pages-info i { color: var(--primary); }

.book-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.book-price {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary);
}

.book-purchase { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border); }
.book-price-display { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }

.coupon-hint { font-size: 0.75rem; color: var(--success); }

/* ===== CATEGORY CARDS ===== */
.category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1rem;
    color: var(--text-secondary);
    text-align: center;
    transition: all 0.2s;
    text-decoration: none;
}
.category-card:hover {
    border-color: var(--primary);
    background: rgba(79, 142, 247, 0.08);
    color: var(--primary);
    transform: translateY(-2px);
}
.category-card i { font-size: 1.75rem; }
.category-card span { font-size: 0.85rem; font-weight: 500; }
.category-card-all { border-color: rgba(79, 142, 247, 0.3); color: var(--primary); }

/* ===== STORE PAGE ===== */
.store-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 2rem 0 1.5rem;
}

.page-title { font-size: 1.75rem; font-weight: 700; margin-bottom: 1rem; }
.page-header { margin-bottom: 1.5rem; }

.store-search { margin-bottom: 1.25rem; }
.store-search .form-control { background: var(--bg-card); }

.filter-tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filter-tab {
    padding: 0.4rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.85rem;
    transition: all 0.2s;
    background: var(--bg-card);
    text-decoration: none;
}
.filter-tab:hover { border-color: var(--primary); color: var(--primary); }
.filter-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* ===== MODAL ===== */
.modal-dark { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.modal-dark .modal-header { border-bottom-color: var(--border); }
.modal-dark .modal-title { color: var(--text-primary); }

.purchase-book-summary {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.purchase-book-icon {
    background: rgba(79, 142, 247, 0.1);
    border-radius: var(--radius-md);
    padding: 1rem;
    color: var(--primary);
}

/* ===== AUTH PAGES ===== */
.auth-container {
    min-height: calc(100vh - 180px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
    position: relative;
}

.auth-close {
    position: absolute;
    top: 1rem;
    left: 1rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
    line-height: 1;
    text-decoration: none;
    opacity: 0.6;
    transition: opacity 0.2s;
}
.auth-close:hover { opacity: 1; color: var(--text-primary); }

.auth-header { text-align: center; margin-bottom: 2rem; }
.auth-icon { font-size: 2.5rem; color: var(--primary); margin-bottom: 0.75rem; display: block; }
.auth-header h2 { font-weight: 700; margin-bottom: 0.25rem; }
.auth-footer { margin-top: 1.5rem; text-align: center; padding-top: 1.5rem; border-top: 1px solid var(--border); }

/* ===== LIBRARY / READER ===== */
.reader-container { background: var(--bg-primary); min-height: 100vh; }

.reader-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.pdf-viewer-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

.pdf-nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
}

.page-info { color: var(--text-secondary); font-size: 0.9rem; }

.pdf-canvas-wrapper {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
}

#pdfCanvas { max-width: 100%; box-shadow: var(--shadow-md); direction: ltr; }

/* ===== ADMIN ===== */
.admin-tabs { border-bottom-color: var(--border); }
.admin-tabs .nav-link {
    color: var(--text-secondary) !important;
    border: 1px solid transparent;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    background: none;
    padding: 0.6rem 1.2rem;
}
.admin-tabs .nav-link.active {
    background: var(--bg-card) !important;
    border-color: var(--border) var(--border) var(--bg-card) !important;
    color: var(--primary) !important;
}
.admin-tabs .nav-link:hover:not(.active) { background: rgba(79, 142, 247, 0.08) !important; }

.admin-section { animation: fadeIn 0.2s ease; }

.admin-form .form-control, .admin-form .form-select { background: var(--bg-card); }

.section-subtitle { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); }

.admin-table { color: var(--text-primary); }
.admin-table th { color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; border-color: var(--border); font-weight: 500; }
.admin-table td { border-color: var(--border); vertical-align: middle; }
.admin-table tbody tr:hover { background: rgba(79, 142, 247, 0.05); }

.user-list { display: flex; flex-direction: column; gap: 0.75rem; }

.user-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.user-item:hover { border-color: var(--border-hover); }
.user-item-info { flex: 1; min-width: 0; }
.user-item-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

/* ===== EMPTY STATE ===== */
.empty-state { color: var(--text-muted); }
.empty-state h3 { color: var(--text-secondary); margin-bottom: 0.5rem; }

/* ===== ALERTS ===== */
.alert-danger { background: rgba(239, 68, 68, 0.1); border-color: var(--danger); color: #fca5a5; }

/* ===== TABLE RESPONSIVE ===== */
.table-responsive { border-radius: var(--radius-md); overflow: hidden; }

/* ===== BADGES ===== */
.badge { font-weight: 500; }
code { color: var(--primary); background: rgba(79, 142, 247, 0.1); padding: 0.15rem 0.4rem; border-radius: 4px; }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
