/* ==================== تنظیمات پایه ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* رنگ‌های روشن (حالت روز) */
    --primary: #6C63FF;
    --primary-dark: #5a52d6;
    --secondary: #FF8C42;
    --secondary-dark: #e07a2e;
    --bg-light: #ffffff;
    --bg-card: #f8f9fa;
    --text-dark: #1a1a2e;
    --text-gray: #6c757d;
    --border: #e0e0e0;
    --success: #28a745;
    --error: #dc3545;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 15px 40px rgba(0, 0, 0, 0.15);
    --transition: all 0.3s ease;
}

[data-theme="dark"] {
    /* رنگ‌های تیره (حالت شب) */
    --primary: #8B85FF;
    --primary-dark: #7a73e6;
    --secondary: #FFA05A;
    --bg-light: #121212;
    --bg-card: #1e1e2e;
    --text-dark: #f0f0f0;
    --text-gray: #a0a0b0;
    --border: #2a2a3e;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Inter', 'Vazirmatn', Tahoma, sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
    transition: var(--transition);
    overflow-x: hidden;
}

/* ==================== دکمه تغییر تم ==================== */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

#themeSwitcher {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

#themeSwitcher:hover {
    transform: scale(1.1);
    background: var(--primary-dark);
}

/* ==================== سایدبار ==================== */
.sidebar {
    position: fixed;
    top: 0;
    right: -300px;
    width: 300px;
    height: 100vh;
    background: var(--bg-card);
    box-shadow: var(--shadow);
    z-index: 1001;
    transition: var(--transition);
    overflow-y: auto;
}

.sidebar.open {
    right: 0;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--primary);
}

.sidebar-header h2 {
    color: var(--primary);
}

#closeSidebar {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-gray);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.sidebar-nav a {
    padding: 12px 15px;
    margin: 5px 0;
    color: var(--text-dark);
    text-decoration: none;
    border-radius: 10px;
    transition: var(--transition);
    font-weight: 500;
}

.sidebar-nav a:hover {
    background: var(--primary);
    color: white;
    transform: translateX(-5px);
}

.sidebar-nav a.active {
    background: var(--primary);
    color: white;
}

.menu-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    font-size: 28px;
    cursor: pointer;
    z-index: 999;
    display: none;
    box-shadow: var(--shadow);
}

/* ==================== محتوای اصلی ==================== */
.main-content {
    margin-right: 0;
    padding: 20px;
    transition: var(--transition);
    min-height: 100vh;
}

.page {
    display: none;
    animation: fadeIn 0.5s ease;
}

.page.active-page {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== صفحه اصلی (خانه) ==================== */
.hero-section {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 30px;
    padding: 60px 40px;
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

.hero-content h1 {
    font-size: 3.5rem;
    margin-bottom: 10px;
}

.hero-subtitle {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.hero-description {
    font-size: 1.1rem;
    margin-bottom: 30px;
    opacity: 0.95;
}

.hero-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-primary, .btn-secondary {
    padding: 12px 30px;
    font-size: 1rem;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
}

.btn-primary {
    background: white;
    color: var(--primary);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
    background: transparent;
    color: white;
    border: 2px solid white;
}

.btn-secondary:hover {
    background: white;
    color: var(--primary);
    transform: translateY(-3px);
}

.stats-card, .continue-card, .features-section {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.stats-card h3, .continue-card h3, .features-section h3 {
    margin-bottom: 20px;
    color: var(--primary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
}

.stat-item {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-gray);
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    color: var(--secondary);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.feature {
    background: var(--bg-light);
    padding: 15px;
    border-radius: 15px;
    text-align: center;
    font-weight: 500;
    transition: var(--transition);
}

.feature:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

/* ==================== صفحه آموزش تایپ ==================== */
.lang-selector {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
}

.lang-btn {
    padding: 10px 25px;
    border: 2px solid var(--primary);
    background: transparent;
    color: var(--primary);
    border-radius: 50px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
}

.lang-btn.active {
    background: var(--primary);
    color: white;
}

.lesson-selector {
    text-align: center;
    margin-bottom: 20px;
}

#lessonSelect {
    padding: 10px 20px;
    font-size: 1rem;
    border-radius: 10px;
    border: 2px solid var(--border);
    background: var(--bg-card);
    color: var(--text-dark);
    cursor: pointer;
}

.typing-container {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 25px;
    box-shadow: var(--shadow);
}

.target-text-box {
    background: var(--bg-light);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
}

.target-text {
    font-family: 'Fira Code', monospace;
    font-size: 1.8rem;
    line-height: 1.5;
    text-align: center;
    word-break: break-word;
    color: var(--text-dark);
}

.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 10px;
    margin-top: 15px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    width: 0%;
    transition: width 0.3s ease;
}

.user-input {
    width: 100%;
    padding: 15px;
    font-family: 'Fira Code', monospace;
    font-size: 1.2rem;
    border: 2px solid var(--border);
    border-radius: 15px;
    background: var(--bg-light);
    color: var(--text-dark);
    resize: vertical;
    margin-bottom: 20px;
}

.user-input:focus {
    outline: none;
    border-color: var(--primary);
}

.virtual-keyboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--bg-light);
    border-radius: 15px;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.key {
    width: 50px;
    height: 50px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1rem;
    transition: var(--transition);
    color: var(--text-dark);
}

.key.active {
    background: var(--primary);
    color: white;
    transform: scale(0.95);
    border-color: var(--primary);
}

.stats-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--bg-light);
    border-radius: 15px;
}

.stat {
    text-align: center;
    font-weight: 600;
}

.stat span:first-child {
    color: var(--text-gray);
    font-size: 0.9rem;
    display: block;
    margin-bottom: 5px;
}

.stat span:last-child {
    font-size: 1.5rem;
    color: var(--primary);
}

.lesson-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.lesson-controls button {
    padding: 10px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
}

.lesson-controls button:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

/* ==================== صفحه تست سرعت ==================== */
.test-settings {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.test-settings select {
    padding: 10px 20px;
    border-radius: 10px;
    border: 2px solid var(--border);
    background: var(--bg-card);
    color: var(--text-dark);
}

.test-text {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 15px;
    font-family: monospace;
    font-size: 1.2rem;
    line-height: 1.8;
    margin-bottom: 20px;
}

#testInput {
    width: 100%;
    padding: 15px;
    font-family: monospace;
    font-size: 1.1rem;
    border: 2px solid var(--border);
    border-radius: 15px;
    background: var(--bg-light);
    color: var(--text-dark);
}

.test-timer {
    font-size: 3rem;
    text-align: center;
    margin: 20px 0;
    font-weight: bold;
    color: var(--primary);
}

.test-result {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 15px;
    margin-top: 20px;
}

/* ==================== صفحه مسابقه ==================== */
.race-mode {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 30px;
}

.race-text {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 15px;
    font-family: monospace;
    font-size: 1.2rem;
    margin-bottom: 20px;
}

#raceInput {
    width: 100%;
    padding: 15px;
    font-family: monospace;
    font-size: 1.1rem;
    border: 2px solid var(--border);
    border-radius: 15px;
    background: var(--bg-light);
    color: var(--text-dark);
}

.race-progress {
    margin-top: 20px;
}

.user-progress, .bot-progress {
    margin: 10px 0;
}

/* ==================== صفحه پروفایل ==================== */
.profile-info {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 20px;
    margin-bottom: 30px;
}

.info-group {
    margin-bottom: 15px;
}

.info-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--primary);
}

.info-group input {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--bg-light);
    color: var(--text-dark);
}

.stats-chart {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 20px;
    margin-bottom: 30px;
}

.achievements {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 20px;
    margin-bottom: 30px;
}

.settings {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 20px;
}

.settings label {
    display: block;
    margin: 10px 0;
}

/* ==================== جدول رهبران ==================== */
.leaderboard-list {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 20px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    border-bottom: 1px solid var(--border);
}

.leaderboard-rank {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
    width: 50px;
}

.leaderboard-name {
    flex: 1;
    font-weight: 600;
}

.leaderboard-wpm {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--secondary);
}

/* ==================== بلاگ ==================== */
.blog-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.blog-card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 15px;
    transition: var(--transition);
}

.blog-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.blog-title {
    font-size: 1.3rem;
    margin-bottom: 10px;
    color: var(--primary);
}

/* ==================== راهنما ==================== */
.keyboard-guide {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 20px;
    margin-bottom: 30px;
    overflow-x: auto;
}

.guide-keyboard {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 700px;
}

.guide-row {
    display: flex;
    justify-content: center;
    gap: 5px;
}

.guide-key {
    width: 50px;
    height: 50px;
    background: var(--bg-light);
    border: 2px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

[data-finger="pinky-l"] { border-top: 4px solid #FF6B6B; }
[data-finger="ring-l"] { border-top: 4px solid #4ECDC4; }
[data-finger="middle-l"] { border-top: 4px solid #45B7D1; }
[data-finger="index-l"] { border-top: 4px solid #96CEB4; }
[data-finger="thumb"] { border-top: 4px solid #FFEAA7; }
[data-finger="index-r"] { border-top: 4px solid #DDA0DD; }
[data-finger="middle-r"] { border-top: 4px solid #98D8C8; }
[data-finger="ring-r"] { border-top: 4px solid #F7D794; }
[data-finger="pinky-r"] { border-top: 4px solid #E77F67; }

.finger-table {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 20px;
}

/* ==================== صفحات تماس و درباره ==================== */
#contactForm input, #contactForm textarea {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--bg-light);
    color: var(--text-dark);
}

/* ==================== واکنشگرا (Responsive) ==================== */
@media (max-width: 768px) {
    .menu-btn {
        display: block;
    }
    
    .sidebar {
        width: 280px;
    }
    
    .hero-content h1 {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1.2rem;
    }
    
    .target-text {
        font-size: 1.2rem;
    }
    
    .key {
        width: 35px;
        height: 35px;
        font-size: 0.8rem;
    }
    
    .stats-panel {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .key {
        width: 28px;
        height: 28px;
        font-size: 0.7rem;
    }
    
    .btn-primary, .btn-secondary {
        padding: 8px 20px;
        font-size: 0.9rem;
    }
}