/* DjangoLearn - تم الهام‌گرفته از مستندات جنگو (روشن، RTL، ریسپانسیو) */

/* فونت استعداد (Estedad) — همان فونت پنل مدیریت، به صورت استاتیک در static/fonts */
@font-face {
    font-family: 'Estedad';
    src: url("../fonts/Estedad-Thin.98565c7a79a8.woff2") format('woff2');
    font-weight: 100;
    font-display: swap;
}

@font-face {
    font-family: 'Estedad';
    src: url("../fonts/Estedad-ExtraLight.059050236e12.woff2") format('woff2');
    font-weight: 200;
    font-display: swap;
}

@font-face {
    font-family: 'Estedad';
    src: url("../fonts/Estedad-Light.461dce3e2564.woff2") format('woff2');
    font-weight: 300;
    font-display: swap;
}

@font-face {
    font-family: 'Estedad';
    src: url("../fonts/Estedad-Regular.459bc71dc27e.woff2") format('woff2');
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: 'Estedad';
    src: url("../fonts/Estedad-Medium.a39d89490b90.woff2") format('woff2');
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: 'Estedad';
    src: url("../fonts/Estedad-SemiBold.e93494cd0918.woff2") format('woff2');
    font-weight: 600;
    font-display: swap;
}

@font-face {
    font-family: 'Estedad';
    src: url("../fonts/Estedad-Bold.5d83b5481692.woff2") format('woff2');
    font-weight: 700;
    font-display: swap;
}

@font-face {
    font-family: 'Estedad';
    src: url("../fonts/Estedad-ExtraBold.5eee214b5cd7.woff2") format('woff2');
    font-weight: 800;
    font-display: swap;
}

@font-face {
    font-family: 'Estedad';
    src: url("../fonts/Estedad-Black.abe68be05d18.woff2") format('woff2');
    font-weight: 900;
    font-display: swap;
}

:root {
    --header-bg: #0c4b33;
    --header-bg-dark: #092e20;
    --accent: #44b78b;
    --accent-dark: #2c8b68;
    --text: #232323;
    --muted: #6b7280;
    --border: #e3e3e3;
    --sidebar-bg: #f8f8f8;
    --page-bg: #ffffff;
    --card-bg: #ffffff;
    --hover-bg: #e9f5ef;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0, 0, 0, .08);
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--page-bg);
    color: var(--text);
    font-family: "Estedad", "Segoe UI", Tahoma, "Iranian Sans", system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.85;
    transition: background-color .2s ease, color .2s ease;
}

a {
    color: var(--accent-dark);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1, h2, h3, h4 {
    line-height: 1.5;
    margin: 0 0 .6em;
}

h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }

p { margin: 0 0 1em; }

img { max-width: 100%; }

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}

/* ---------- Header ---------- */

.site-header {
    background: var(--header-bg);
    color: #fff;
    box-shadow: var(--shadow);
}

.site-header .inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.brand {
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    white-space: nowrap;
}

.brand:hover { text-decoration: none; }

.brand .dot { color: var(--accent); }

.menu-toggle {
    display: none;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .4);
    color: #fff;
    border-radius: var(--radius);
    font-size: 18px;
    padding: 4px 10px;
    cursor: pointer;
}

.search-form {
    flex: 1 1 220px;
    display: flex;
    gap: 8px;
    max-width: 460px;
}

.search-form input {
    flex: 1;
    min-width: 0;
    border: none;
    border-radius: var(--radius);
    padding: 8px 12px;
    font-family: inherit;
    font-size: 14px;
}

.search-form button {
    border: none;
    background: var(--accent);
    color: #fff;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-inline-start: auto;
}

.nav-links a {
    color: rgba(255, 255, 255, .92);
    font-size: 14px;
}

.nav-links a:hover { color: #fff; text-decoration: none; }

/* ---------- Layout ---------- */

.layout {
    width: 100%;
    flex: 1 0 auto;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px;
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.sidebar {
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    position: sticky;
    top: 16px;
}

.sidebar h2 {
    font-size: .95rem;
    color: var(--muted);
    margin: 0 0 8px;
}

.sidebar-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar-list li { margin-bottom: 2px; }

.sidebar-list a {
    display: block;
    padding: 5px 8px;
    border-radius: 4px;
    color: var(--text);
    font-size: 14px;
}

.sidebar-list a:hover,
.sidebar-list a.active {
    background: var(--hover-bg);
    color: var(--header-bg);
    text-decoration: none;
}

.sidebar-link-row { margin-top: 12px; }

/* ---------- Content ---------- */

.content { min-width: 0; }

.page-title {
    border-bottom: 2px solid var(--border);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }

/* ---------- Error pages ---------- */

.error-layout {
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    justify-items: center;
    padding-block: 48px;
}

.error-card {
    width: 100%;
    max-width: 720px;
    padding: clamp(24px, 5vw, 56px);
    border: 1px solid var(--border);
    border-top: 4px solid var(--accent);
    border-radius: var(--radius);
    background: var(--card-bg);
    box-shadow: var(--shadow);
    text-align: center;
}

.error-code {
    color: var(--accent-dark);
    font-size: clamp(5rem, 16vw, 9rem);
    font-weight: 800;
    line-height: 1;
    letter-spacing: .04em;
}

.error-label {
    color: var(--muted);
    font-size: .85rem;
    margin: 12px 0 24px;
}

.error-description {
    max-width: 500px;
    margin: 0 auto 26px;
    color: var(--muted);
}

.error-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
}

.error-actions a:focus-visible,
.error-help a:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 4px;
}

.error-help {
    margin: 26px 0 0;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: .85rem;
}

.error-help a {
    display: block;
    margin-top: 6px;
}

/* ---------- صفحات محتوایی (درباره/قوانین/حریم خصوصی/سوالات متداول) ---------- */

.prose {
    max-width: 720px;
    line-height: 1.9;
}

.prose h2 { font-size: 1.1rem; margin: 22px 0 8px; }
.prose h3 { font-size: 1rem; margin: 18px 0 6px; }
.prose p { margin: 0 0 12px; }
.prose ul, .prose ol { padding-inline-start: 22px; margin: 0 0 12px; }
.prose li { margin-bottom: 6px; }

.faq-list { max-width: 760px; }
.faq-answer { padding: 10px 14px; font-size: .92rem; line-height: 1.9; }

/* ---------- پست وبلاگ ---------- */

.post { max-width: 760px; }

.post-cover {
    display: block;
    width: 100%;
    border-radius: var(--radius);
    margin-bottom: 18px;
}

.post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    color: var(--muted);
    font-size: .85rem;
    margin-bottom: 16px;
}

.breadcrumb {
    font-size: .85rem;
    color: var(--muted);
    margin-bottom: 12px;
}

/* ---------- فهرست کارتی و برچسب‌ها ---------- */

.card-list {
    display: grid;
    gap: 14px;
    max-width: 760px;
}

.card-item {
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
}

.card-item h3 { margin: 0 0 8px; font-size: 1.05rem; }
.card-item h3 a { text-decoration: none; }
.card-item .post-meta { margin-bottom: 0; }

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 22px;
}

.tag-chip {
    display: inline-block;
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--card-bg);
    color: var(--muted);
    font-size: .8rem;
    text-decoration: none;
}

.tag-chip:hover {
    border-color: var(--accent);
    color: var(--accent-dark);
}

/* ---------- Alerts ---------- */

.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    border: 1px solid transparent;
    font-size: 14px;
}

.alert.success { background: #e9f5ef; border-color: #bde3cf; color: #0c4b33; }
.alert.info { background: #e8f1fb; border-color: #c3d9f0; color: #1c4e80; }
.alert.warning { background: #fdf6e3; border-color: #f0e0b0; color: #8a6d1a; }
.alert.error, .alert.danger { background: #fdecea; border-color: #f5c6c0; color: #a1281f; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-block;
    padding: 9px 18px;
    border-radius: var(--radius);
    background: var(--header-bg);
    color: #fff;
    border: 1px solid var(--header-bg);
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.6;
}

.btn:hover { background: var(--header-bg-dark); text-decoration: none; color: #fff; }

.btn-accent { background: var(--accent); border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-outline {
    background: transparent;
    color: var(--header-bg);
}

.btn-outline:hover { background: var(--hover-bg); color: var(--header-bg); }

.btn-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}

.btn-ghost:hover { background: var(--sidebar-bg); color: var(--text); }

.btn-danger { background: #a1281f; border-color: #a1281f; }
.btn-danger:hover { background: #842018; border-color: #842018; }

.btn-block { display: block; width: 100%; text-align: center; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-sm { padding: 5px 12px; font-size: .82rem; }

/* ---------- Cards / grids ---------- */

.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 18px;
}

.course-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow .15s ease;
}

.course-card:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, .1); }

.course-card .cover {
    display: block;
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, #0c4b33, #44b78b);
    position: relative;
}

.course-card .cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.course-card .cover .placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, .85);
    font-size: 2rem;
    font-weight: 700;
}

.course-card .cover .discount-badge {
    position: absolute;
    top: 8px;
    inset-inline-start: 8px;
    z-index: 1;
    background: #e53935;
    color: #fff;
    font-size: .75rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}

.course-card .body { padding: 12px 14px; display: flex; flex-direction: column; flex: 1; }

.course-card h3 { font-size: 1rem; margin: 0 0 6px; }

.course-card h3 a { color: var(--text); }

.course-card .meta {
    color: var(--muted);
    font-size: .8rem;
    margin-bottom: 8px;
}

.course-card .footer {
    margin-top: auto;
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    gap: 8px;
    padding-top: 8px;
}

.price { font-weight: 700; color: var(--header-bg); }
.price.free { color: var(--accent-dark); }
.price-old { color: var(--muted); text-decoration: line-through; font-size: .85rem; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: .72rem;
    background: #eef2f1;
    color: var(--muted);
}

.badge-free { background: #e9f5ef; color: var(--accent-dark); }
.badge-paid { background: #fdf3e3; color: #8a6d1a; }

/* ---------- Forms ---------- */

.form-row { margin-bottom: 14px; }

.form-row label {
    display: block;
    margin-bottom: 6px;
    font-size: .88rem;
}

input[type="text"],
input[type="search"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    background: var(--card-bg);
    color: var(--text);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(68, 183, 139, .18);
}

.field-error { color: #a1281f; font-size: .82rem; margin-top: 4px; }
.help-text { color: var(--muted); font-size: .8rem; margin-top: 4px; }

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: .9rem;
}

.checkbox-row input[type="radio"],
.checkbox-row input[type="checkbox"] { width: auto; }

/* ---------- Auth pages ---------- */

.auth-wrap {
    max-width: 420px;
    margin: 40px auto;
    padding: 0 16px;
}

.auth-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 26px;
    box-shadow: var(--shadow);
    background: var(--card-bg);
}

.auth-card h1 { font-size: 1.25rem; margin-bottom: 4px; }

/* ---------- Course detail ---------- */

.course-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 24px;
    margin-bottom: 26px;
}

.course-hero .cover {
    border-radius: var(--radius);
    overflow: hidden;
    background: linear-gradient(135deg, #0c4b33, #44b78b);
    min-height: 200px;
}

.course-hero .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

.buy-box {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    background: var(--sidebar-bg);
    align-self: start;
    position: sticky;
    top: 16px;
}

.buy-box .amount { font-size: 1.5rem; font-weight: 700; color: var(--header-bg); }

.spec-list {
    list-style: none;
    padding: 0;
    margin: 14px 0;
    font-size: .88rem;
}

.spec-list li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px dashed var(--border);
}

.spec-list li:last-child { border-bottom: none; }
.spec-list .k { color: var(--muted); }

.curriculum { margin-top: 10px; }

.section-block {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    overflow: hidden;
}

.section-block > summary {
    cursor: pointer;
    padding: 10px 14px;
    background: var(--sidebar-bg);
    font-weight: 600;
    font-size: .95rem;
    list-style: none;
}

.section-block > summary::-webkit-details-marker { display: none; }

.section-block > summary::before {
    content: "+";
    display: inline-block;
    width: 20px;
    color: var(--accent-dark);
    font-weight: 700;
}

.section-block[open] > summary::before { content: "−"; }

.lesson-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 14px;
    border-top: 1px solid var(--border);
    font-size: .9rem;
}

.lesson-desc {
    padding: 2px 14px 10px;
    color: var(--muted);
    font-size: .86rem;
    line-height: 1.9;
}

.file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 14px 7px 28px;
    border-top: 1px dashed var(--border);
    font-size: .85rem;
    background: var(--sidebar-bg);
}

.file-row .name { color: var(--muted); }

.video-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.video-item .frame {
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
}

.video-item iframe,
.video-item video {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

.video-item .caption { font-size: .85rem; margin-top: 6px; color: var(--muted); }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

.table th, .table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: right;
    vertical-align: middle;
}

.table th { background: var(--sidebar-bg); font-weight: 600; }

.status {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: .76rem;
    white-space: nowrap;
}

.status-pending_payment { background: #fdf6e3; color: #8a6d1a; }
.status-failed { background: #fdecea; color: #a1281f; }
.status-processing { background: #e8f1fb; color: #1c4e80; }
.status-paid { background: #e9f5ef; color: #0c4b33; }
.status-canceled { background: #eef2f1; color: var(--muted); }
.status-refunded { background: #f0eefb; color: #4c3f9e; }

/* ---------- Pagination ---------- */

.pagination {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 26px 0 6px;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .85rem;
    color: var(--text);
}

.pagination .current { background: var(--header-bg); color: #fff; border-color: var(--header-bg); }

/* ---------- Footer ---------- */

.site-footer {
    margin-top: 40px;
    padding: 22px 16px;
    background: var(--header-bg);
    color: #cfe6dc;
    font-size: .85rem;
    text-align: center;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px 24px;
}

.footer-main { flex: 1 1 auto; }

.footer-enamad { flex: 0 0 auto; }

.footer-enamad img {
    display: block;
    width: 90px;
    max-width: 100%;
    height: auto;
}

.footer-links {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 16px;
}

.footer-links a { color: #cfe6dc; }
.footer-links a:hover { color: #fff; }

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
    .course-hero { grid-template-columns: 1fr; }
    .buy-box { position: static; }
}

@media (max-width: 720px) {
    .video-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .menu-toggle { display: inline-flex; }

    .nav-links {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        margin-inline-start: 0;
        padding: 8px 0 4px;
        border-top: 1px solid rgba(255, 255, 255, .2);
    }

    body.nav-open .nav-links { display: flex; }

    .search-form { order: 5; flex-basis: 100%; max-width: none; }

    .layout { grid-template-columns: 1fr; gap: 18px; }

    .sidebar { position: static; }
}

@media (max-width: 520px) {
    body { font-size: 14px; }
    h1 { font-size: 1.4rem; }
    .course-grid { grid-template-columns: 1fr; }
    .layout { padding: 16px 12px; }

    .site-footer { flex-direction: column; }
}

/* ---------- Theme toggle ---------- */

.theme-toggle {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .4);
    color: #fff;
    border-radius: var(--radius);
    font-size: 15px;
    line-height: 1;
    padding: 6px 9px;
    cursor: pointer;
}

.theme-toggle:hover { background: rgba(255, 255, 255, .12); }

.theme-toggle .icon-sun { display: none; }

html[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- تم شب ---------- */

html[data-theme="dark"] {
    --text: #e4e8e6;
    --muted: #9aa8a2;
    --border: #2b3532;
    --sidebar-bg: #161d1b;
    --page-bg: #0f1413;
    --accent-dark: #4fc79a;
    --card-bg: #17201d;
    --hover-bg: #1e2a26;
    --shadow: 0 2px 10px rgba(0, 0, 0, .45);
    color-scheme: dark;
}

html[data-theme="dark"] .alert.success { background: #12291f; border-color: #1e4a35; color: #7fd3ab; }
html[data-theme="dark"] .alert.info { background: #12222f; border-color: #1e3d55; color: #86bff0; }
html[data-theme="dark"] .alert.warning { background: #2a2413; border-color: #4d4222; color: #e2c264; }
html[data-theme="dark"] .alert.error,
html[data-theme="dark"] .alert.danger { background: #2b1614; border-color: #552723; color: #f0918a; }

html[data-theme="dark"] .badge { background: var(--sidebar-bg); }
html[data-theme="dark"] .badge-free { background: #12291f; color: #7fd3ab; }
html[data-theme="dark"] .badge-paid { background: #2a2413; color: #e2c264; }

html[data-theme="dark"] .status-pending_payment { background: #2a2413; color: #e2c264; }
html[data-theme="dark"] .status-failed { background: #2b1614; color: #f0918a; }
html[data-theme="dark"] .status-processing { background: #12222f; color: #86bff0; }
html[data-theme="dark"] .status-paid { background: #12291f; color: #7fd3ab; }
html[data-theme="dark"] .status-canceled { background: var(--sidebar-bg); color: var(--muted); }
html[data-theme="dark"] .status-refunded { background: #1e1b30; color: #b3aaf0; }

html[data-theme="dark"] .price,
html[data-theme="dark"] .buy-box .amount { color: var(--accent); }

html[data-theme="dark"] .price.free { color: #7fd3ab; }

html[data-theme="dark"] .btn-outline {
    color: var(--accent);
    border-color: var(--accent);
}

html[data-theme="dark"] .btn-outline:hover {
    background: var(--hover-bg);
    color: var(--accent);
}

html[data-theme="dark"] .sidebar-list a:hover,
html[data-theme="dark"] .sidebar-list a.active { color: var(--accent); }

html[data-theme="dark"] .course-card:hover { box-shadow: 0 4px 18px rgba(0, 0, 0, .55); }
