/* --- ОБЩИЕ УЛУЧШЕНИЯ --- */
body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    /* Легкий фиолетовый отсвет на фоне */
    background-image: radial-gradient(circle at top right, #2a1a35 0%, #121212 40%); 
}

/* --- ШАПКА (GLOBAL) --- */
.header {
    background: rgba(18, 18, 18, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 800;
}

.logo-icon { font-size: 24px; }
.logo .accent { color: var(--primary); }

.balance-badge {
    background: rgba(187, 134, 252, 0.15);
    color: var(--primary);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid rgba(187, 134, 252, 0.3);
}

/* --- КОНТЕНТ --- */
.content {
    padding: var(--container-padding);
    max-width: 600px;
    margin: 0 auto;
    padding-bottom: 140px; 
}

/* --- ПЛАВАЮЩЕЕ МЕНЮ (GLOBAL NAV) --- */
.bottom-nav-floating {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    background: rgba(30, 30, 30, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 24px;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 1000;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-grey);
    font-size: 10px;
    padding: 8px 16px;
    border-radius: 16px;
    transition: all 0.2s;
}

.nav-icon {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
    stroke-width: 1.5;
}

.nav-item.active {
    color: var(--primary);
    background: rgba(187, 134, 252, 0.1);
}

.nav-item.active .nav-icon {
    stroke-width: 2.5;
    transform: scale(1.1);
}

/* Скрываем старое меню */
.bottom-nav { display: none; }

/* --- ЭЛЕМЕНТЫ UI (Кнопки, Формы, Списки) --- */
.list-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.back-btn {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-grey);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
}

.primary-btn {
    width: 100%;
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 16px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 16px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(142, 45, 226, 0.4);
    transition: transform 0.1s;
}
.primary-btn:active { transform: scale(0.98); }

/* Input & Select */
.app-select, .app-input {
    width: 100%;
    background: var(--bg-main);
    color: white;
    border: 1px solid var(--glass-border);
    padding: 12px;
    border-radius: 12px;
    font-size: 16px;
    outline: none;
    appearance: none;
}
.app-select:focus, .app-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(187, 134, 252, 0.2);
    background-color: #2a2a2a;
}
.form-group label {
    display: block;
    color: var(--text-grey);
    font-size: 12px;
    margin-bottom: 6px;
    padding-left: 4px;
}
.form-group { margin-bottom: 16px; }

/* --- ПОИСК (SEARCH) --- */
.search-wrapper { position: relative; margin-bottom: 24px; z-index: 100; }
.search-input-box {
    position: relative; display: flex; align-items: center;
    background: var(--bg-card); border: 1px solid var(--glass-border);
    border-radius: 12px; padding: 0 12px; transition: border-color 0.2s;
}
.search-input-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(187, 134, 252, 0.1);
}
.search-icon { width: 20px; height: 20px; color: var(--text-grey); margin-right: 8px; }
#global-search-input {
    width: 100%; background: transparent; border: none;
    color: white; padding: 14px 0; font-size: 16px; outline: none;
}
.search-dropdown {
    position: absolute; top: 100%; left: 0; right: 0;
    background: #1e1e1e; border: 1px solid #333; border-radius: 12px;
    margin-top: 8px; max-height: 300px; overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.search-item { padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.05); cursor: pointer; }
.search-item:hover { background: rgba(255,255,255,0.05); }
.search-item-title { font-weight: bold; color: white; }
.search-item-subtitle { font-size: 12px; color: var(--text-grey); margin-top: 2px; }

/* --- КАТАЛОГ И СПИСКИ --- */
.brand-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.brand-card {
    background-color: white; border-radius: 16px; aspect-ratio: 1 / 1;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: transform 0.1s;
}
.brand-card:active { transform: scale(0.95); }
.brand-card img { width: 60%; height: auto; object-fit: contain; pointer-events: none; }

.gen-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding-bottom: 20px; }
.gen-card {
    position: relative; background: var(--bg-card); border-radius: 16px;
    overflow: hidden; aspect-ratio: 4 / 3; border: 1px solid var(--glass-border);
    cursor: pointer; transition: transform 0.1s;
}
.gen-card:active { transform: scale(0.96); }
.gen-card img { width: 100%; height: 100%; object-fit: cover; }
.gen-card-overlay {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9), rgba(0,0,0,0));
    padding: 12px 8px; padding-top: 30px; display: flex; flex-direction: column; justify-content: flex-end;
}
.gen-card-title { font-size: 14px; font-weight: bold; color: white; margin-bottom: 2px; text-shadow: 0 1px 3px rgba(0,0,0,0.8); }
.gen-card-years { font-size: 12px; color: #ccc; font-weight: 500; }

.models-list { background: var(--bg-card); border-radius: 16px; overflow: hidden; }
.list-item {
    padding: 16px; border-bottom: 1px solid var(--glass-border);
    display: flex; justify-content: space-between; align-items: center;
    cursor: pointer; transition: background 0.2s;
}
.list-item:active { background: var(--glass-bg); }

/* --- ИСТОРИЯ --- */
.history-card {
    background: var(--bg-card); border-radius: 12px; padding: 16px;
    margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center;
    border: 1px solid var(--glass-border); cursor: pointer; transition: background 0.2s;
}
.history-card:active { background: var(--glass-bg); }
.hist-name { font-weight: bold; font-size: 15px; color: white; margin-bottom: 4px; }
.hist-date { font-size: 12px; color: var(--text-grey); }
.hist-score {
    width: 40px; height: 40px; border-radius: 50%; border: 3px solid;
    display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 14px;
}

/* --- LOADERS --- */
.spinner {
    width: 16px; height: 16px; border: 2px solid var(--text-grey);
    border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.story-loader-container {
    background: var(--bg-card); border: 1px solid var(--primary);
    border-radius: 12px; padding: 20px; text-align: center;
    box-shadow: 0 0 15px rgba(187, 134, 252, 0.1); animation: fadeIn 0.3s ease-out;
}
.story-icon { font-size: 32px; margin-bottom: 12px; display: inline-block; animation: bounce 1s infinite; }
.story-text { font-size: 16px; font-weight: bold; color: white; margin-bottom: 4px; min-height: 24px; }
.story-subtext { font-size: 12px; color: var(--text-grey); }
.progress-bar { height: 4px; background: #333; border-radius: 2px; margin-top: 16px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); width: 0%; transition: width 0.3s linear; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

/* --- БАННЕР RUSTORE (Вставка в Историю) --- */
.app-promo-banner {
    background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
    border: 1px solid #333;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px; /* Отступ до заголовка "Мои отчеты" */
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.promo-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.promo-icon {
    font-size: 24px;
    background: #333;
    width: 42px; 
    height: 42px;
    display: flex; 
    align-items: center; 
    justify-content: center;
    border-radius: 10px;
}

.promo-text h3 {
    margin: 0 0 2px 0;
    font-size: 15px;
    color: white;
}

.promo-text p {
    margin: 0;
    font-size: 12px;
    color: #aaa;
}

.promo-btn {
    display: block;
    background: #0077FF; /* Фирменный синий цвет RuStore */
    color: white;
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    transition: opacity 0.2s;
}

.promo-btn:hover {
    opacity: 0.9;
}


/* --- МОДАЛЬНОЕ ОКНО ОПЛАТЫ (Dark Theme) --- */
.payment-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8); /* Темное затемнение */
    backdrop-filter: blur(5px); /* Размытие фона сайта */
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    box-sizing: border-box;
    animation: fadeIn 0.3s ease-out;
}

.payment-modal-content {
    background: #1e1e1e; /* Темный фон окна */
    width: 100%;
    max-width: 550px; /* Чуть шире для удобства */
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    border: 1px solid #333; /* Тонкая рамка */
    display: flex;
    flex-direction: column;
    animation: zoomIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28); /* Пружинистая анимация */
}

.payment-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    background: #252525; /* Чуть светлее фона контента */
    border-bottom: 1px solid #333;
    color: #fff;
    font-size: 18px;
    font-weight: 600;
}

#close-payment-btn {
    background: transparent;
    border: none;
    color: #aaa;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: color 0.2s;
}

#close-payment-btn:hover {
    color: #fff;
}

/* Контейнер виджета должен совпадать по цвету с фоном виджета */
#yookassa-form-container {
    width: 100%;
    min-height: 450px;
    background: #1e1e1e; /* ВАЖНО: Цвет совпадает с background в JS */
}

@keyframes zoomIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- СТИЛИ МОДАЛЬНОГО ОКНА СОГЛАШЕНИЯ --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); backdrop-filter: blur(5px);
    z-index: 10000;
    display: flex; justify-content: center; align-items: flex-end; /* Снизу на мобилке */
}

@media (min-width: 768px) {
    .modal-overlay { align-items: center; }
    .bottom-nav-floating {width: 90%; bottom: 10px; padding: 8px 8px;} 
    
}


.modal-content-scrollable {
    background: #1e1e1e;
    width: 100%; max-width: 600px;
    height: 85vh; /* Почти на весь экран */
    border-radius: 20px 20px 0 0;
    display: flex; flex-direction: column;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
    animation: slideUp 0.3s ease-out;
}

@media (min-width: 768px) {
    .modal-content-scrollable {
        height: 70vh; border-radius: 20px;
        animation: zoomIn 0.3s ease-out;
    }
}

.modal-header {
    padding: 16px 20px; border-bottom: 1px solid #333;
    display: flex; justify-content: space-between; align-items: center;
}
.modal-header h2 { margin: 0; font-size: 18px; color: white; }

.legal-text {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    color: #ccc;
    font-size: 14px;
    line-height: 1.6;
}
.legal-text h3 { color: white; margin-top: 20px; margin-bottom: 10px; font-size: 16px; }
.legal-text p { margin-bottom: 10px; }

.modal-footer-btn {
    padding: 16px; border-top: 1px solid #333;
}

.text-link-btn {
    background: none; border: none;
    color: #777; text-decoration: underline;
    font-size: 12px; cursor: pointer; padding: 5px;
}
.text-link-btn:hover { color: #aaa; }

@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
/* --- МОБИЛЬНЫЕ ПРАВКИ (UX) --- */
@media (max-width: 600px) {
    .bottom-nav-floating {
        bottom: 10px;
        width: 75%; /* Делаем уже */
        border-radius: 19px;
        padding: 0px 1px; /* Как ты просил */
        transition: transform 0.3s ease-in-out, opacity 0.3s;
    }
}

/* Класс для скрытия меню при клавиатуре */
.nav-hidden {
    transform: translateY(150%); /* Уезжает вниз */
    opacity: 0;
    pointer-events: none;
}

/* Стили для ссылки соглашения под кнопкой */
.agreement-note {
    font-size: 11px;
    color: #666;
    text-align: center;
    margin-top: 12px;
    line-height: 1.4;
}

.agreement-link {
    color: #888;
    text-decoration: underline;
    cursor: pointer;
    transition: color 0.2s;
}

.agreement-link:hover {
    color: var(--primary);
}
