/* Стили для PWA */

/* Скрываем элементы, которые должны отображаться только в браузере */
.standalone-mode[data-mode="pwa"] .browser-only {
    display: none !important;
}

/* Показываем элементы, которые должны отображаться только в PWA */
.pwa-only {
    display: none;
}

.standalone-mode[data-mode="pwa"] .pwa-only {
    display: block !important;
}

/* Стили для баннера установки */
.install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(18, 18, 18, 0.95);
    color: #fff;
    z-index: 9999;
    padding: 12px 16px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    animation: slide-up 0.3s ease-out;
}

.install-banner-content {
    display: flex;
    align-items: center;
    max-width: 600px;
    margin: 0 auto;
}

.install-banner-icon {
    margin-right: 16px;
}

.install-banner-icon img {
    width: 48px;
    height: 48px;
    border-radius: 12px;
}

.install-banner-text {
    flex: 1;
}

.install-banner-text strong {
    display: block;
    font-size: 16px;
    margin-bottom: 4px;
}

.install-banner-text p {
    margin: 0;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

.install-banner-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.install-banner-button {
    background: linear-gradient(135deg, #4b9cff, #3a7dcc);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.install-banner-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(75, 156, 255, 0.3);
}

.install-banner-dismiss {
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    border: none;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: color 0.2s ease;
}

.install-banner-dismiss:hover {
    color: white;
}

/* Контейнер для кнопки установки */
#install-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 999;
}

#install-button {
    background: linear-gradient(135deg, #4b9cff, #3a7dcc);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 30px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
}

#install-button i {
    font-size: 18px;
}

#install-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(75, 156, 255, 0.4);
}

/* Анимации */
@keyframes slide-up {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* Адаптация под iPhone с челкой */
@supports (padding: max(0px)) {
    /* Стили для PWA режима */
    .standalone-mode[data-mode="pwa"] {
        /* Увеличиваем отступ сверху, чтобы шапка не проваливалась под статус-бар iPhone */
        padding-top: max(env(safe-area-inset-top), 50px);
        padding-bottom: max(env(safe-area-inset-bottom), 20px);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    
    /* Стили для браузерной версии - небольшой отступ сверху для шапки */
    body:not(.standalone-mode), .standalone-mode[data-mode="browser"] {
        padding-top: 60px; /* Отступ для фиксированной шапки */
        padding-bottom: 0;
        padding-left: 0;
        padding-right: 0;
        min-height: 100vh; /* Гарантируем минимальную высоту на весь экран */
        width: 100%; /* Гарантируем полную ширину */
        margin: 0;
        background-color: var(--dark-bg) !important; /* Гарантируем цвет фона */
    }
    
    /* Фиксируем шапку в PWA режиме */
    .standalone-mode[data-mode="pwa"] .header {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1000 !important;
        padding-top: max(env(safe-area-inset-top), 5px) !important;
        padding-bottom: 5px !important;
        background-color: #1a1e21 !important;
        border-bottom: 1px solid #2d3339 !important;
        margin: 0 !important;
        height: auto !important;
        min-height: 30px !important; /* Задаем минимальную высоту шапки */
        width: 100% !important;
        display: block !important;
        text-align: center !important;
    }
    
    /* Стили шапки для браузерной версии - делаем фиксированной как в PWA */
    .standalone-mode[data-mode="browser"] .header {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1000 !important;
        padding-top: 5px !important;
        padding-bottom: 3px !important;
        background-color: #1a1e21 !important;
        border-bottom: 1px solid #2d3339 !important;
        margin: 0 !important;
        height: auto !important;
        min-height: 30px !important;
        width: 100% !important;
        display: block !important;
        text-align: center !important;
        box-sizing: border-box !important;
    }
    
    /* Унифицируем стиль логотипа в шапке для браузерного режима */
    .standalone-mode[data-mode="browser"] .header .logo {
        font-size: 1.5rem !important;
        font-weight: 800 !important;
        color: var(--primary-color) !important;
        margin: 0 !important;
        letter-spacing: 1px !important;
        text-align: center !important;
    }
    
    /* Унифицируем стиль контейнера логотипа для браузерного режима */
    .standalone-mode[data-mode="browser"] .header .logo-container {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    /* Унифицируем стиль логотипа в шапке только для PWA режима */
    .standalone-mode[data-mode="pwa"] .header .logo {
        font-size: 1.5rem !important;
        font-weight: 800 !important;
        color: var(--primary-color) !important;
        margin: 0 !important;
        letter-spacing: 1px !important;
        text-align: center !important;
    }
    
    /* Унифицируем стиль контейнера логотипа только для PWA режима */
    .standalone-mode[data-mode="pwa"] .header .logo-container {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    /* Переопределяем стили шапки только для PWA режима */
    .standalone-mode[data-mode="pwa"] .header h1,
    .standalone-mode[data-mode="pwa"] .header h2,
    .standalone-mode[data-mode="pwa"] .header h3 {
        font-size: 1.5rem !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Добавляем отступ для контента в PWA режиме, чтобы он не перекрывался с фиксированной шапкой */
    .standalone-mode[data-mode="pwa"] main {
        margin-top: 80px;
    }
    
    /* Специальные стили для страниц словаря и статей в PWA режиме */
    
    /* Прямое исправление для контейнеров статей и словаря в PWA режиме */
    .standalone-mode[data-mode="pwa"].article-page .container:not(.header .container) {
        padding-top: 70px !important;
    }
    
    .standalone-mode[data-mode="pwa"].dictionary-page .container:not(.header .container) {
        padding-top: 70px !important;
    }
    
    /* Стили для контейнеров в браузерном режиме */
    .standalone-mode[data-mode="browser"].article-page .container:not(.header .container) {
        padding-top: 60px !important;
        width: 100% !important;
        max-width: 800px !important;
        margin: 0 auto !important;
    }
    
    .standalone-mode[data-mode="browser"].dictionary-page .container:not(.header .container) {
        padding-top: 60px !important;
        width: 100% !important;
        max-width: 800px !important;
        margin: 0 auto !important;
    }
    
    /* Дополнительные стили для конкретных контейнеров */
    .standalone-mode[data-mode="pwa"].article-page .article-container {
        padding-top: 10px !important;
    }
    
    .standalone-mode[data-mode="pwa"].dictionary-page .dictionary-container {
        padding-top: 10px !important;
    }
    
    /* Отступ для контента в браузерной версии */
    .standalone-mode[data-mode="browser"] main {
        margin-top: 20px;
        width: 100%;
        min-height: calc(100vh - 80px);
    }
    
    .install-banner {
        padding-bottom: max(env(safe-area-inset-bottom), 12px);
        padding-left: max(env(safe-area-inset-left), 16px);
        padding-right: max(env(safe-area-inset-right), 16px);
    }
}

/* Стили для полноэкранного режима только в PWA */
.standalone-mode[data-mode="pwa"] .call-controls {
    padding-bottom: max(env(safe-area-inset-bottom), 25px);
}

/* Стили навигации для разных режимов */

/* Большие кнопки навигации только для PWA режима */
.standalone-mode[data-mode="pwa"] .bottom-nav {
    height: 70px;
    padding-bottom: max(env(safe-area-inset-bottom), 15px);
}

.standalone-mode[data-mode="pwa"] .nav-icon {
    font-size: 1.8rem;
    margin-bottom: 5px;
}

.standalone-mode[data-mode="pwa"] .nav-item {
    padding: 8px 0;
}

/* Меньшие кнопки навигации для браузерной версии */
.standalone-mode[data-mode="browser"] .bottom-nav {
    height: 50px;
    padding-bottom: 5px;
}

.standalone-mode[data-mode="browser"] .nav-icon {
    font-size: 1.4rem;
    margin-bottom: 3px;
}

.standalone-mode[data-mode="browser"] .nav-item {
    padding: 5px 0;
}

/* Базовые стили для всех режимов */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    background-color: var(--dark-bg);
}

/* Стили для PWA режима */
@media all and (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
    /* Дополнительные стили только для PWA режима, если необходимо */
    
    /* Скрываем адресную строку и навигацию Safari */
    body {
        -webkit-touch-callout: none;
        -webkit-overflow-scrolling: touch;
    }
}

/* Дополнительные стили для полноэкранного режима */
.browser-chrome, .browser-controls, .browser-ui {
    display: none !important;
}

/* Специальные стили для iOS */
@supports (-webkit-overflow-scrolling: touch) {
    body {
        -webkit-overflow-scrolling: touch;
        -webkit-tap-highlight-color: transparent;
    }
}
