/* Адаптивные стили для всех устройств */

/* Большие экраны (Desktop) */
@media (min-width: 1200px) {
    .container {
        max-width: 1400px;
    }
    
    .hero-title {
        font-size: 4rem;
    }
    
    .section-header h2 {
        font-size: 3rem;
    }
}

/* Планшеты (Tablet) */
@media (max-width: 1024px) {
    .container {
        padding: 0 30px;
    }
    
    .hero-content {
        grid-template-columns: 1fr;
        gap: 40px;
        text-align: center;
    }
    
    .hero-title {
        font-size: 3rem;
    }
    
    .hero-stats {
        justify-content: center;
    }
    
    .features-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 25px;
    }
    
    .courses-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
    
    .nav-menu {
        gap: 20px;
    }
    
    .success-stories {
        grid-template-columns: 1fr;
    }
}

/* Маленькие планшеты */
@media (max-width: 768px) {
    .nav-menu {
        position: fixed;
        top: 80px;
        left: -100%;
        width: 100%;
        height: calc(100vh - 80px);
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        padding-top: 50px;
        gap: 30px;
        transition: var(--transition);
    }
    
    .nav-menu.active {
        left: 0;
    }
    
    .nav-toggle {
        display: flex;
    }
    
    .nav-auth {
        flex-direction: column;
        gap: 10px;
        position: fixed;
        top: 200px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 1001;
        opacity: 0;
        transition: var(--transition);
    }
    
    .nav-menu.active + .nav-auth {
        opacity: 1;
    }
    
    .hero {
        padding-top: 80px;
    }
    
    .hero-content {
        padding: 50px 0;
    }
    
    .hero-title {
        font-size: 2.5rem;
        margin-bottom: 15px;
    }
    
    .hero-subtitle {
        font-size: 1.1rem;
        margin-bottom: 25px;
    }
    
    .hero-stats {
        gap: 30px;
        margin-bottom: 30px;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .hero-buttons {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
    
    .btn-primary, .btn-secondary {
        width: 100%;
        max-width: 280px;
        justify-content: center;
    }
    
    .section-header h2 {
        font-size: 2rem;
    }
    
    .section-header p {
        font-size: 1rem;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .feature-card {
        padding: 30px 20px;
    }
    
    .course-filters {
        justify-content: flex-start;
        overflow-x: auto;
        padding: 10px 0;
        gap: 10px;
    }
    
    .course-filters::-webkit-scrollbar {
        display: none;
    }
    
    .filter-btn {
        flex-shrink: 0;
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    
    .courses-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .cta-content h2 {
        font-size: 2rem;
    }
    
    .cta-content p {
        font-size: 1.1rem;
    }
    
    .cta-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .modal-content {
        margin: 10% auto;
        padding: 30px 25px;
        width: 95%;
        max-width: 400px;
    }
    
    .floating-elements {
        display: none;
    }
}

/* Мобильные устройства */
@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }
    
    .nav-container {
        padding: 0 15px;
    }
    
    .hero-title {
        font-size: 2rem;
        line-height: 1.2;
    }
    
    .hero-subtitle {
        font-size: 1rem;
        margin-bottom: 20px;
    }
    
    .hero-stats {
        flex-direction: column;
        gap: 20px;
        margin-bottom: 25px;
    }
    
    .stat {
        display: flex;
        align-items: center;
        gap: 10px;
        justify-content: center;
    }
    
    .stat-number {
        font-size: 1.8rem;
    }
    
    .section-header h2 {
        font-size: 1.8rem;
        line-height: 1.2;
    }
    
    .features-grid {
        gap: 15px;
    }
    
    .feature-card {
        padding: 25px 15px;
    }
    
    .feature-icon {
        width: 60px;
        height: 60px;
        font-size: 24px;
        margin-bottom: 15px;
    }
    
    .feature-card h3 {
        font-size: 1.2rem;
        margin-bottom: 10px;
    }
    
    .course-card {
        margin: 0 10px;
    }
    
    .course-header {
        padding: 15px;
    }
    
    .course-subject {
        font-size: 1.3rem;
    }
    
    .course-content {
        padding: 20px;
    }
    
    .course-stats {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .course-price {
        flex-direction: column;
        align-items: center;
        gap: 5px;
    }
    
    .cta-content h2 {
        font-size: 1.8rem;
        line-height: 1.2;
    }
    
    .cta-content p {
        font-size: 1rem;
    }
    
    .story {
        padding: 15px;
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    
    .modal-content {
        padding: 25px 20px;
        margin: 15% auto;
    }
    
    .modal-content h2 {
        font-size: 1.5rem;
        margin-bottom: 25px;
    }
    
    .auth-form {
        gap: 15px;
    }
    
    .hero-card {
        padding: 20px;
        margin: 0 10px;
    }
    
    .card-header {
        margin-bottom: 20px;
    }
    
    .avatar {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .achievement {
        margin-top: 15px;
        padding: 12px;
        flex-direction: column;
        text-align: center;
        gap: 5px;
    }
}

/* Очень маленькие экраны */
@media (max-width: 360px) {
    .hero-title {
        font-size: 1.8rem;
    }
    
    .hero-subtitle {
        font-size: 0.95rem;
    }
    
    .section-header h2 {
        font-size: 1.6rem;
    }
    
    .btn-primary, .btn-secondary {
        padding: 12px 20px;
        font-size: 0.9rem;
    }
    
    .feature-card h3 {
        font-size: 1.1rem;
    }
    
    .feature-card p {
        font-size: 0.9rem;
    }
    
    .course-subject {
        font-size: 1.2rem;
    }
    
    .course-description {
        font-size: 0.9rem;
    }
    
    .modal-content {
        padding: 20px 15px;
    }
}

/* Ландшафтная ориентация на мобильных */
@media (max-width: 768px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: 100px 0 50px;
    }
    
    .hero-content {
        padding: 30px 0;
    }
    
    .hero-title {
        font-size: 2.2rem;
    }
    
    .hero-stats {
        flex-direction: row;
        gap: 20px;
    }
    
    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* Высокие экраны */
@media (min-height: 800px) {
    .hero {
        min-height: 90vh;
    }
}

/* Принтер */
@media print {
    .navbar,
    .hero-buttons,
    .cta-section,
    .modal {
        display: none !important;
    }
    
    .hero {
        background: white !important;
        color: black !important;
        min-height: auto;
    }
    
    .hero-title,
    .section-header h2 {
        color: black !important;
    }
    
    .feature-card,
    .course-card {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }
}

/* Настройки для улучшенной доступности */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Высокий контраст */
@media (prefers-contrast: high) {
    :root {
        --text-primary: #000000;
        --text-secondary: #333333;
        --bg-primary: #ffffff;
        --bg-secondary: #f5f5f5;
        --primary: #0000ff;
        --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    }
}

/* Темная тема */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #0f172a;
        --bg-secondary: #1e293b;
        --bg-card: #334155;
        --text-primary: #f8fafc;
        --text-secondary: #cbd5e1;
        --text-light: #94a3b8;
    }
    
    .navbar {
        background: rgba(15, 23, 42, 0.95);
    }
    
    .modal-content {
        background-color: var(--bg-card);
    }
}
/* Полный рефакторинг мобильного меню */
@media (max-width: 992px) {
    /* Базовые стили навбара */
    .navbar {
        padding: 10px 0;
        height: 60px;
    }

    .nav-container {
        padding: 0 15px;
        height: 100%;
    }

    .nav-logo {
        font-size: 18px;
        z-index: 1001;
    }

    .nav-logo i {
        font-size: 22px;
    }

    /* Мобильное меню - фиксированное поверх контента */
    .nav-menu {
        position: fixed;
        top: 60px;
        left: -100%;
        width: 100%;
        height: calc(100vh - 60px);
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        flex-direction: column;
        align-items: stretch;
        padding: 20px;
        gap: 0;
        transition: all 0.3s ease-in-out;
        z-index: 1000;
        overflow-y: auto;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
        border-top: 1px solid rgba(102, 126, 234, 0.1);
    }

    .nav-menu.active {
        left: 0;
    }

    /* Ссылки меню */
    .nav-link {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 15px 20px;
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.9);
        border: 1px solid rgba(102, 126, 234, 0.1);
        font-weight: 600;
        font-size: 16px;
        margin-bottom: 8px;
        transition: all 0.2s ease;
    }

    .nav-link:hover,
    .nav-link.active {
        background: var(--primary);
        color: white;
        transform: translateX(5px);
    }

    .nav-link i {
        width: 20px;
        text-align: center;
        font-size: 14px;
    }

    /* Кнопки входа/регистрации в мобильном меню */
    .nav-auth {
        display: flex !important;
        flex-direction: column;
        gap: 10px;
        margin: 20px 0;
        padding: 0;
    }

    .nav-auth .btn-login,
    .nav-auth .btn-register {
        width: 100%;
        justify-content: center;
        padding: 12px;
        font-size: 16px;
        border-radius: 10px;
        margin: 0;
        border: 2px solid;
    }

    .nav-auth .btn-login {
        background: transparent;
        border-color: var(--primary);
        color: var(--primary);
    }

    .nav-auth .btn-register {
        background: var(--primary);
        border-color: var(--primary);
        color: white;
    }

    /* Профиль пользователя в мобильном меню */
    .nav-profile {
        flex-direction: column;
        gap: 15px;
        padding: 20px;
        background: rgba(255, 255, 255, 0.9);
        border-radius: 12px;
        margin: 20px 0;
        border: 1px solid rgba(102, 126, 234, 0.1);
    }

    .level-indicator {
        align-items: center;
    }

    .level-badge {
        font-size: 14px;
        padding: 4px 12px;
    }

    .xp-bar {
        width: 100px;
    }

    .profile-menu {
        flex-direction: column;
        text-align: center;
        gap: 10px;
        padding: 15px;
        background: rgba(102, 126, 234, 0.05);
        border-radius: 10px;
    }

    .avatar {
        width: 40px;
        height: 40px;
    }

    .username {
        font-size: 16px;
        font-weight: 600;
    }

    .profile-dropdown {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        background: transparent;
        padding: 15px 0 0 0;
        min-width: auto;
    }

    .profile-dropdown a {
        padding: 12px 15px;
        background: rgba(255, 255, 255, 0.8);
        border-radius: 8px;
        margin-bottom: 5px;
        border: 1px solid rgba(0, 0, 0, 0.05);
        font-size: 14px;
    }

    /* Бургер-иконка */
    .nav-toggle {
        display: flex;
        flex-direction: column;
        width: 24px;
        height: 24px;
        cursor: pointer;
        background: none;
        border: none;
        padding: 0;
        z-index: 1001;
    }

    .nav-toggle span {
        width: 100%;
        height: 2px;
        background: var(--text-primary);
        margin: 3px 0;
        transition: all 0.3s ease;
        transform-origin: center;
    }

    .nav-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(6px, 6px);
    }

    .nav-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .nav-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(6px, -6px);
    }

    /* Скрываем десктопные элементы */
    .nav-profile .level-indicator,
    .nav-profile .profile-menu {
        display: none;
    }
}

/* Улучшения для очень маленьких экранов */
@media (max-width: 480px) {
    .navbar {
        padding: 8px 0;
        height: 56px;
    }

    .nav-menu {
        top: 56px;
        height: calc(100vh - 56px);
        padding: 15px;
    }

    .nav-link {
        padding: 12px 16px;
        font-size: 15px;
        margin-bottom: 6px;
    }

    .nav-auth .btn-login,
    .nav-auth .btn-register {
        padding: 10px;
        font-size: 15px;
    }

    .nav-profile {
        padding: 15px;
        gap: 12px;
    }

    .profile-menu {
        padding: 12px;
    }

    .avatar {
        width: 36px;
        height: 36px;
    }

    .username {
        font-size: 15px;
    }
}

/* Предотвращаем скролл тела и сдвиг контента */
body.menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Гарантируем, что основной контент не сдвигается */
.dashboard-main,
.courses-section,
.hero,
.profile-main {
    position: relative;
    z-index: 1;
}

/* Стили для мобильного профиля в меню */
@media (max-width: 992px) {
    .mobile-profile-section {
        margin-top: 20px;
        padding-top: 20px;
        border-top: 1px solid rgba(102, 126, 234, 0.2);
    }

    .mobile-profile-header {
        display: flex;
        align-items: center;
        gap: 15px;
        padding: 15px;
        background: rgba(255, 255, 255, 0.9);
        border-radius: 12px;
        margin-bottom: 10px;
        border: 1px solid rgba(102, 126, 234, 0.1);
    }

    .mobile-avatar {
        position: relative;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        overflow: hidden;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        padding: 2px;
        flex-shrink: 0;
    }

    .mobile-avatar img {
        width: 100%;
        height: 100%;
        border-radius: 50%;
        object-fit: cover;
    }

    .mobile-status-indicator {
        position: absolute;
        bottom: 4px;
        right: 4px;
        width: 12px;
        height: 12px;
        background: #10b981;
        border: 2px solid white;
        border-radius: 50%;
    }

    .mobile-user-info {
        flex: 1;
    }

    .mobile-username {
        font-weight: 700;
        font-size: 16px;
        color: var(--text-primary);
        margin-bottom: 4px;
    }

    .mobile-level {
        font-size: 14px;
        color: var(--primary);
        font-weight: 600;
    }

    .mobile-profile-links {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .mobile-profile-link {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 16px;
        background: rgba(255, 255, 255, 0.9);
        border-radius: 10px;
        text-decoration: none;
        color: var(--text-primary);
        font-weight: 500;
        transition: all 0.2s ease;
        border: 1px solid rgba(102, 126, 234, 0.1);
    }

    .mobile-profile-link:hover {
        background: var(--primary);
        color: white;
        transform: translateX(5px);
    }

    .mobile-profile-link i {
        width: 18px;
        text-align: center;
        font-size: 14px;
    }

    .mobile-profile-link.logout {
        color: #ef4444;
        border-color: rgba(239, 68, 68, 0.2);
    }

    .mobile-profile-link.logout:hover {
        background: #ef4444;
        color: white;
    }

    /* Скрываем десктопный профиль в навбаре на мобилке */
    .nav-profile {
        display: none !important;
    }

/* Обеспечиваем правильное отображение меню */
.nav-menu {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    width: 100%;
    height: calc(100vh - 60px);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    flex-direction: column;
    align-items: stretch;
    padding: 20px;
    gap: 10px;
    transition: all 0.3s ease-in-out;
    z-index: 10002;   /* было 1000 */
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

    .nav-menu.active {
        display: flex !important;
    }

    .nav-link {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 15px 20px;
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.9);
        border: 1px solid rgba(102, 126, 234, 0.1);
        font-weight: 600;
        font-size: 16px;
        transition: all 0.2s ease;
        text-decoration: none;
        color: var(--text-primary);
    }

    .nav-link:hover,
    .nav-link.active {
        background: var(--primary);
        color: white;
        transform: translateX(5px);
    }

    /* Бургер-иконка */
    .nav-toggle {
        display: flex !important;
        flex-direction: column;
        width: 24px;
        height: 24px;
        cursor: pointer;
        background: none;
        border: none;
        padding: 0;
        z-index: 1001;
    }

    .nav-toggle span {
        width: 100%;
        height: 2px;
        background: var(--text-primary);
        margin: 3px 0;
        transition: all 0.3s ease;
        transform-origin: center;
    }

    .nav-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(6px, 6px);
    }

    .nav-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .nav-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(6px, -6px);
    }
}

/* На десктопе скрываем мобильный профиль */
@media (min-width: 993px) {
    .mobile-profile-section {
        display: none;
    }
    
    .nav-profile {
        display: flex !important;
    }
    
    .nav-toggle {
        display: none !important;
    }
    
    .nav-menu {
        display: flex !important;
        position: static;
        height: auto;
        background: transparent;
        padding: 0;
        flex-direction: row;
    }
}

/* Предотвращаем скролл тела при открытом меню */
body.menu-open {
    overflow: hidden;
}
/* === FINAL FIX: мобильное меню едет на transform, никаких left/display === */
@media (max-width: 992px) {
  /* панель меню */
  .nav-menu,
  #nav-menu {
    position: fixed;
    top: 60px;               /* высота шапки */
    right: 0;
    bottom: 0;
    left: auto;
    width: 100%;
    display: flex !important;
    flex-direction: column;
    padding: 20px;
    background: #fff;
    overflow-y: auto;

    /* спрятано по умолчанию */
    transform: translateX(100%);
    transition: transform .3s ease;
    pointer-events: none;

    /* ВАЖНО: выше, чем затемнение */
    z-index: 10002;
  }

  /* открыто */
  .nav-menu.active,
  #nav-menu.active {
    transform: translateX(0);
    pointer-events: auto;
  }

  /* затемнение под меню */
  body.menu-open::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 10001;          /* меньше, чем у меню */
  }

  /* просто блокируем скролл */
  body.menu-open {
    overflow: hidden;
  }
}
/* ===== iPad/tablet fix (768–1024px) ===== */
:root { --nav-h: 60px; }

@media (min-width: 768px) and (max-width: 1024px) {
  /* 1) Герой не должен уезжать под фиксированную шапку */
  .hero {
    /* запас под фикс-хедер + чуть воздуха */
    padding-top: calc(var(--nav-h) + 30px) !important;
  }

  /* 2) Кнопки авторизации не «висят» фиксом поверх контента */
  .nav-auth {
    position: static !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    opacity: 1 !important;
    display: flex !important;
    gap: 12px;
  }

  /* можно скрыть кнопки в шапке и показать их внутри бургер-меню */
  .navbar .nav-auth {
    display: none !important;
  }
  .nav-menu .nav-auth {
    display: flex !important;
    flex-direction: column;
    margin: 10px 0 0;
  }

  /* 3) Само мобильное меню — только через transform, без left/display */
  .nav-menu {
    position: fixed !important;
    top: var(--nav-h) !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100%;
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 20px;
    overflow-y: auto;
    z-index: 10002;           /* выше героя */
    transform: translateX(100%);
    transition: transform .3s ease;
    pointer-events: none;
    display: flex !important; /* чтобы не мигало */
    flex-direction: column;
    gap: 10px;
  }
  .nav-menu.active { 
    transform: translateX(0); 
    pointer-events: auto; 
  }

  /* 4) Блокируем скролл страницы и даём затемнение под меню */
  body.menu-open { overflow: hidden; }
  body.menu-open::before {
    content: "";
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 10001;
  }

  /* 5) Чуть уменьшить заголовок, чтобы не ломал строки */
  .hero-title { font-size: 2.8rem !important; line-height: 1.15; }
  .hero-subtitle { font-size: 1.1rem !important; }
}

/* iOS Safari мелкий твик, чтобы не дергало шрифты и скролл */
html { -webkit-text-size-adjust: 100%; }
body, .nav-menu { -webkit-overflow-scrolling: touch; }
