/* ========== ОБЩИЕ ИСПРАВЛЕНИЯ ========== */
/* test 2 */

/* Fix для viewport на мобильных */
@media screen and (max-width: 767px) {
    html, body {
        overflow-x: hidden;
        width: 100%;
        position: relative;
    }

    body {
        font-size: 14px;
        line-height: 1.4;
    }
}

/* ========== ХЭДЕР И НАВИГАЦИЯ ========== */

/* Мобильные портреты */
@media (max-width: 575px) {
    :root {
        --header-height: 60px;
    }
    
    /* Fix для логотипа в хэдере */
    .header {
        padding: 12px 16px !important;
        min-height: 60px;
        flex-wrap: nowrap;
        gap: 10px;
    }

    .header-left {
        flex: 1;
        min-width: 0;
    }

    .logo {
        font-size: 18px;
        gap: 8px;
        align-items: center;
        height: 36px;
    }

    .logo img {
        height: 28px;
        width: 28px;
    }

    .logo span {
        display: block !important;
        font-size: 18px;
        font-weight: 700;
        line-height: 1.2;
        margin-top: 0;
    }

    /* User menu fix */
    .user-menu {
        flex-shrink: 0;
    }

    .user-avatar {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    /* Mobile menu - initially hidden, shows when active */
    .navbar-menu {
        display: none !important;
    }

    .navbar-menu.active {
        display: flex !important;
        flex-direction: column;
        position: fixed;
        top: calc(var(--header-height, 80px));
        left: 0;
        right: 0;
        background: white;
        border-bottom: 1px solid var(--gray-200, #e5e7eb);
        padding: 12px 16px;
        gap: 8px;
        z-index: 99;
        width: 100%;
        box-sizing: border-box;
        max-width: 100%;
        margin: 0;
        min-height: auto;
        overflow: hidden;
    }

    .navbar-menu.active .nav-link {
        padding: 10px 12px;
        text-align: left;
        border-radius: 6px;
        color: var(--gray-700, #374151);
    }

    .navbar-menu.active .mobile-auth-links {
        display: flex;
        flex-direction: column;
        gap: 8px;
        margin-top: 8px;
        padding-top: 8px;
        border-top: 1px solid var(--gray-200, #e5e7eb);
    }

    .navbar-menu.active .mobile-auth-links .btn {
        width: 100%;
        padding: 10px 12px;
        font-size: 14px;
    }
}

/* Очень маленькие экраны */
@media (max-width: 360px) {
    .logo span {
        font-size: 16px;
    }

    .logo img {
        height: 24px;
        width: 24px;
    }
}

/* ========== ГЛАВНАЯ СТРАНИЦА (до авторизации) ========== */

/* Скрываем preloader на главной если есть проблемы */
#preloader {
    position: fixed;
    z-index: 99999;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Контейнер приложения */
#app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Контент до авторизации */
body:not(.authenticated) {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* Hero секция (если есть на главной) */
.hero-section {
    padding: 40px 20px;
    text-align: center;
    color: white;
    position: relative;
    z-index: 1;
    min-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.hero-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 16px;
    line-height: 1.2;
}

.hero-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 32px;
    line-height: 1.5;
}

/* Кнопки на главной */
.hero-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
}

.hero-btn {
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.hero-btn.primary {
    background: white;
    color: #667eea;
}

.hero-btn.secondary {
    background: transparent;
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
}

.hero-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

/* ========== МОДАЛЬНЫЕ ОКНА (ФИКС ПРОКРУТКИ) ========== */
/* Все стили модального окна находятся в auth.css */
/* Здесь только адаптивные дополнения */

@media (max-width: 767px) {
    /* Скрыть desktop auth buttons в header на мобилке */
    .auth-buttons {
        display: none !important;
    }

    .mobile-auth-links {
        display: flex;
        gap: 10px;
        margin-top: 12px;
        flex-direction: column;
    }

    .mobile-auth-links .btn {
        width: 100%;
    }

    /* Адаптивный размер модального окна на мобилке */
    .modal {
        padding: 0;
        align-items: flex-start;
        justify-content: flex-start;
    }

    .modal.active {
        align-items: center;
        justify-content: center;
        padding: 20px;
    }

    .modal-content {
        max-width: 100%;
        width: calc(100% - 40px);
        max-height: calc(100vh - 40px);
        margin: auto;
        padding: 20px;
        border-radius: 12px;
    }

/* Особый фикс для очень маленьких экранов */

    /* @media (max-width: 360px) {
        white-space: nowrap;
    } */

    /* Поля формы */
    .form-group {
        margin-bottom: 20px;
    }

    .form-group label {
        font-size: 14px;
        margin-bottom: 6px;
        display: block;
    }

    .input-with-icon {
        position: relative;
    }

    .input-with-icon input {
        padding: 14px 16px 14px 44px;
        font-size: 16px; /* Важно для iOS чтобы не зумился */
        height: 48px;
        border-radius: 10px;
    }

    .input-with-icon i:first-of-type {
        left: 16px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 18px;
    }

    .toggle-password {
        right: 16px;
        left: auto;
        top: 50%;
        transform: translateY(-50%);
        font-size: 18px;
    }

    /* Кнопки */
    .btn {
        height: 50px;
        font-size: 16px;
        font-weight: 600;
        border-radius: 10px;
        padding: 0 24px;
    }

    .btn-block {
        width: 100%;
    }

    /* Ссылки под формой */
    .auth-links {
        margin-top: 20px;
        text-align: center;
    }

    .auth-links a {
        font-size: 14px;
        color: var(--primary-color);
        text-decoration: none;
    }
}

/* Фикс для placeholder на iOS */
@media (max-width: 767px) {
    input::placeholder,
    textarea::placeholder {
        font-size: 16px; /* Предотвращает зум на iOS */
    }
}

/* ========== ТЕСТОВАЯ ПЛАШКА В ФОРМЕ ========== */

.test-data-panel {
    background: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
    border-radius: 12px;
    padding: 20px;
    margin-top: 30px;
    color: #333;
    position: relative;
    overflow: hidden;
}

.test-data-panel::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transform: translate(30%, -30%);
}

.test-data-panel h4 {
    margin-bottom: 12px;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.test-data-panel h4 i {
    color: #e74c3c;
}

.test-data-list {
    font-size: 13px;
    line-height: 1.5;
}

.test-data-item {
    margin-bottom: 8px;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.test-data-label {
    font-weight: 500;
    min-width: 80px;
    color: #555;
}

.test-data-value {
    flex: 1;
    font-family: 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    word-break: break-all;
}

/* Адаптивность тестовой плашки */
@media (max-width: 767px) {
    .test-data-panel {
        margin-top: 25px;
        padding: 16px;
    }

    .test-data-list {
        font-size: 12px;
    }

    .test-data-item {
        flex-direction: column;
        gap: 2px;
        margin-bottom: 10px;
    }

    .test-data-label {
        min-width: auto;
        font-size: 11px;
        opacity: 0.8;
    }

    .test-data-value {
        font-size: 13px;
        padding: 4px 8px;
    }
}

/* ========== ФИКС ДЛЯ ВЫСОТЫ ЭКРАНА ========== */

/* Все стили для модального окна находятся в auth.css - избегаем конфликтов */

/* ========== КНОПКИ ВХОДА/РЕГИСТРАЦИИ НА ГЛАВНОЙ ========== */

/* Если у вас есть кнопки до авторизации на главной */
.auth-buttons-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 100;
}

.auth-buttons-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    max-width: 500px;
    margin: 0 auto;
}

.auth-main-btn {
    height: 56px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    text-decoration: none;
}

.auth-main-btn.primary {
    background: white;
    color: #667eea;
}

.auth-main-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

/* Адаптивность для кнопок */
@media (max-width: 767px) {
    .auth-buttons-container {
        padding: 16px;
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }

    .auth-buttons-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .auth-main-btn {
        height: 52px;
    }
}

/* ========== ИСПРАВЛЕНИЕ ДЛЯ HERO НА МОБИЛЬНЫХ ========== */

/* Если hero перекрывается хэдером */
@media (max-width: 767px) {
    .hero-section {
        padding-top: 80px; /* Отступ под хэдер */
        padding-bottom: 120px; /* Отступ под кнопки */
        min-height: 100vh;
        box-sizing: border-box;
    }

    .hero-title {
        font-size: 1.8rem;
        padding: 0 16px;
    }

    .hero-subtitle {
        font-size: 1rem;
        padding: 0 16px;
        margin-bottom: 40px;
    }
}

/* ========== ЭКСТРА ФИКСЫ ДЛЯ КОНКРЕТНЫХ УСТРОЙСТВ ========== */

/* iPhone SE и очень маленькие экраны */
@media (max-width: 375px) and (max-height: 670px) {
    .hero-section {
        padding-top: 60px;
        padding-bottom: 100px;
    }

    .hero-title {
        font-size: 1.6rem;
    }

    .form-group input {
        height: 44px;
        font-size: 15px;
    }

    .btn {
        height: 46px;
        font-size: 15px;
    }
}

/* Ландшафтная ориентация */
@media (max-height: 500px) and (orientation: landscape) {
    .hero-section {
        padding-top: 70px;
        padding-bottom: 70px;
        min-height: auto;
    }

    .modal.active {
        align-items: flex-start;
        padding-top: 10px;
    }

    .modal-content {
        max-height: 80vh;
        margin-top: 10px;
    }

    .auth-form {
        padding-bottom: 10px;
    }
}

/* ========== АНИМАЦИИ ДЛЯ ПЛАВНОСТИ ========== */

@media (max-width: 767px) {
    .modal-content {
        animation: mobileModalAppear 0.3s ease-out;
    }

    @keyframes mobileModalAppear {
        from {
            opacity: 0;
            transform: translateY(20px) scale(0.98);
        }
        to {
            opacity: 1;
            transform: translateY(0) scale(1);
        }
    }
}

/* ========== ФИКС ДЛЯ КЛАВИАТУРЫ НА МОБИЛЬНЫХ ========== */

/* Когда открыта клавиатура */
.keyboard-open .modal.active {
    align-items: flex-start !important;
    padding-top: 10px !important;
}

.keyboard-open .modal-content {
    max-height: 70vh !important;
}

/* JavaScript класс для определения открытой клавиатуры */
@media (max-width: 767px) {
    .keyboard-open body {
        height: 100%;
        overflow: hidden;
    }
}

/* Ensure desktop auth buttons are visible on large screens */
@media (min-width: 768px) {
    .auth-buttons {
        display: flex !important;
        gap: 10px;
        justify-content: flex-end;
        align-items: center;
    }

    .navbar-menu {
        display: flex !important;
    }

    .mobile-auth-links {
        display: none !important;
    }
}