/* ===== Mobile Bottom Navigation ===== */
/* Подключить к любой странице для Android-стиля навигации */
/* Совместим с существующими стилями проекта (style.css, pay.css) */

:root {
    --nav-height: 64px;
    --nav-safe-area: env(safe-area-inset-bottom, 0px);
    --nav-primary: #253081; /* Цвет из style.css */
    --nav-primary-light: #515a98;
    --nav-primary-container: #e7e9f3;
    --nav-surface: #ffffff;
    --nav-on-surface: #1c1b1f;
    --nav-on-surface-variant: #49454f;
}

/* Отступ снизу для контента */
body.has-bottom-nav {
    padding-bottom: calc(var(--nav-height) + var(--nav-safe-area) + 8px) !important;
}

/* ===== Bottom Navigation Bar ===== */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-height) + var(--nav-safe-area));
    background: var(--nav-surface);
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    padding-top: 8px;
    padding-bottom: var(--nav-safe-area);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    border-top: 1px solid #e5e7eb;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4px 0;
    cursor: pointer;
    position: relative;
    text-decoration: none !important;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s ease;
}

/* Pill background для активного состояния */
.mobile-nav-item::before {
    content: '';
    position: absolute;
    top: 0;
    width: 56px;
    height: 32px;
    background: transparent;
    border-radius: 16px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-nav-item.active::before {
    background: #e7e9f3;
}

/* Иконка */
.mobile-nav-icon {
    width: 24px;
    height: 24px;
    position: relative;
    z-index: 1;
    transition: all 0.2s ease;
}

.mobile-nav-icon svg {
    width: 24px;
    height: 24px;
    fill: #5f6368;
    stroke: #5f6368;
    transition: fill 0.2s ease, stroke 0.2s ease;
}

.mobile-nav-item.active .mobile-nav-icon svg {
    fill: #253081;
    stroke: #253081;
}

/* Подпись */
.mobile-nav-label {
    font-size: 12px;
    font-weight: 500;
    color: #5f6368;
    margin-top: 4px;
    position: relative;
    z-index: 1;
    transition: all 0.2s ease;
    text-decoration: none !important;
}

.mobile-nav-item.active .mobile-nav-label {
    color: #253081;
}

/* Ripple при нажатии */
.mobile-nav-item:active::before {
    transform: scale(1.1);
    background: #e7e9f3;
}

/* ===== Auth Modal (Bottom Sheet) ===== */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: none;
    align-items: flex-end;
    justify-content: center;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.auth-overlay.show {
    display: flex;
}

.auth-sheet {
    background: #fff;
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-overflow-scrolling: touch;
}

.auth-overlay.show .auth-sheet {
    transform: translateY(0);
}

.auth-sheet-handle {
    width: 32px;
    height: 4px;
    background: #cbd5e0;
    border-radius: 2px;
    margin: 12px auto;
}

.auth-sheet-content {
    padding: 8px 24px 32px;
}

.auth-sheet-title {
    font-size: 24px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 24px;
    color: #253081;
}

/* Auth Tabs */
.auth-tabs {
    display: flex;
    margin-bottom: 24px;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 4px;
    border: 1px solid #e9ecef;
}

.auth-tab-btn {
    flex: 1;
    padding: 12px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    color: #6c757d;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-tab-btn.active {
    background: #fff;
    color: var(--nav-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Auth Forms */
.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-input-field {
    margin-bottom: 16px;
}

.auth-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #495057;
    margin-bottom: 6px;
}

.auth-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    background: #fff;
    color: #495057;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    outline: none;
    box-sizing: border-box;
}

.auth-input:focus {
    border-color: var(--nav-primary);
    box-shadow: 0 0 0 3px rgba(37, 48, 129, 0.1);
}

.auth-input::placeholder {
    color: #adb5bd;
}

/* Auth Buttons */
.auth-btn {
    display: block;
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 500;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
    box-sizing: border-box;
}

.auth-btn-primary {
    background: var(--nav-primary);
    color: #fff;
}

.auth-btn-primary:hover {
    background: var(--nav-primary-light);
}

.auth-btn-primary:active {
    transform: scale(0.98);
}

.auth-btn-secondary {
    background: transparent;
    color: #6c757d;
    border: 1px solid #ced4da;
    margin-top: 12px;
}

.auth-btn-secondary:hover {
    background: #f8f9fa;
}

/* Auth Messages */
.auth-message {
    padding: 12px 16px;
    border-radius: 0.25rem;
    font-size: 14px;
    margin-bottom: 16px;
    display: none;
}

.auth-message.show {
    display: block;
}

.auth-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.auth-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Auth Links */
.auth-forgot-link,
.auth-back-link {
    text-align: center;
    margin-top: 16px;
}

.auth-forgot-link a,
.auth-back-link a {
    color: var(--nav-primary);
    text-decoration: none;
    font-size: 14px;
}

.auth-forgot-link a:hover,
.auth-back-link a:hover {
    text-decoration: underline;
}

.auth-form-description {
    font-size: 14px;
    color: #666;
    margin-bottom: 20px;
    line-height: 1.5;
}

/* ===== Snackbar ===== */
.mobile-snackbar {
    position: fixed;
    bottom: calc(var(--nav-height) + var(--nav-safe-area) + 16px);
    left: 16px;
    right: 16px;
    background: #323232;
    color: #fff;
    padding: 14px 16px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 10001;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.mobile-snackbar.show {
    transform: translateY(0);
    opacity: 1;
}

/* ===== Скрываем на десктопе ===== */
@media (min-width: 769px) {
    .mobile-bottom-nav {
        display: none !important;
    }
    
    body.has-bottom-nav {
        padding-bottom: 0 !important;
    }
}

/* ===== Учитываем purchase-slider из pay.css ===== */
/* Когда открыт слайдер покупки, поднимаем навигацию */
.purchase-slider.show ~ .mobile-bottom-nav,
body:has(.purchase-slider.show) .mobile-bottom-nav {
    z-index: 1030; /* Ниже слайдера (1050) */
}

/* ===== Темная тема ===== */
@media (prefers-color-scheme: dark) {
    .mobile-bottom-nav {
        background: #1a1a1a;
        border-top-color: #333;
    }
    
    .mobile-nav-item::before {
        background: transparent;
    }
    
    .mobile-nav-item.active::before {
        background: rgba(144, 205, 244, 0.15);
    }
    
    .mobile-nav-icon svg {
        fill: #9aa0a6;
        stroke: #9aa0a6;
    }
    
    .mobile-nav-item.active .mobile-nav-icon svg {
        fill: #8ab4f8;
        stroke: #8ab4f8;
    }
    
    .mobile-nav-label {
        color: #9aa0a6;
    }
    
    .mobile-nav-item.active .mobile-nav-label {
        color: #8ab4f8;
    }
    
    .auth-sheet {
        background: #2d2d2d;
    }
    
    .auth-sheet-handle {
        background: #555;
    }
    
    .auth-sheet-title {
        color: #e8eaed;
    }
    
    .auth-tabs {
        background: #3c3c3c;
        border-color: #555;
    }
    
    .auth-tab-btn {
        color: #9aa0a6;
    }
    
    .auth-tab-btn.active {
        background: #2d2d2d;
        color: #8ab4f8;
    }
    
    .auth-label {
        color: #e8eaed;
    }
    
    .auth-input {
        background: #3c3c3c;
        border-color: #555;
        color: #e8eaed;
    }
    
    .auth-input:focus {
        border-color: #8ab4f8;
        box-shadow: 0 0 0 3px rgba(138, 180, 248, 0.2);
    }
    
    .auth-input::placeholder {
        color: #9aa0a6;
    }
    
    .auth-btn-primary {
        background: #8ab4f8;
        color: #1a1a1a;
    }
    
    .auth-btn-primary:hover {
        background: #aecbfa;
    }
    
    .auth-btn-secondary {
        color: #9aa0a6;
        border-color: #555;
    }
    
    .auth-btn-secondary:hover {
        background: #3c3c3c;
    }
    
    .mobile-snackbar {
        background: #3c3c3c;
    }
    
    .auth-forgot-link a,
    .auth-back-link a {
        color: #8ab4f8;
    }
    
    .auth-form-description {
        color: #9aa0a6;
    }
}

/* ===== Оптимизации для Android WebView ===== */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    .mobile-bottom-nav,
    .mobile-nav-item,
    .auth-sheet {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
}
