/* style.css - v6.0 (Mobile Scroll Fixed) */

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --bg-body: #f3f4f6;
    --bg-card: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --danger: #ef4444;
    --success: #10b981;
    --sidebar-w: 250px;
    --bottom-h: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    margin: 0;
}

/* --- LOGIN PAGE --- */
body.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.login-container {
    background: white;
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.input-group { margin-bottom: 1rem; text-align: left; }
.input-group label { display: block; margin-bottom: 0.5rem; font-weight: 600; font-size: 0.9rem; }
.input-group input, .input-group select { 
    width: 100%; padding: 12px; 
    border: 1px solid #d1d5db; border-radius: 8px; font-size: 1rem; background: #fff;
}

.btn-primary { 
    width: 100%; padding: 12px; background: var(--primary); color: white; 
    border: none; border-radius: 8px; font-weight: 600; cursor: pointer; font-size: 1rem; 
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-demo { 
    width: 100%; padding: 10px; background: #fff; border: 2px solid #e5e7eb; 
    border-radius: 8px; cursor: pointer; margin-top: 10px; font-weight: 600; color: #374151; 
}

.lang-switcher { position: absolute; top: 20px; right: 20px; z-index: 50; }
.lang-switcher button { border: 1px solid #ddd; background: white; padding: 5px 10px; margin-left: 5px; border-radius: 4px; cursor: pointer; }

/* --- APP LAYOUT --- */
.app-layout {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-w);
    background: white;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    z-index: 90;
    flex-shrink: 0;
}

.logo-area { font-size: 1.25rem; font-weight: bold; margin-bottom: 2rem; color: var(--primary); display: flex; align-items: center; gap: 10px; }
.nav-links { list-style: none; flex: 1; overflow-y: auto; }
.nav-item { 
    display: flex; align-items: center; padding: 12px 15px; 
    color: var(--text-muted); text-decoration: none; border-radius: 8px; margin-bottom: 5px; 
    transition: 0.2s; font-weight: 500; cursor: pointer; 
}
.nav-item:hover, .nav-item.active { background-color: #eff6ff; color: var(--primary); }
.nav-icon { margin-right: 12px; font-size: 1.2rem; }

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 90px;
    -webkit-overflow-scrolling: touch;
}

.mobile-header { 
    display: none; background: white; padding: 15px; 
    border-bottom: 1px solid #eee; justify-content: space-between; align-items: center; 
    position: sticky; top: 0; z-index: 50;
}
.mobile-header h1 { margin: 0; font-size: 1.2rem; }

/* =========================================
   3. МОДАЛЬНЫЕ ОКНА (FIXED)
   ========================================= */
.modal-overlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0,0,0,0.6); 
    display: none; 
    justify-content: center; 
    align-items: center; 
    z-index: 2000;
    backdrop-filter: blur(2px);
}

.modal-box { 
    background: white; 
    padding: 2rem; 
    border-radius: 12px; 
    width: 90%; 
    max-width: 500px; 
    position: relative;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    
    /* Скролл для десктопа */
    max-height: 85vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.close-modal { 
    position: absolute; 
    top: 15px; 
    right: 20px; 
    font-size: 2rem; 
    cursor: pointer; 
    color: #999;
    line-height: 1;
    z-index: 10;
}

.help-command { background: #f0fdf4; padding: 4px 8px; border-radius: 4px; font-family: monospace; color: #166534; white-space: nowrap; }

/* =========================================
   4. КОМПОНЕНТЫ
   ========================================= */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 15px; margin-bottom: 20px; }
.card { background: white; padding: 1.5rem; border-radius: 10px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.section-title { font-size: 1.1rem; font-weight: bold; margin-bottom: 15px; border-bottom: 1px solid #eee; padding-bottom: 5px; color: var(--primary); }
.balance-val { font-size: 1.8rem; font-weight: bold; margin: 10px 0; color: #111; }
.btn-del-cat { color: var(--danger); cursor: pointer; font-weight: bold; padding: 5px 10px; }
.invite-box { background: #f0fdf4; padding: 10px; border-radius: 6px; border: 1px solid #bbf7d0; word-break: break-all; font-family: monospace; font-size: 0.85rem; color: #166534; cursor: pointer; }

/* =========================================
   5. АДАПТИВ МОБИЛЬНЫЙ (ИСПРАВЛЕНО)
   ========================================= */
@media (max-width: 768px) {
    .app-layout { flex-direction: column; }
    
    /* Меню вниз */
    .sidebar { 
        position: fixed; bottom: 0; left: 0; width: 100%; height: var(--bottom-h); 
        flex-direction: row; padding: 0; border-top: 1px solid #eee; border-right: none; 
        justify-content: space-around; align-items: center;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    }
    
    .logo-area { display: none; }
    .mobile-header { display: flex; }
    
/*    .nav-links { display: flex; width: 100%; justify-content: space-around; padding: 0; overflow: visible; }
    .nav-item { flex-direction: column; font-size: 0.7rem; padding: 8px 0; margin: 0; flex: 1; justify-content: center; border-radius: 0; }
    .nav-icon { margin-right: 0; margin-bottom: 4px; font-size: 1.4rem; }*/
    .nav-text { display: block; font-size: 0.7rem; }

 .nav-links { 
        display: flex; 
        width: 100%; 
        padding: 0;
        /* ДОБАВЛЕНО: Скролл, если иконок много */
        overflow-x: auto; 
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start; /* Чтобы не растягивались */
    }
    
    .nav-item { 
        flex-direction: column; 
        font-size: 0.65rem; /* Чуть меньше шрифт */
        padding: 8px 0; 
        margin: 0; 
        /* ДОБАВЛЕНО: Мин ширина, чтобы пальцем попасть */
        min-width: 65px; 
        flex: 0 0 auto; /* Не сжиматься */
        justify-content: center; 
    }
    
    .nav-icon { margin-right: 0; margin-bottom: 4px; font-size: 1.3rem; }
    
    /* Скрываем скроллбар для красоты */
    .nav-links::-webkit-scrollbar { display: none; }
}

    
    /* --- FIX MODAL MOBILE --- */
    .modal-overlay {
        align-items: flex-end; /* Окно выезжает снизу или занимает низ */
    }
    
    .modal-box {
        width: 100%;
        height: 100%;        /* На весь экран */
        max-height: 100%;    /* Отключаем ограничение */
        border-radius: 0;    /* Убираем скругления */
        padding: 20px;
        padding-top: 60px;   /* Отступ сверху для кнопки закрыть */
        overflow-y: scroll;  /* Жесткий скролл */
        -webkit-overflow-scrolling: touch;
    }
    
    .close-modal {
        position: fixed; /* Фиксируем крестик, чтобы не улетал при скролле */
        top: 15px;
        right: 20px;
        background: rgba(255,255,255,0.9);
        padding: 5px;
        border-radius: 50%;
        width: 40px;
        height: 40px;
        text-align: center;
        line-height: 30px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        z-index: 20;
    }
}

/* RTL */
[dir="rtl"] .sidebar { border-right: none; border-left: 1px solid #e5e7eb; }
[dir="rtl"] .nav-icon { margin-right: 0; margin-left: 12px; }
[dir="rtl"] .mobile-header { flex-direction: row-reverse; }
[dir="rtl"] .close-modal { right: auto; left: 20px; }
[dir="rtl"] .input-group { text-align: right; }
[dir="rtl"] .tx-row { direction: rtl; }

   /* --- BUDGETS --- */
.budget-item { background: white; padding: 15px; border-radius: 12px; margin-bottom: 15px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.budget-header { display: flex; justify-content: space-between; margin-bottom: 8px; font-weight: 600; }
.budget-nums { display: flex; justify-content: space-between; font-size: 0.85rem; color: #666; margin-bottom: 5px; }

.progress-bg { width: 100%; height: 10px; background: #e5e7eb; border-radius: 5px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 5px; transition: width 0.5s ease; }

/* Цвета прогресса */
.prog-green { background: #10b981; }
.prog-yellow { background: #f59e0b; }
.prog-red { background: #ef4444; }

.btn-set-limit { font-size: 0.8rem; color: var(--primary); background: none; border: 1px solid #e5e7eb; padding: 2px 8px; border-radius: 4px; cursor: pointer; }
.progress-fill { min-width: 2px; }


   /* --- PRO MODAL STYLES --- */
.pro-header { text-align: center; margin-bottom: 20px; }
.pro-title { font-size: 1.5rem; font-weight: bold; color: #d97706; margin-bottom: 5px; }
.pro-price { font-size: 2rem; font-weight: 800; color: #1f2937; }
.pro-period { font-size: 0.9rem; color: #6b7280; font-weight: normal; }

/* Таблица сравнения */
.compare-box { background: #f9fafb; border-radius: 8px; padding: 15px; margin-bottom: 20px; border: 1px solid #e5e7eb; }
.compare-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #eee; font-size: 0.9rem; }
.compare-row:last-child { border-bottom: none; }

.comp-feature { flex: 1; text-align: left; font-weight: 500; color: #374151; }
.comp-free { color: #9ca3af; font-size: 0.8rem; text-align: right; width: 80px; }
.comp-pro { color: #d97706; font-weight: bold; text-align: right; width: 80px; }

/* Иконки */
.icon-check { color: #10b981; margin-right: 4px; }
.icon-lock { color: #ef4444; margin-right: 4px; font-size: 0.8rem; }

/* Кнопка покупки */
.btn-buy { 
    display: block; width: 100%; text-align: center; text-decoration: none;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white; padding: 15px; border-radius: 8px; font-weight: bold; font-size: 1.1rem;
    box-shadow: 0 4px 10px rgba(217, 119, 6, 0.3); transition: transform 0.2s;
}
.btn-buy:active { transform: scale(0.98); }
