/* ============================================
   كتبي - مكتبة حميز نت الرقمية
   ============================================ */

:root {
    --primary: #00a651;
    --primary-dark: #006837;
    --primary-light: #22c55e;
    --primary-gradient: linear-gradient(135deg, #00a651, #22c55e);
    --secondary: #3399ff;
    --secondary-dark: #0066cc;
    --accent: #ffd700;
    --accent-dark: #ccab00;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #0ea5e9;
    --background: #000000;
    --background-secondary: #111111;
    --background-tertiary: #1a1a1a;
    --background-card: #1e1e1e;
    --background-elevated: #2a2a2a;
    --text: #ffffff;
    --text-muted: #cccccc;
    --text-light: #e5e5e5;
    --text-secondary: #b3b3b3;
    --border: #333333;
    --border-light: #404040;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.5);
    --shadow-primary: 0 8px 25px rgba(0, 166, 81, 0.3);
    --header-height: 70px;
    --border-radius: 12px;
    --border-radius-lg: 16px;
    --border-radius-xl: 24px;
    --transition: 0.3s ease;
    --glass-bg: rgba(26, 26, 26, 0.9);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-backdrop: blur(20px);
}

/* الوضع النهاري */
body.light-mode {
    --background: #f5f7fa;
    --background-secondary: #ffffff;
    --background-tertiary: #eef1f5;
    --background-card: #ffffff;
    --background-elevated: #f0f2f5;
    --text: #1a1a2e;
    --text-muted: #555555;
    --text-light: #333333;
    --text-secondary: #666666;
    --border: #e0e0e0;
    --border-light: #d0d0d0;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.15);
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(0, 0, 0, 0.08);
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 20%, rgba(0, 166, 81, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(51, 153, 255, 0.06) 0%, transparent 50%);
    z-index: -1;
    pointer-events: none;
}

body.light-mode::before {
    background:
        radial-gradient(circle at 20% 20%, rgba(0, 166, 81, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(51, 153, 255, 0.03) 0%, transparent 50%);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

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

/* ===============================
   الهيدر
   =============================== */
.main-header {
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: var(--glass-backdrop);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 998;
    height: var(--header-height);
    border-bottom: 1px solid rgba(0, 166, 81, 0.2);
    transition: all var(--transition);
}

body.light-mode .main-header {
    background: rgba(255, 255, 255, 0.97);
    border-bottom-color: var(--border);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    max-width: 1200px;
    margin: 0 auto;
    height: 100%;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary);
    font-size: 1.5rem;
    font-weight: 800;
    text-decoration: none;
}

.logo i { color: var(--accent); }

.nav-links {
    display: flex;
    gap: 1.5rem;
    list-style: none;
}

.nav-link {
    color: var(--text);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    transition: all var(--transition);
}

.nav-link:hover, .nav-link.active {
    color: var(--primary);
    background: rgba(0, 166, 81, 0.1);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.search-toggle-btn,
.theme-toggle-btn,
.font-size-btn {
    background: none;
    border: 2px solid var(--border-light);
    color: var(--text);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
}

.search-toggle-btn:hover,
.theme-toggle-btn:hover,
.font-size-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(0, 166, 81, 0.1);
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    flex-direction: column;
    gap: 4px;
    width: 40px;
    height: 40px;
    justify-content: center;
    align-items: center;
}

.hamburger-line {
    display: block;
    width: 24px;
    height: 3px;
    background: var(--primary);
    border-radius: 2px;
    transition: all var(--transition);
}

/* ===============================
   البحث Overlay
   =============================== */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    z-index: 1001;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
}

.search-overlay.active { display: flex; }

.search-overlay-content {
    width: 90%;
    max-width: 600px;
}

.search-overlay-box {
    position: relative;
    margin-bottom: 1rem;
}

.search-overlay-box input {
    width: 100%;
    padding: 1.25rem 3.5rem 1.25rem 1.5rem;
    border: 2px solid var(--border-light);
    border-radius: var(--border-radius-lg);
    background: var(--background-card);
    color: var(--text);
    font-size: 1.2rem;
    font-family: inherit;
    transition: all var(--transition);
}

.search-overlay-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(0, 166, 81, 0.2);
}

.search-close-btn {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color var(--transition);
}

.search-close-btn:hover { color: var(--danger); }

.search-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.filter-btn {
    padding: 0.5rem 1rem;
    background: var(--background-elevated);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    transition: all var(--transition);
}

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

.search-results {
    max-height: 50vh;
    overflow-y: auto;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--background-card);
    border-radius: var(--border-radius);
    margin-bottom: 0.75rem;
    border: 1px solid var(--border);
    transition: all var(--transition);
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
}

.search-result-item:hover {
    border-color: var(--primary);
    transform: translateX(-5px);
}

.search-result-cover {
    width: 50px;
    height: 65px;
    object-fit: cover;
    border-radius: 6px;
    background: var(--background-elevated);
}

.search-result-info h4 { font-size: 0.95rem; margin-bottom: 0.25rem; }
.search-result-info p { font-size: 0.8rem; color: var(--text-muted); margin: 0; }

/* ===============================
   القائمة المحمولة
   =============================== */
.mobile-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: 999;
    visibility: hidden;
    opacity: 0;
    transition: all 0.3s ease;
}

.mobile-menu.show { visibility: visible; opacity: 1; }

.mobile-menu-backdrop {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.mobile-menu-content {
    position: absolute;
    top: 0; right: 0;
    width: 300px;
    max-width: 85vw;
    height: 100%;
    background: var(--background-secondary);
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.mobile-menu.show .mobile-menu-content { transform: translateX(0); }

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.mobile-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary);
    font-size: 1.2rem;
    font-weight: 700;
}

.mobile-logo i { color: var(--accent); }

.mobile-menu-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-nav { flex: 1; padding: 1rem 0; }

.mobile-nav-link {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    transition: all var(--transition);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    gap: 1rem;
}

.mobile-nav-link:hover { background: rgba(0, 166, 81, 0.1); color: var(--primary); }
.mobile-nav-link i:first-child { color: var(--primary); width: 20px; text-align: center; }
.mobile-nav-link span { flex: 1; }

.mobile-menu-footer {
    padding: 1.5rem;
    text-align: center;
    border-top: 1px solid var(--border);
}

.mobile-menu-footer p { color: var(--text-muted); font-size: 0.85rem; margin: 0; }

/* ===============================
   المحتوى الرئيسي
   =============================== */
.main-content { padding-top: var(--header-height); }

/* ===============================
   Hero Section
   =============================== */
.hero-section {
    padding: 5rem 0 3rem;
    text-align: center;
    background: linear-gradient(180deg, rgba(0, 166, 81, 0.05) 0%, transparent 100%);
}

.hero-title {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 800;
    background: linear-gradient(45deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto 2rem;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
}

.stat-item { text-align: center; }

.stat-item .stat-number {
    display: block;
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
}

.stat-item .stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ===============================
   Reading Progress Bar
   =============================== */
.reading-progress-bar {
    padding: 1rem 0;
}

.progress-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.progress-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.progress-info i { color: var(--accent); }
.progress-page { color: var(--primary); font-weight: 600; }

.progress-btn {
    background: var(--primary-gradient);
    color: white;
    padding: 0.5rem 1.25rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all var(--transition);
}

.progress-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-primary); color: white; }

/* ===============================
   التصنيفات
   =============================== */
.categories-section { padding: 1.5rem 0; }

.categories-scroll {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding: 0.5rem 0;
    scrollbar-width: none;
}

.categories-scroll::-webkit-scrollbar { display: none; }

.category-chip {
    padding: 0.6rem 1.25rem;
    background: var(--background-elevated);
    border: 1px solid var(--border-light);
    border-radius: 25px;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    white-space: nowrap;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.category-chip:hover { border-color: var(--primary); color: var(--primary); }
.category-chip.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ===============================
   قسم الكتب
   =============================== */
.books-section { padding: 2rem 0 4rem; }

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

.section-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
}

.books-view-toggle {
    display: flex;
    gap: 0.5rem;
}

.view-btn {
    background: var(--background-elevated);
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

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

.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
}

.books-grid.list-view {
    grid-template-columns: 1fr;
}

.books-grid.list-view .book-card {
    flex-direction: row;
    align-items: center;
}

.books-grid.list-view .book-card-cover {
    width: 80px;
    height: 110px;
    min-height: auto;
}

/* كارد الكتاب */
.book-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--text);
    position: relative;
}

.book-card:hover {
    transform: translateY(-8px);
    border-color: rgba(0, 166, 81, 0.3);
    box-shadow: var(--shadow-primary);
}

.book-card-cover {
    width: 100%;
    min-height: 200px;
    background: linear-gradient(135deg, var(--background-elevated), var(--background-tertiary));
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.book-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-card-cover .no-cover {
    font-size: 3rem;
    color: var(--primary);
    opacity: 0.5;
}

.book-card-badge {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    font-size: 0.7rem;
    font-weight: 700;
    z-index: 2;
}

.badge-free { background: var(--success); color: white; }
.badge-paid { background: var(--accent); color: #000; }
.badge-freemium { background: var(--info); color: white; }

.book-card-info {
    padding: 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.book-card-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-card-author {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.book-card-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.book-card-meta span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.loading-spinner {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
    grid-column: 1 / -1;
}

.loading-spinner i { font-size: 2rem; margin-bottom: 1rem; display: block; color: var(--primary); }

.no-books {
    text-align: center;
    padding: 4rem;
    color: var(--text-muted);
}

.no-books i { font-size: 3rem; margin-bottom: 1rem; display: block; opacity: 0.5; }

/* ===============================
   قسم الاشتراك
   =============================== */
.subscription-section { padding: 3rem 0; }

.subscription-card {
    background: linear-gradient(135deg, rgba(0, 166, 81, 0.1), rgba(255, 215, 0, 0.1));
    border: 1px solid rgba(0, 166, 81, 0.3);
    border-radius: var(--border-radius-xl);
    padding: 3rem;
    text-align: center;
}

.subscription-content h2 {
    font-size: 1.75rem;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.subscription-content p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.subscription-price {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.25rem;
}

.price-amount {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(45deg, var(--accent), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.price-currency { font-size: 1.25rem; color: var(--accent); font-weight: 700; }
.price-period { color: var(--text-muted); }

.subscription-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--primary-gradient);
    color: white;
    padding: 1rem 2.5rem;
    border-radius: 30px;
    font-weight: 700;
    font-size: 1.1rem;
    transition: all var(--transition);
}

.subscription-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-primary);
    color: white;
}

/* ===============================
   الفوتر
   =============================== */
.main-footer {
    background: var(--background-secondary);
    padding: 3rem 0 1.5rem;
    border-top: 1px solid var(--border);
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary);
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
}

.footer-logo i { color: var(--accent); }

.footer-description { color: var(--text-muted); font-size: 0.9rem; line-height: 1.6; }

.footer-title { color: var(--primary); font-size: 1rem; font-weight: 700; margin-bottom: 1rem; }

.footer-links { list-style: none; }
.footer-links li { margin-bottom: 0.5rem; }
.footer-links a { color: var(--text-muted); font-size: 0.9rem; display: flex; align-items: center; gap: 0.5rem; }
.footer-links a:hover { color: var(--primary); }

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

/* ===============================
   Toast
   =============================== */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    background: var(--success);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-xl);
    z-index: 2000;
    transform: translateX(-120%);
    transition: transform 0.3s ease;
    max-width: 350px;
}

.toast.show { transform: translateX(0); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
.toast.info { background: var(--info); }

.toast-content { display: flex; align-items: center; gap: 0.75rem; }

/* ===============================
   Responsive
   =============================== */
@media (max-width: 768px) {
    .nav-links { display: none; }
    .mobile-menu-toggle { display: flex; }
    .header-content { padding: 0 1rem; }
    .hero-stats { gap: 1.5rem; }
    .hero-title { font-size: 1.75rem; }
    .books-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
    .book-card-cover { min-height: 150px; }
    .subscription-card { padding: 2rem 1.5rem; }
    .footer-content { grid-template-columns: 1fr; }
    .toast { left: 1rem; right: 1rem; max-width: none; }
}

@media (max-width: 480px) {
    .books-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
    .book-card-info { padding: 0.75rem; }
    .book-card-title { font-size: 0.85rem; }
    .hero-section { padding: 3rem 0 2rem; }
}
