:root {
    --primary: #FF6B35;
    --secondary: #F7931E;
    --accent: #FDC830;
    
    /* Default Light Mode Colors */
    --dark: #2C2C2C;
    --darker: #1A1A1A;
    --light: #F5F5F5;
    --white: #FFFFFF;
    
    /* New dedicated variable for footer background */
    --footer-bg: #1A1A1A; 
    
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-lg: rgba(0, 0, 0, 0.15);
    --border: #E0E0E0;
    --success: #4CAF50;
    --error: #F44336;
    
    color-scheme: light;
}

/* 🌙 Improved Dark Mode Variables */
[data-theme="dark"] {
    --dark: #E0E0E0;        /* Main text: Soft White */
    --darker: #FFFFFF;      /* Headings: Bright White */
    --light: #121212;       /* Page Background: Deep Dark Gray */
    --white: #1E1E1E;       /* Cards/Header: Lighter Dark Gray */
    
    /* Fix: Footer stays dark in dark mode */
    --footer-bg: #080808;   
    
    --border: #333333;      /* Subtle dark borders */
    --shadow: rgba(0, 0, 0, 0.5);
    --shadow-lg: rgba(0, 0, 0, 0.7);
    
    /* Fixes system elements like scrollbars to be dark */
    color-scheme: dark; 
}

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

body {
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--light);
    color: var(--dark);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.en {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ================= HEADER ================= */

header {
    background: var(--white);
    box-shadow: 0 2px 10px var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 3px solid var(--primary);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
}

.logo-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Righteous', cursive;
    font-size: 1.5rem;
    color: var(--white);
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
    transform: rotate(-5deg);
}

.logo-text {
    font-family: 'Righteous', cursive;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
    letter-spacing: -0.5px;
}

nav {
    display: flex;
    gap: 2rem;
    align-items: center;
    flex-wrap: wrap;
}

nav a {
    text-decoration: none;
    color: var(--dark);
    font-weight: 600;
    font-size: 1rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

nav a:hover,
nav a.active {
    color: var(--primary);
    background: rgba(255, 107, 53, 0.1);
}

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

.theme-toggle, .lang-switch {
    background: var(--light);
    border: 2px solid var(--border);
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.2rem;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lang-switch {
    font-weight: 600;
    font-size: 0.9rem;
    font-family: inherit;
}

.theme-toggle:hover, .lang-switch:hover {
    border-color: var(--primary);
    background: var(--white);
}

/* ================= BUTTONS ================= */

.btn {
    padding: 0.6rem 1.5rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--white);
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 53, 0.4);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

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

.btn-danger {
    background: var(--error);
    color: var(--white);
}

.btn-danger:hover {
    background: #d32f2f;
}

.btn-small {
    padding: 0.3rem 0.8rem;
    font-size: 0.85rem;
}

.btn-full {
    width: 100%;
    padding: 1rem;
}

/* ================= MAIN ================= */

main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    min-height: calc(100vh - 200px);
}

.page {
    display: none;
    animation: fadeIn 0.4s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 2rem;
    color: var(--darker);
    position: relative;
    display: inline-block;
}

.page-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 60%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 2px;
}

/* ================= GRIDS ================= */

.news-grid, .download-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.news-card, .download-card {
    background: var(--white);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px var(--shadow);
    transition: all 0.3s ease;
    border: 1px solid var(--border);
}

.news-card {
    cursor: pointer;
}

.news-card:hover, .download-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px var(--shadow-lg);
}

/* ================= NEWS ================= */

.news-image {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 3rem;
    font-weight: bold;
    overflow: hidden;
    position: relative;
}

.news-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

.news-image-icon {
    position: relative;
    z-index: 1;
}

.news-content {
    padding: 1.5rem;
}

.news-date {
    color: #999;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.news-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.8rem;
    color: var(--darker);
}

.news-excerpt {
    color: #666;
    line-height: 1.8;
}

/* ================= DOWNLOADS ================= */

.download-card {
    padding: 2rem;
    text-align: center;
}

.download-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 20px;
    margin: 0 auto 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 2rem;
}

.download-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--darker);
}

.download-meta {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.download-list {
    text-align: left;
    margin-top: 1rem;
}

.download-item {
    background: var(--light);
    padding: 0.8rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.download-item-name {
    font-weight: 600;
    color: var(--darker);
}

.download-item-size {
    color: #999;
    font-size: 0.85rem;
}

/* ================= INFO ================= */

.info-section {
    background: var(--white);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px var(--shadow);
    border: 1px solid var(--border);
}

.info-section h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--darker);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.info-section h2::before {
    content: '';
    width: 4px;
    height: 30px;
    background: linear-gradient(180deg, var(--primary), var(--secondary));
    border-radius: 2px;
}

.info-section p {
    line-height: 2;
    color: #555;
    margin-bottom: 1rem;
}

/* ================= FORUM ================= */

.forum-categories {
    display: grid;
    gap: 1rem;
    margin-top: 2rem;
}

.forum-category {
    background: var(--white);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px var(--shadow);
    border: 1px solid var(--border);
    transition: all 0.3s ease;
    cursor: pointer;
}

.forum-category:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 20px var(--shadow-lg);
}

.forum-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.forum-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--darker);
}

.forum-stats {
    display: flex;
    gap: 2rem;
    color: #999;
    font-size: 0.9rem;
}

/* ================= AUTH ================= */

.auth-container {
    max-width: 450px;
    margin: 3rem auto;
    background: var(--white);
    border-radius: 16px;
    padding: 3rem;
    box-shadow: 0 4px 30px var(--shadow-lg);
    border: 1px solid var(--border);
}

.auth-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    text-align: center;
    color: var(--darker);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--dark);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    font-family: inherit;
    background: var(--white);
    color: var(--dark);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

textarea {
    min-height: 150px;
    resize: vertical;
}

.file-input {
    padding: 0.5rem;
}

.image-preview {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: 8px;
    margin-top: 0.5rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: #666;
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

/* ================= ADMIN ================= */

.admin-container {
    margin-top: 2rem;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 2px 10px var(--shadow);
}

.admin-welcome {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--darker);
}

.admin-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    background: var(--white);
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 2px 10px var(--shadow);
    flex-wrap: wrap;
}

.admin-tab {
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-family: inherit;
    font-size: 1rem;
    color: var(--dark);
}

.admin-tab:hover {
    background: var(--light);
}

.admin-tab.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--white);
}

.admin-content {
    background: var(--white);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 10px var(--shadow);
}

.admin-panel {
    display: none;
}

.admin-panel.active {
    display: block;
}

.admin-list {
    margin-top: 2rem;
}

.admin-list-item {
    background: var(--light);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-list-item-content h4 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.admin-list-item-content p {
    color: #666;
    font-size: 0.9rem;
    margin: 0;
}

/* ================= MODAL ================= */

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    overflow-y: auto;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal-content {
    background: var(--white);
    border-radius: 16px;
    padding: 3rem;
    max-width: 800px;
    width: 100%;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    font-size: 2rem;
    cursor: pointer;
    color: #999;
    background: none;
    border: none;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--light);
    color: var(--dark);
}

.modal-header {
    margin-bottom: 2rem;
}

.modal-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--darker);
    margin-bottom: 0.5rem;
}

.modal-date {
    color: #999;
    font-size: 0.9rem;
}

.modal-body {
    line-height: 2;
    color: #555;
    font-size: 1.1rem;
}

.video-embed {
    margin: 2rem 0;
    border-radius: 12px;
    overflow: hidden;
    background: var(--light);
}

.video-embed iframe {
    width: 100%;
    min-height: 400px;
    border: none;
}

/* ================= TOPIC / COMMENTS ================= */

.topic-header {
    background: var(--white);
    padding: 2rem;
    border-radius: 16px;
    margin-bottom: 2rem;
    box-shadow: 0 2px 10px var(--shadow);
}

.topic-meta {
    display: flex;
    gap: 2rem;
    color: #999;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.topic-body {
    line-height: 2;
    color: #555;
}

.comment {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 10px var(--shadow);
}

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

.comment-author {
    font-weight: 700;
    color: var(--primary);
}

.comment-date {
    color: #999;
    font-size: 0.85rem;
}

.comment-body {
    color: #555;
    line-height: 1.8;
}

/* ================= STATES ================= */

.loading {
    text-align: center;
    padding: 3rem;
    color: #999;
    font-size: 1.2rem;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: #999;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.empty-state-text {
    font-size: 1.2rem;
    font-weight: 600;
    color: #666;
}

.hidden {
    display: none !important;
}

/* ================= FOOTER ================= */

footer {
    background: var(--footer-bg); /* NEW - uses correct dark color */
    color: #cccccc; /* Fixed light color for footer text to ensure readability */
    padding: 3rem 2rem 1.5rem;
    margin-top: 4rem;
}

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

.footer-section h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--accent);
}

.footer-section p,
.footer-section a {
    color: #ccc;
    text-decoration: none;
    display: block;
    margin-bottom: 0.5rem;
    transition: color 0.3s ease;
}

.footer-section a:hover {
    color: var(--accent);
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid #444;
    color: #999;
}

/* ================= RESPONSIVE ================= */

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
    }

    nav {
        justify-content: center;
    }

    .page-title {
        font-size: 2rem;
    }

    .news-grid, .download-grid {
        grid-template-columns: 1fr;
    }

    .admin-tabs {
        flex-direction: column;
    }
}
