/* ============================================================
   Ганҷи маърифат — Premium RTL UI
   ============================================================ */

:root {
    --color-primary: #1a5f4a;
    --color-primary-dark: #0f3d30;
    --color-primary-light: #2d8a6e;
    --color-secondary: #c9a227;
    --color-secondary-light: #e8c547;
    --color-accent: #8b4513;
    --color-bg: #faf8f3;
    --color-bg-alt: #f0ebe0;
    --color-surface: #ffffff;
    --color-text: #2c2416;
    --color-text-muted: #6b5d4d;
    --color-border: #e0d5c4;
    --color-success: #2d7a4f;
    --color-error: #c0392b;
    --shadow-sm: 0 2px 8px rgba(44, 36, 22, 0.06);
    --shadow-md: 0 8px 24px rgba(44, 36, 22, 0.1);
    --shadow-lg: 0 16px 48px rgba(44, 36, 22, 0.12);
    --radius: 12px;
    --radius-lg: 20px;
    --font-main: 'Noto Naskh Arabic', 'Scheherazade New', serif;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-main);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.8;
    font-size: 17px;
    min-height: 100vh;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(201, 162, 39, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 90% 80%, rgba(26, 95, 74, 0.05) 0%, transparent 50%);
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 1.25rem; }

/* --- Navbar --- */
.navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--color-primary);
    font-weight: 700;
    font-size: 1.35rem;
}

.logo-icon { font-size: 1.6rem; }

.nav-menu {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-menu a {
    text-decoration: none;
    color: var(--color-text);
    font-weight: 500;
    transition: color var(--transition);
}

.nav-menu a:hover { color: var(--color-primary); }

.nav-highlight {
    color: var(--color-secondary) !important;
    font-weight: 600 !important;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.nav-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--color-text);
    transition: var(--transition);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.4rem;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    color: #fff;
    box-shadow: 0 4px 14px rgba(26, 95, 74, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(26, 95, 74, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--color-secondary), var(--color-secondary-light));
    color: var(--color-text);
}

.btn-outline {
    background: transparent;
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.btn-outline:hover { background: var(--color-primary); color: #fff; }

.btn-lg { padding: 0.85rem 2rem; font-size: 1.05rem; }
.btn-sm { padding: 0.4rem 1rem; font-size: 0.9rem; }
.btn-block { width: 100%; }

/* --- Hero --- */
.hero {
    position: relative;
    padding: 5rem 0 4rem;
    overflow: hidden;
}

.hero-pattern {
    position: absolute;
    inset: 0;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 0L60 30L30 60L0 30Z' fill='%231a5f4a'/%3E%3C/svg%3E");
    background-size: 40px 40px;
}

.hero-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: center;
    position: relative;
}

.hero-badge {
    display: inline-block;
    background: rgba(201, 162, 39, 0.15);
    color: var(--color-accent);
    padding: 0.35rem 1rem;
    border-radius: 50px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.hero-title {
    font-size: clamp(2.2rem, 5vw, 3.5rem);
    font-weight: 700;
    color: var(--color-primary-dark);
    line-height: 1.3;
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-size: 1.2rem;
    color: var(--color-text-muted);
    margin-bottom: 2rem;
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 1rem; }

.hero-book-stack {
    position: relative;
    height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stack-book {
    position: absolute;
    font-size: 5rem;
    filter: drop-shadow(var(--shadow-md));
    animation: float 4s ease-in-out infinite;
}

.stack-book-1 { transform: rotate(-8deg) translateX(30px); animation-delay: 0s; }
.stack-book-2 { transform: rotate(3deg); z-index: 2; animation-delay: 0.5s; }
.stack-book-3 { transform: rotate(10deg) translateX(-30px); animation-delay: 1s; }

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(var(--r, 0deg)); }
    50% { transform: translateY(-12px) rotate(var(--r, 0deg)); }
}

/* --- Sections --- */
.section { padding: 4rem 0; }
.section-alt { background: var(--color-bg-alt); }

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.section-header h2 {
    font-size: 1.8rem;
    color: var(--color-primary-dark);
}

.link-more { color: var(--color-primary); text-decoration: none; font-weight: 600; }

/* --- Book Cards --- */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.book-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
    border: 1px solid var(--color-border);
}

.book-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
}

.book-card-link { text-decoration: none; color: inherit; display: block; }

.book-cover-wrap {
    position: relative;
    aspect-ratio: 3/4;
    overflow: hidden;
    background: linear-gradient(145deg, var(--color-bg-alt), var(--color-border));
}

.book-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.book-card:hover .book-cover { transform: scale(1.05); }

.book-cover-overlay {
    position: absolute;
    inset: 0;
    background: rgba(26, 95, 74, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition);
}

.book-card:hover .book-cover-overlay { opacity: 1; }

.book-open-icon { font-size: 2.5rem; animation: bookOpen 0.5s ease; }

@keyframes bookOpen {
    from { transform: scale(0.5) rotateY(90deg); opacity: 0; }
    to { transform: scale(1) rotateY(0); opacity: 1; }
}

.badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-new { background: var(--color-secondary); color: var(--color-text); }

.book-card-body { padding: 1rem; }

.book-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-author { font-size: 0.85rem; color: var(--color-text-muted); }

.book-tag {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.15rem 0.6rem;
    background: rgba(26, 95, 74, 0.1);
    color: var(--color-primary);
    border-radius: 50px;
    font-size: 0.75rem;
}

/* --- Book of Day --- */
.book-of-day-card {
    background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary));
    color: #fff;
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.book-of-day-label { font-size: 0.95rem; opacity: 0.9; margin-bottom: 1rem; }

.book-of-day-inner {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 2rem;
    align-items: center;
}

.book-of-day-cover {
    width: 160px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

.book-of-day-card .btn-primary {
    background: var(--color-secondary);
    color: var(--color-text);
    margin-top: 1rem;
}

/* --- Competitions --- */
.comp-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.comp-card {
    background: var(--color-surface);
    border: 2px solid var(--color-secondary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-decoration: none;
    color: inherit;
    transition: all var(--transition);
    position: relative;
}

.comp-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--color-primary);
}

.comp-status {
    display: inline-block;
    padding: 0.2rem 0.8rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.comp-status-active { background: #d4edda; color: #155724; }
.comp-status-planned { background: #fff3cd; color: #856404; }
.comp-status-finished { background: #e2e3e5; color: #383d41; }

.comp-list-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1.5rem;
    align-items: center;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem 2rem;
    margin-bottom: 1rem;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--color-border);
    transition: all var(--transition);
}

.comp-list-item:hover { border-color: var(--color-secondary); box-shadow: var(--shadow-md); }

/* --- Competition Detail --- */
.comp-detail-header {
    background: linear-gradient(135deg, #1a3a5f, var(--color-primary-dark));
    color: #fff;
    padding: 3rem 0;
    text-align: center;
}

.comp-detail-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 2rem;
    align-items: start;
}

.comp-block { margin-bottom: 1.5rem; }
.comp-block h2 { color: var(--color-primary); margin-bottom: 1rem; font-size: 1.3rem; }

.comp-sidebar-card {
    position: sticky;
    top: 90px;
    margin-bottom: 1rem;
}

.comp-sidebar-highlight {
    background: linear-gradient(145deg, rgba(201, 162, 39, 0.1), rgba(201, 162, 39, 0.05));
    border: 1px solid var(--color-secondary);
}

.tips-list { list-style: none; padding: 0; }
.tips-list li { padding: 0.5rem 0; border-bottom: 1px solid var(--color-border); }
.tips-list li::before { content: '✓ '; color: var(--color-primary); }

.comp-resource-link {
    display: block;
    padding: 0.75rem;
    background: var(--color-bg);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    text-decoration: none;
    color: var(--color-primary);
    font-weight: 500;
}

/* --- AI --- */
.ai-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 2rem;
    align-items: start;
}

.ai-form { padding: 1.5rem; }

.ai-message { padding: 1.5rem; margin-bottom: 1.5rem; border-right: 4px solid var(--color-primary); }

.ai-source { font-size: 0.8rem; color: var(--color-text-muted); margin-bottom: 0.5rem; }

.ai-placeholder { padding: 3rem; text-align: center; }
.ai-icon { font-size: 3rem; margin-bottom: 1rem; }

.ai-header { background: linear-gradient(135deg, #2c1654, var(--color-primary-dark)); color: #fff; }

/* --- Forms --- */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
}

.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; margin-bottom: 0.4rem; font-weight: 600; font-size: 0.95rem; }

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1rem;
    background: var(--color-bg);
    transition: border-color var(--transition);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

.filter-form { margin-bottom: 2rem; }
.filter-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.filter-row .form-input, .filter-row .form-select { flex: 1; min-width: 140px; }

/* --- Book Detail --- */
.book-detail-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 3rem;
}

.book-detail-cover img {
    width: 100%;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.book-author-lg { font-size: 1.2rem; color: var(--color-text-muted); margin-bottom: 1rem; }

.book-meta-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.5rem; }

.tag {
    padding: 0.3rem 0.9rem;
    background: var(--color-bg-alt);
    border-radius: 50px;
    font-size: 0.85rem;
}

.book-actions { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 2rem; }

/* --- Progress --- */
.progress-bar-wrap { margin: 1.5rem 0; }
.progress-bar {
    height: 8px;
    background: var(--color-border);
    border-radius: 50px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-bar div {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    border-radius: 50px;
    transition: width 0.5s ease;
}

/* --- Reader Path --- */
.reader-path-hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    color: #fff;
}

.path-user-info { display: flex; align-items: center; gap: 1rem; }

.path-avatar {
    width: 60px;
    height: 60px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
}

.path-level-badge {
    background: var(--color-secondary);
    color: var(--color-text);
    padding: 0.2rem 0.8rem;
    border-radius: 50px;
    font-size: 0.85rem;
}

.points-number { font-size: 2.5rem; font-weight: 700; display: block; text-align: center; }

.levels-track {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.level-step {
    text-align: center;
    padding: 1.5rem;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 2px solid var(--color-border);
    opacity: 0.6;
    transition: all var(--transition);
}

.level-step.active, .level-step.completed { opacity: 1; border-color: var(--color-secondary); }
.level-step.active { background: rgba(201, 162, 39, 0.1); }

.level-icon { font-size: 2rem; margin-bottom: 0.5rem; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    text-align: center;
    padding: 1.5rem;
}

.stat-num { display: block; font-size: 2rem; font-weight: 700; color: var(--color-primary); }

.progress-item {
    display: grid;
    grid-template-columns: 60px 1fr auto;
    gap: 1rem;
    align-items: center;
    padding: 1rem;
    margin-bottom: 0.75rem;
    text-decoration: none;
    color: inherit;
}

.progress-item img { width: 60px; height: 80px; object-fit: cover; border-radius: 8px; }

/* --- Auth --- */
.auth-section { min-height: 60vh; display: flex; align-items: center; }
.auth-container { max-width: 440px; margin: 0 auto; }
.auth-card { padding: 2.5rem; }
.auth-card h1 { text-align: center; margin-bottom: 1.5rem; color: var(--color-primary); }
.auth-link { text-align: center; margin-top: 1rem; font-size: 0.95rem; }
.auth-link a { color: var(--color-primary); }

/* --- Page Header --- */
.page-header {
    background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary));
    color: #fff;
    padding: 3rem 0;
    text-align: center;
}

.page-header h1 { font-size: 2.2rem; margin-bottom: 0.5rem; }

/* --- Alerts --- */
.alert {
    padding: 1rem 1.5rem;
    margin: 1rem auto;
    max-width: 1200px;
    border-radius: var(--radius);
    font-weight: 500;
}

.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* --- Footer --- */
.footer {
    background: var(--color-primary-dark);
    color: rgba(255,255,255,0.85);
    margin-top: 4rem;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 2rem;
    padding: 3rem 0;
}

.footer a { color: rgba(255,255,255,0.7); text-decoration: none; display: block; margin-bottom: 0.5rem; }
.footer a:hover { color: var(--color-secondary); }
.footer h3, .footer h4 { color: #fff; margin-bottom: 1rem; }

.footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 1rem 0;
    text-align: center;
    font-size: 0.9rem;
}

/* --- Pagination --- */
.pagination { display: flex; gap: 0.5rem; justify-content: center; margin-top: 2rem; }

.page-link {
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.page-link.active, .page-link:hover {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.empty-state { text-align: center; padding: 4rem; color: var(--color-text-muted); }
.empty-icon { font-size: 3rem; display: block; margin-bottom: 1rem; }

.error-section { text-align: center; padding: 6rem 0; }
.error-code { font-size: 6rem; font-weight: 700; color: var(--color-primary); opacity: 0.3; }

/* --- Animations --- */
[data-animate] {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

[data-animate].visible { opacity: 1; transform: translateY(0); }

.text-muted { color: var(--color-text-muted); }

/* --- Responsive --- */
@media (max-width: 992px) {
    .hero-content { grid-template-columns: 1fr; text-align: center; }
    .hero-actions { justify-content: center; }
    .hero-visual { display: none; }
    .book-detail-grid { grid-template-columns: 1fr; }
    .comp-detail-layout { grid-template-columns: 1fr; }
    .ai-layout { grid-template-columns: 1fr; }
    .book-of-day-inner { grid-template-columns: 1fr; text-align: center; }
    .book-of-day-cover { margin: 0 auto; }
    .footer-grid { grid-template-columns: 1fr; }
    .levels-track { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .nav-toggle { display: flex; }
    .nav-menu {
        position: fixed;
        top: 70px;
        right: 0;
        left: 0;
        background: var(--color-surface);
        flex-direction: column;
        padding: 1.5rem;
        gap: 1rem;
        transform: translateY(-120%);
        transition: transform var(--transition);
        border-bottom: 1px solid var(--color-border);
    }
    .nav-menu.open { transform: translateY(0); }
    .filter-row { flex-direction: column; }
    .comp-list-item { grid-template-columns: 1fr; }
}
