/* Базовые стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* Навигация */
.navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
}

.nav-logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: #4f46e5;
}

.nav-menu {
    display: flex;
    gap: 2rem;
}

.nav-link {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    transition: color 0.3s;
}

.nav-link:hover {
    color: #4f46e5;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Основной контейнер */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.section {
    display: none;
}

.section.active {
    display: block;
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Приветственный экран */
.welcome-container {
    text-align: center;
    background: white;
    padding: 3rem;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    margin: 2rem 0;
}

.welcome-container h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: #4f46e5;
}

.auth-forms {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 2rem;
}

.form-container {
    padding: 2rem;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
}

/* Кнопки */
.btn-primary, .btn-secondary, .btn-logout, .btn-back {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #4f46e5;
    color: white;
}

.btn-primary:hover {
    background: #4338ca;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #10b981;
    color: white;
}

.btn-secondary:hover {
    background: #059669;
    transform: translateY(-2px);
}

.btn-logout {
    background: #ef4444;
    color: white;
}

.btn-back {
    background: #6b7280;
    color: white;
}

/* Формы */
.form-input, .form-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 1rem;
}

.form-textarea {
    height: 150px;
    resize: vertical;
    font-family: monospace;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

/* Карточки */
.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    text-align: center;
}

.stat-card.large {
    padding: 2rem;
}

.stat-card h3 {
    color: #6b7280;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.stat-card p {
    font-size: 1.5rem;
    font-weight: bold;
    color: #4f46e5;
}

.user-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

/* Прогресс */
.progress-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.progress-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: #e5e7eb;
    border-radius: 5px;
    margin: 1rem 0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #34d399);
    border-radius: 5px;
    transition: width 0.5s ease;
    width: 0%;
}

/* Сетки */
.languages-grid, .lessons-grid, .achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.language-card, .lesson-card, .achievement-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: all 0.3s;
}

.language-card:hover, .lesson-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.lesson-card.completed {
    border-left: 4px solid #10b981;
}

.lesson-status {
    margin-top: 0.5rem;
    font-weight: 600;
    color: #6b7280;
}

.achievement-card {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.achievement-icon {
    width: 50px;
    height: 50px;
    background: #fbbf24;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.achievement-locked {
    opacity: 0.5;
}

.achievement-locked .achievement-icon {
    background: #9ca3af;
}

.achievements-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

/* Таблицы лидеров */
.leaderboard-tabs, .admin-tabs {
    display: flex;
    gap: 0.5rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 0.5rem 1rem;
    border: 2px solid #e5e7eb;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.tab-btn.active {
    background: #4f46e5;
    color: white;
    border-color: #4f46e5;
}

.leaderboard-container {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.leaderboard-header {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr 1fr;
    padding: 1rem;
    background: #f8fafc;
    font-weight: 600;
    border-bottom: 2px solid #e5e7eb;
}

.leaderboard-list {
    max-height: 500px;
    overflow-y: auto;
}

.leaderboard-item {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr 1fr;
    padding: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.leaderboard-item:last-child {
    border-bottom: none;
}

.leaderboard-item.current-user {
    background: #eff6ff;
    border-left: 4px solid #4f46e5;
}

/* Модальные окна */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6b7280;
}

.close:hover {
    color: #374151;
}

/* Упражнения */
.exercise {
    margin: 1rem 0;
    padding: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
}

.exercise-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1rem 0;
}

.option-btn {
    padding: 0.75rem;
    border: 2px solid #e5e7eb;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: left;
}

.option-btn:hover {
    border-color: #4f46e5;
}

.option-btn.correct {
    background: #d1fae5;
    border-color: #10b981;
    color: #065f46;
}

.option-btn.incorrect {
    background: #fee2e2;
    border-color: #ef4444;
    color: #7f1d1d;
}

.option-btn:disabled {
    cursor: not-allowed;
}

.lesson-complete {
    text-align: center;
    padding: 2rem;
}

.lesson-complete h3 {
    color: #10b981;
    margin-bottom: 1rem;
}

/* Админ панель */
.admin-tab-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    margin-top: 1rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.language-stats {
    margin-top: 2rem;
}

.stats-list, .users-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stat-item, .user-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.user-actions {
    display: flex;
    gap: 0.5rem;
}

.user-actions button {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

.search-box {
    margin-bottom: 1rem;
}

.lessons-management {
    margin-top: 1rem;
}

.language-section {
    background: #f8fafc;
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.lessons-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.lesson-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.lesson-info h4 {
    margin: 0 0 0.5rem 0;
    color: #374151;
}

.lesson-info p {
    margin: 0.25rem 0;
    font-size: 0.9rem;
    color: #6b7280;
}

.lesson-actions {
    display: flex;
    gap: 0.5rem;
}

.export-options {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.export-textarea {
    width: 100%;
    height: 300px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    margin-top: 1rem;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: #6b7280;
}

/* Рекомендации */
.recommendations {
    margin-top: 2rem;
}

.lessons-container {
    margin-top: 2rem;
}

.lessons-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Адаптивность */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-menu {
        gap: 1rem;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .auth-forms {
        grid-template-columns: 1fr;
    }
    
    .main-container {
        padding: 1rem;
    }
    
    .languages-grid, .lessons-grid {
        grid-template-columns: 1fr;
    }
    
    .leaderboard-header, .leaderboard-item {
        grid-template-columns: 0.5fr 1.5fr 1fr 1fr;
        font-size: 0.9rem;
    }
    
    .modal-content {
        margin: 10% auto;
        width: 95%;
        padding: 1rem;
    }
    
    .lesson-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .lesson-actions, .user-actions {
        width: 100%;
    }
    
    .user-actions button {
        width: 100%;
    }
    
    .section-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .tab-btn {
        flex: 1;
        min-width: 120px;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .welcome-container {
        padding: 1.5rem;
    }
    
    .welcome-container h1 {
        font-size: 2rem;
    }
    
    .form-container {
        padding: 1rem;
    }
    
    .leaderboard-header, .leaderboard-item {
        grid-template-columns: 0.5fr 1fr 0.8fr 0.8fr;
        font-size: 0.8rem;
        padding: 0.75rem;
    }
}

/* PWA стили */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
    }
}