/* --- 1. RESET & VARIABLES --- */
:root {
    /* Цвета Telegram (с фоллбэками для браузера) */
    --bg-color: var(--tg-theme-bg-color, #1c1c1e);
    --text-color: var(--tg-theme-text-color, #ffffff);
    --hint-color: var(--tg-theme-hint-color, #9e9e9e);
    --link-color: var(--tg-theme-link-color, #2481cc);
    --button-color: var(--tg-theme-button-color, #2481cc);
    --button-text-color: var(--tg-theme-button-text-color, #ffffff);
    --secondary-bg-color: var(--tg-theme-secondary-bg-color, #2c2c2e);
    
    /* Свои цвета интерфейса */
    --accent-color: #007aff; /* iOS Blue */
    --success-color: #34c759;
    --danger-color: #ff3b30;
    --card-radius: 16px;
    --spacing: 16px;
    
    /* Шрифт */
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* Убираем синий блик при нажатии на Android */
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden; /* Чтобы скроллилось только внутри контейнеров */
    height: 100vh;
    width: 100vw;
}

/* --- 2. LAYOUT & VIEWS --- */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.3s ease;
    z-index: 10;
}

/* Скрываем неактивные экраны */
.view.hidden-view {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.95);
    z-index: 0;
}

.view.active-view {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
    z-index: 10;
}

/* Область прокрутки */
.scroll-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing);
    padding-bottom: 100px; /* Чтобы контент не перекрывался таббаром */
    -webkit-overflow-scrolling: touch;
}

/* Скрываем скроллбар, но оставляем прокрутку */
.scroll-content::-webkit-scrollbar {
    display: none;
}

/* --- 3. HEADER --- */
.app-header {
    padding: var(--spacing);
    padding-top: 20px;
    background-color: var(--bg-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 20;
    /* Размытие фона как в iOS */
    backdrop-filter: blur(10px); 
    -webkit-backdrop-filter: blur(10px);
}

.page-title {
    font-size: 28px;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.5px;
}

.date-subtitle {
    margin: 4px 0 0 0;
    color: var(--hint-color);
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--link-color);
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
}

/* --- 4. CARDS (CATEGORIES & TASKS) --- */
.card {
    background-color: var(--secondary-bg-color);
    border-radius: var(--card-radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    transition: transform 0.2s, background-color 0.2s;
    position: relative;
    overflow: hidden;
}

.card:active {
    transform: scale(0.98);
    background-color: rgba(255, 255, 255, 0.05);
}

.card h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
}

.card p {
    margin: 0;
    color: var(--hint-color);
    font-size: 13px;
}

/* Прогресс бар */
.progress-container {
    height: 4px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin-top: 12px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background-color: var(--accent-color);
    border-radius: 2px;
    transition: width 0.5s ease;
}

/* Стили задачи */
.task-item {
    background-color: var(--secondary-bg-color);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.task-content {
    display: flex;
    flex-direction: column;
}

.task-name {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 4px;
}

.task-deadline {
    font-size: 12px;
    color: var(--hint-color);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Чекбокс */
input[type="checkbox"] {
    width: 24px;
    height: 24px;
    accent-color: var(--success-color);
    cursor: pointer;
}

.task-item.done .task-name {
    text-decoration: line-through;
    color: var(--hint-color);
}

/* --- 5. STATISTICS (UPDATED) --- */
.stats-grid {
    display: flex;
    flex-direction: column; /* Блоки друг под другом */
    gap: 16px;
}

/* Строка для мелких карточек (Firefighter и Скорость) */
.stat-row {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Две колонки одинаковой ширины */
    gap: 16px;
}

.full-width {
    width: 100%;
}

.stat-card {
    background: var(--secondary-bg-color);
    border-radius: var(--card-radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    /* Тень для объема */
    box-shadow: 0 4px 20px rgba(0,0,0,0.1); 
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.card-header i {
    font-size: 22px;
    /* Подложка под иконку */
    background: rgba(255, 255, 255, 0.1);
    padding: 8px;
    border-radius: 8px;
}

.card-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

/* Крупные цифры */
.stat-value {
    font-size: 28px;
    font-weight: 800;
    margin-top: auto;
    letter-spacing: -1px;
}

.stat-label {
    font-size: 13px;
    color: var(--hint-color);
    font-weight: 500;
    margin-top: 4px;
}

.chart-wrapper {
    height: 180px; /* Чуть выше для наглядности */
    width: 100%;
    position: relative;
}

/* Специальный стиль для маленьких карточек */
.stat-card.mini {
    padding: 16px;
}

.stat-card.mini i {
    font-size: 24px;
    margin-bottom: 8px;
}

/* --- 6. BOTTOM NAVIGATION (TAB BAR) --- */
.bottom-tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80px; /* Высота под пальцы */
    background-color: var(--secondary-bg-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-bottom: 20px; /* Учет полоски iOS */
    border-top: 1px solid rgba(255,255,255,0.05);
    z-index: 50;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--hint-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    cursor: pointer;
    width: 60px;
}

.tab-btn i {
    font-size: 24px;
    transition: transform 0.2s;
}

.tab-btn.active {
    color: var(--link-color);
}

.tab-btn.active i {
    transform: translateY(-2px);
}

.fab-placeholder {
    width: 56px; /* Место под кнопку */
}

/* --- 7. FLOATING ACTION BUTTON (FAB) --- */
.fab-main {
    position: fixed;
    bottom: 45px; /* Чуть выше таббара */
    left: 50%;
    transform: translateX(-50%);
    width: 56px;
    height: 56px;
    border-radius: 28px;
    background-color: var(--link-color);
    color: white;
    border: none;
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(36, 129, 204, 0.4);
    z-index: 60;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.fab-main:active {
    transform: translateX(-50%) scale(0.9);
    box-shadow: 0 2px 8px rgba(36, 129, 204, 0.2);
}

/* --- 8. BOTTOM SHEETS (MODALS) --- */
.overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(2px);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--secondary-bg-color);
    border-radius: 20px 20px 0 0;
    padding: 24px;
    padding-bottom: 40px;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.bottom-sheet.active {
    transform: translateY(0);
}

.sheet-handle {
    width: 40px;
    height: 4px;
    background-color: rgba(255,255,255,0.2);
    border-radius: 2px;
    align-self: center;
    margin-bottom: 8px;
}

.bottom-sheet h3 {
    margin: 0;
    text-align: center;
    font-size: 20px;
}

/* --- 9. INPUTS & BUTTONS --- */
.input-group {
    background-color: rgba(0,0,0,0.2);
    border-radius: 12px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 50px;
}

.input-group i {
    color: var(--hint-color);
    font-size: 20px;
}

.input-group input {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 16px;
    width: 100%;
    height: 100%;
    outline: none;
    font-family: var(--font-main);
}

.primary-btn {
    background-color: var(--link-color);
    color: white;
    border: none;
    height: 50px;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}

.delete-btn {
    font-size: 20px;
    padding: 8px;
    color: var(--danger-color);
    opacity: 0.7;
}

/* --- 10. UTILITIES --- */
.hidden { display: none !important; }

/* Loader */
.loader-container {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s;
}

.spinner {
    width: 40px; height: 40px;
    border: 4px solid rgba(255,255,255,0.1);
    border-top-color: var(--link-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.hidden-opacity { opacity: 0; } /* Для плавного появления при старте */

/* Горящая задача */
.urgent-glow {
    border: 1px solid var(--danger-color);
    box-shadow: 0 0 15px rgba(255, 59, 48, 0.2);
}
