/*
Theme Name: مكتبة الروايات
Theme URI: http://localhost/wordpress
Author: مخصص
Author URI: http://localhost/wordpress
Description: قالب مخصص لموقع مكتبة الروايات العربية - مشابه لموقع maktbaa.com
Version: 1.0.0
License: GPL v2 or later
Text Domain: maktbaa
Domain Path: /languages
Tags: rtl-language-support, two-columns, right-sidebar, custom-colors, dark-mode
*/

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: auto; overflow-anchor: auto; font-family: 'Cairo', 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif; }
body { font-family: 'Cairo', 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif; overscroll-behavior-y: none; overflow-x: hidden; max-width: 100vw; direction: rtl; }

/* Fonts */
@font-face { font-family:'IBM Plex Sans Arabic'; font-style:normal; font-weight:400; font-display:swap; src:url('assets/fonts/ibm-plex-arabic-400.woff2') format('woff2'); }
@font-face { font-family:'IBM Plex Sans Arabic'; font-style:normal; font-weight:500; font-display:swap; src:url('assets/fonts/ibm-plex-arabic-500.woff2') format('woff2'); }
@font-face { font-family:'IBM Plex Sans Arabic'; font-style:normal; font-weight:600; font-display:swap; src:url('assets/fonts/ibm-plex-arabic-600.woff2') format('woff2'); }
@font-face { font-family:'IBM Plex Sans Arabic'; font-style:normal; font-weight:700; font-display:swap; src:url('assets/fonts/ibm-plex-arabic-700.woff2') format('woff2'); }

/* CSS Variables */
:root {
  --primary: #6366f1;
  --secondary: #8b5cf6;
  --accent: #10b981;
  --amber: #f59e0b;
  --amber-dark: #d97706;
  --bg: #f9fafb;
  --bg-card: #ffffff;
  --bg-input: #f3f4f6;
  --text: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --radius: 12px;
  --nav-bg: rgba(255,255,255,0.95);
}

.dark {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #1e293b;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #334155;
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
  --nav-bg: rgba(15,23,42,0.95);
}

body { background: var(--bg); color: var(--text); transition: background 0.3s, color 0.3s; }

/* Scrollbar */
.custom-scrollbar::-webkit-scrollbar { width: 8px; height: 8px; }
.custom-scrollbar::-webkit-scrollbar-track { background: rgba(0,0,0,0.05); border-radius: 10px; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: linear-gradient(180deg, #9333ea, #7e22ce); border-radius: 10px; }
.dark .custom-scrollbar::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); }
.dark .custom-scrollbar::-webkit-scrollbar-thumb { background: linear-gradient(180deg, #a855f7, #9333ea); }

/* Container */
.container { max-width: 1280px; margin: 0 auto; padding: 0 12px; }
@media (min-width: 480px) { .container { padding: 0 16px; } }
@media (min-width: 640px) { .container { padding: 0 20px; } }
@media (min-width: 1024px) { .container { padding: 0 24px; } }
@media (min-width: 1280px) { .container { padding: 0 32px; } }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border-width: 0; }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; height: auto; }

/* Navigation */
.nav { background: var(--nav-bg); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); position: sticky; top: 0; z-index: 50; border-bottom: 1px solid var(--border); transition: box-shadow 0.3s; }
.nav.scrolled { box-shadow: 0 4px 20px rgba(0,0,0,0.08); }
.nav-inner { display: flex; justify-content: space-between; align-items: center; height: 60px; gap: 12px; }
@media (min-width: 768px) { .nav-inner { height: 64px; } }
.nav-logo { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700; flex-shrink: 0; }
@media (min-width: 480px) { .nav-logo { font-size: 20px; } }
.nav-logo img { height: 36px; width: auto; }
@media (min-width: 480px) { .nav-logo img { height: 40px; } }
.nav-links { display: none; align-items: center; gap: 16px; }
@media (min-width: 768px) { .nav-links { display: flex; gap: 20px; } }
@media (min-width: 1024px) { .nav-links { gap: 24px; } }
.nav-link { font-weight: 500; font-size: 13px; transition: color 0.2s; white-space: nowrap; position: relative; }
@media (min-width: 1024px) { .nav-link { font-size: 14px; } }
.nav-link::after { content: ''; position: absolute; bottom: -4px; left: 0; width: 0; height: 2px; background: var(--amber); border-radius: 1px; transition: width 0.3s; }
.nav-link:hover::after, .nav-link.active::after { width: 100%; }
.nav-link:hover, .nav-link.active { color: var(--amber); }

/* Search */
.search-form { position: relative; flex: 1; max-width: 400px; margin: 0 12px; display: none; }
@media (min-width: 480px) { .search-form { display: block; margin: 0 16px; } }
@media (min-width: 768px) { .search-form { max-width: 480px; margin: 0 24px; } }
@media (min-width: 1024px) { .search-form { max-width: 560px; margin: 0 32px; } }
.search-input { width: 100%; padding: 9px 44px 9px 14px; background: var(--bg-input); border: 2px solid transparent; border-radius: 9999px; font-size: 13px; color: var(--text); outline: none; transition: border-color 0.2s, box-shadow 0.2s; direction: rtl; }
@media (min-width: 480px) { .search-input { padding: 10px 48px 10px 16px; font-size: 14px; } }
.search-input:focus { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(245,158,11,0.12); }
.search-input::placeholder { color: var(--text-muted); }
.search-btn { position: absolute; left: 3px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; background: var(--amber); border: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; color: #111; transition: all 0.2s; }
@media (min-width: 480px) { .search-btn { width: 36px; height: 36px; left: 4px; } }
.search-btn:hover { background: var(--amber-dark); box-shadow: 0 4px 12px rgba(245,158,11,0.4); transform: translateY(-50%) scale(1.05); }
.search-btn svg { width: 13px; height: 13px; }
@media (min-width: 480px) { .search-btn svg { width: 14px; height: 14px; } }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer; border: none; transition: all 0.2s; text-decoration: none; white-space: nowrap; -webkit-tap-highlight-color: transparent; }
@media (min-width: 480px) { .btn { padding: 8px 16px; font-size: 14px; } }
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--amber); color: #111; }
.btn-primary:hover { background: var(--amber-dark); box-shadow: 0 4px 16px rgba(245,158,11,0.3); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--amber); color: var(--amber); background: rgba(245,158,11,0.05); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
@media (min-width: 480px) { .btn-sm { padding: 4px 12px; } }

/* Theme Toggle */
.theme-toggle { padding: 10px; border-radius: 10px; background: var(--bg-input); border: none; cursor: pointer; color: var(--text); display: flex; align-items: center; justify-content: center; transition: all 0.2s; flex-shrink: 0; }
.theme-toggle:hover { background: var(--border); transform: scale(1.05); }
.theme-toggle:active { transform: scale(0.95); }
.theme-toggle svg { width: 18px; height: 18px; }
@media (min-width: 480px) { .theme-toggle svg { width: 20px; height: 20px; } }
.theme-toggle .sun { display: none; }
.dark .theme-toggle .moon { display: none; }
.dark .theme-toggle .sun { display: inline; }

/* Mobile menu */
.mobile-menu-btn { display: flex; padding: 10px; border: none; background: var(--bg-input); border-radius: 8px; cursor: pointer; color: var(--text); transition: background 0.2s; flex-shrink: 0; }
.mobile-menu-btn:hover { background: var(--border); }
@media (min-width: 768px) { .mobile-menu-btn { display: none; } }
.mobile-menu { display: none; border-top: 1px solid var(--border); padding: 12px 0; background: var(--nav-bg); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); animation: slideDown 0.25s ease; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.mobile-menu.open { display: block; }
.mobile-menu .container { display: flex; flex-direction: column; gap: 2px; }
.mobile-menu a { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-radius: 10px; font-weight: 500; font-size: 15px; transition: background 0.2s, color 0.2s; }
.mobile-menu a:hover { background: var(--bg-input); color: var(--amber); }
.mobile-menu a.active { background: var(--amber); color: #111; font-weight: 700; }
.mobile-menu form { margin-bottom: 8px; }

/* Hero Section */
.hero { background: var(--bg-card); padding: 40px 0 48px; }
@media (min-width: 768px) { .hero { padding: 64px 0; } }
.hero-content { text-align: center; max-width: 768px; margin: 0 auto; }
.hero-title { font-size: 28px; font-weight: 700; margin-bottom: 8px; }
@media (min-width: 768px) { .hero-title { font-size: 48px; } }
.hero-title .highlight { color: var(--amber); }
.hero-subtitle { color: var(--text-secondary); margin-bottom: 32px; font-size: 14px; }
.hero-search { max-width: 560px; margin: 0 auto; }
.hero-search input { padding: 16px 56px 16px 20px; font-size: 16px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 12px; }

/* Cards */
.card { background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; transition: transform 0.25s, box-shadow 0.25s; }
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
.card:active { transform: scale(0.98); }
.card-img { aspect-ratio: 3/4; overflow: hidden; position: relative; background: var(--border); }
.card-img img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.35s; }
.card:hover .card-img img { transform: scale(1.05); }
.card-info { padding: 10px 12px; }
@media (min-width: 480px) { .card-info { padding: 12px 14px; } }
.card-title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 480px) { .card-title { font-size: 14px; } }
.card-author { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
@media (min-width: 480px) { .card-author { font-size: 12px; } }

/* Grid */
.novel-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 480px) { .novel-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; } }
@media (min-width: 640px) { .novel-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; } }
@media (min-width: 768px) { .novel-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; } }
@media (min-width: 1024px) { .novel-grid { grid-template-columns: repeat(5, 1fr); } }
@media (min-width: 1280px) { .novel-grid { grid-template-columns: repeat(6, 1fr); } }

/* Section */
.section { padding: 24px 0; }
@media (min-width: 480px) { .section { padding: 28px 0; } }
@media (min-width: 768px) { .section { padding: 36px 0; } }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
@media (min-width: 480px) { .section-header { margin-bottom: 18px; } }
@media (min-width: 768px) { .section-header { margin-bottom: 24px; } }
.section-title { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
@media (min-width: 480px) { .section-title { font-size: 22px; } }
@media (min-width: 768px) { .section-title { font-size: 24px; } }
.section-link { font-size: 13px; color: var(--amber); font-weight: 600; text-decoration: none; white-space: nowrap; transition: opacity 0.2s; }
@media (min-width: 480px) { .section-link { font-size: 14px; } }
.section-link:hover { opacity: 0.8; }

/* Category Pills */
.cat-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.cat-pill { padding: 8px 20px; background: var(--bg-input); border-radius: 9999px; font-size: 14px; font-weight: 500; transition: all 0.2s; }
.cat-pill:hover { background: var(--amber); color: #111; }

/* Footer */
.footer { background: var(--bg-card); border-top: 1px solid var(--border); padding: 32px 0 24px; margin-top: 32px; }
@media (min-width: 768px) { .footer { padding: 48px 0; margin-top: 56px; } }
.footer-grid { display: grid; grid-template-columns: 1fr; gap: 24px; }
@media (min-width: 480px) { .footer-grid { grid-template-columns: 1fr 1fr; gap: 24px; } }
@media (min-width: 768px) { .footer-grid { grid-template-columns: 1fr 1fr 1fr; gap: 32px; } }
@media (min-width: 1024px) { .footer-grid { grid-template-columns: 1fr 1fr 1.3fr; gap: 40px; } }
.footer h3 { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
@media (min-width: 768px) { .footer h3 { font-size: 16px; margin-bottom: 12px; } }
.footer p, .footer a { font-size: 13px; color: var(--text-secondary); display: block; margin-bottom: 6px; line-height: 1.6; }
@media (min-width: 768px) { .footer p, .footer a { font-size: 14px; margin-bottom: 8px; } }
.footer a:hover { color: var(--amber); }
.footer-bottom { border-top: 1px solid var(--border); margin-top: 24px; padding-top: 14px; text-align: center; font-size: 12px; color: var(--text-muted); }
@media (min-width: 768px) { .footer-bottom { margin-top: 32px; padding-top: 16px; font-size: 13px; } }
.footer-legal-links { display: flex; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; }
.footer-legal-links a { color: var(--text-muted); transition: color 0.2s; }
.footer-legal-links a:hover { color: var(--amber); }
.footer-legal-links span { color: var(--border); opacity: 0.6; }
@media (min-width: 480px) { .footer-legal-links { gap: 10px; } }

/* Pagination */
.pagination { display: flex; justify-content: center; gap: 4px; margin-top: 28px; flex-wrap: wrap; }
@media (min-width: 480px) { .pagination { margin-top: 32px; gap: 6px; } }
.pagination a, .pagination span { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 36px; padding: 6px 10px; border-radius: 8px; font-size: 13px; background: var(--bg-card); border: 1px solid var(--border); text-decoration: none; color: var(--text); transition: all 0.2s; }
@media (min-width: 480px) { .pagination a, .pagination span { min-width: 40px; height: 40px; padding: 8px 14px; font-size: 14px; } }
.pagination a:hover { border-color: var(--amber); color: var(--amber); }
.pagination .current { background: var(--amber); color: #111; border-color: var(--amber); font-weight: 700; }

/* Admin bar offset */
body.admin-bar .nav { top: 32px; }

/* Chat glow animation */
@keyframes glow-pulse {
    0%, 100% { filter: drop-shadow(0 0 3px rgba(245,158,11,0.4)); }
    50% { filter: drop-shadow(0 0 10px rgba(245,158,11,0.8)) drop-shadow(0 0 20px rgba(245,158,11,0.4)); }
}

/* Creative extras */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.skeleton {
    background: linear-gradient(90deg, var(--bg-input) 25%, var(--border) 50%, var(--bg-input) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

/* Responsive images */
img { max-width: 100%; height: auto; display: block; }

/* Smooth page transitions */
main { animation: fadeInUp 0.4s ease; min-height: 60vh; }

/* Touch improvements */
@media (hover: none) and (pointer: coarse) {
    .btn, button, a { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; }
    input, select, textarea { font-size: 16px !important; }
}

/* Print styles */
@media print {
    .nav, .footer, .theme-toggle, .mobile-menu-btn { display: none !important; }
    body { background: #fff !important; color: #000 !important; }
}