/* =========================================
   1. БАЗОВЫЕ ПЕРЕМЕННЫЕ И СБРОС
   ========================================= */
   :root {
    --color-primary: #e53935;       /* Основной красный */
    --color-primary-hover: #b71c1c; /* Темно-красный при наведении */
    --color-success: #2e7d32;       /* Зеленый для выполненного */
    --color-bg: #fff5f7;            /* Розоватый фон страницы */
    --color-surface: #ffffff;       /* Белый фон карточек */
    --color-text: #2c1e1e;          /* Основной текст */
    --color-text-light: #7f5f5f;    /* Второстепенный текст */
    --color-border: #ffc1c1;        /* Границы */
    --grid-line-color: #e57373;     /* Цвет линий сетки календаря */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    padding: 20px;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding-bottom: 60px;
}

/* =========================================
   2. ШАПКА (HEADER)
   ========================================= */
.header {
    text-align: center;
    margin-bottom: 35px;
}

.header h1 {
    font-size: 34px;
    margin-bottom: 10px;
    color: var(--color-primary);
    font-weight: 800;
    letter-spacing: -0.5px;
}

.header p {
    color: var(--color-text-light);
    font-size: 16px;
    font-weight: 500;
}

/* Соцсети в шапке */
.social-links {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.social-link {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.25s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.social-link img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.social-link:hover {
    transform: translateY(-3px) scale(1.08);
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

.social-tg { background: #fff; }
.social-tg:hover { background: #e3f2fd; }

.social-fb { background: #fff; }
.social-fb:hover { background: #e8f0fe; }

.social-inst { background: #fff; }
.social-inst:hover { background: #fce4ec; }

.social-vk { background: #fff; }
.social-vk:hover { background: #e3f2fd; }

/* =========================================
   3. ГЛОБАЛЬНАЯ СТАТИСТИКА (КАРТОЧКИ)
   ========================================= */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--color-surface);
    padding: 25px;
    border-radius: 16px;
    border-left: 5px solid var(--color-primary);
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card h3 {
    color: var(--color-text-light);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

.stat-card .value {
    font-size: 32px;
    font-weight: 800;
    color: var(--color-primary);
    line-height: 1;
}

/* Главный прогресс бар (в карточке статистики) */
.progress-bar {
    width: 100%;
    height: 10px;
    background: #ffebee;
    border-radius: 5px;
    margin-top: 15px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), #ff5252);
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 5px;
}

/* =========================================
   4. ЛЕГЕНДА (Крупная)
   ========================================= */
.legend {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 16px;
    font-weight: 600;
    color: #444;
}

.legend-color {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    flex-shrink: 0;
}

.legend-color.incomplete { 
    background: #fff; 
    border: 2px solid var(--color-border); 
}

.legend-color.completed { 
    background: #e8f5e9; 
    border: 2px solid var(--color-success); 
    position: relative; 
}

.legend-color.completed::after { 
    content: '✓'; 
    font-size: 18px; 
    color: var(--color-success); 
    position: absolute; 
    top: 50%; left: 50%; 
    transform: translate(-50%, -50%);
    font-weight: 900; 
}

/* =========================================
   5. НАВИГАЦИЯ ПО ЭТАПАМ
   ========================================= */
.stage-navigation {
    background: var(--color-primary);
    color: #fff;
    border-radius: 16px;
    position: relative;
    margin: 30px 0 40px 0;
    padding: 25px 70px;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(229, 57, 53, 0.3);
    overflow: hidden;
}

/* Декоративный фон для навигации */
.stage-navigation::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%; width: 200%; height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
    pointer-events: none;
}

.stage-content { text-align: center; flex: 1; position: relative; z-index: 2; }
.stage-title { font-size: 22px; font-weight: 800; line-height: 1.2; margin-bottom: 6px; }
.stage-months { font-size: 15px; opacity: 0.9; font-weight: 500; }

.stage-nav-btn {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2); 
    color: #fff; border: none;
    width: 48px; height: 48px; 
    border-radius: 50%;
    font-size: 26px; font-weight: bold; 
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex; align-items: center; justify-content: center;
    z-index: 3;
}

.stage-nav-btn:hover:not(:disabled) { 
    background: rgba(255, 255, 255, 0.35); 
    transform: translateY(-50%) scale(1.1); 
}
.stage-nav-btn:active:not(:disabled) { 
    transform: translateY(-50%) scale(0.95); 
}
.stage-nav-btn[disabled] { 
    opacity: 0.3; cursor: not-allowed; 
}
.stage-nav-btn-left { left: 20px; }
.stage-nav-btn-right { right: 20px; }

/* =========================================
   6. СЕТКА КАЛЕНДАРЯ (КРАСНАЯ)
   ========================================= */
.month-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.month-card {
    background: var(--color-surface);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0,0,0,0.06);
    display: flex; flex-direction: column;
    height: 100%;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.month-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.1);
}

.month-header {
    background: var(--color-primary);
    color: white;
    padding: 18px;
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.5px;
}

/* Сетка с красными линиями */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px; /* Толщина линий */
    background: var(--grid-line-color); /* Цвет линий */
    border: 1px solid var(--grid-line-color);
    border-radius: 8px;
    overflow: hidden;
    margin: 20px 20px 10px 20px;
}

.day-header {
    text-align: center;
    padding: 10px 2px;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    background: #ef5350; /* Чуть светлее основного красного */
    color: white;
}

.day-cell {
    aspect-ratio: 1;
    background: #fff;
    position: relative;
    cursor: pointer;
    transition: background 0.1s;
}

.day-cell:hover { background: rgba(229, 57, 53, 0.08); z-index: 2; }

/* Номер дня */
.day-number {
    font-size: 13px; font-weight: 600; padding: 5px; 
    color: #555; position: absolute; top: 0; right: 0;
}

/* --- СОСТОЯНИЯ ЯЧЕЕК --- */

/* 1. Пустая (вне месяца) */
.day-cell.empty { background: #fff9f9; cursor: default; }
.day-cell.empty:hover { background: #fff9f9; }

/* 2. Сегодня */
.day-cell.today .day-number {
    background: var(--color-primary);
    color: #fff;
    border-radius: 50%;
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    margin: 3px;
    box-shadow: 0 3px 6px rgba(229, 57, 53, 0.4);
}

/* 3. Выполнено */
.day-cell.completed { background: #e8f5e9; }
.day-cell.completed::after {
    content: '✓';
    position: absolute;
    bottom: 5px; right: 8px;
    font-size: 16px;
    font-weight: 900;
    color: var(--color-success);
}

/* 4. Есть контент от админа (оранжевая точка) */
.day-cell.has-admin-content::before {
    content: '';
    position: absolute;
    bottom: 8px; left: 8px;
    width: 8px; height: 8px;
    background: #ff9800;
    border-radius: 50%;
    box-shadow: 0 0 0 2px #fff;
}

/* 5. Недоступный день (вне этапа) */
.day-cell.disabled-day {
    background: #f0f0f0;
    cursor: default;
    opacity: 0.7;
    background-image: repeating-linear-gradient(45deg, transparent, transparent 10px, #e0e0e0 10px, #e0e0e0 11px);
}
.day-cell.disabled-day:hover { background: #f0f0f0; }
.day-cell.disabled-day .day-number { color: #aaa; }

/* Статистика внизу месяца */
.month-progress {
    margin-top: auto;
    padding: 15px 25px 25px 25px;
    font-size: 13px;
    color: var(--color-text-light);
    text-align: center;
    font-weight: 600;
}
.month-progress-bar {
    width: 100%; height: 8px; 
    background: #ffebee; 
    border-radius: 4px; margin-top: 8px; overflow: hidden;
}
.month-progress-fill {
    height: 100%; 
    background: var(--color-success); 
    transition: width 0.3s ease;
}

/* =========================================
   7. ФИНАЛЬНЫЙ ЭКРАН (SINGLE DAY STAGE)
   ========================================= */
.final-stage-card {
    background: #fff;
    border-radius: 24px;
    padding: 60px 30px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.08);
    margin: 40px auto;
    max-width: 600px;
    border: 3px solid #ffcdd2;
    animation: fadeIn 0.5s ease-out;
}

.final-stage-card h2 {
    font-size: 32px;
    color: var(--color-primary);
    margin-bottom: 10px;
}

.final-stage-date {
    font-size: 18px;
    color: var(--color-text-light);
    margin-bottom: 30px;
    font-weight: 500;
}

/* =========================================
   8. ПОПАП (User Day)
   ========================================= */
.user-popup-overlay {
    position: fixed; z-index: 2000;
    left: 0; top: 0; bottom: 0; right: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s ease;
}

.user-popup-overlay.active {
    opacity: 1; pointer-events: all;
}

.user-popup {
    background: #fff;
    width: 650px; max-width: 95vw;
    height: 85vh; max-height: 900px;
    border-radius: 24px;
    box-shadow: 0 30px 60px rgba(0,0,0,0.3);
    position: relative;
    overflow: hidden;
    display: flex; flex-direction: column;
    transform: translateY(30px);
    transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.user-popup-overlay.active .user-popup {
    transform: translateY(0);
}

.user-popup-close {
    position: absolute; top: 20px; right: 20px;
    background: #f5f5f5; border: none;
    width: 40px; height: 40px; border-radius: 50%;
    font-size: 28px; line-height: 1; color: #555;
    cursor: pointer; z-index: 20;
    transition: all 0.2s;
}
.user-popup-close:hover { background: #e0e0e0; color: #000; transform: rotate(90deg); }

/* Структура попапа */
.popup-layout { display: flex; flex-direction: column; height: 100%; }

.popup-header {
    padding: 35px 35px 15px 35px;
    background: #fff;
    flex-shrink: 0;
    border-bottom: 1px solid #f9f9f9;
}

.popup-date-badge {
    display: inline-block;
    background: #ffebee;
    color: #b71c1c;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 12px;
}

.popup-title {
    font-size: 28px;
    font-weight: 800;
    color: #222;
    line-height: 1.2;
    word-break: break-word;
}

.popup-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px 35px 40px 35px;
    background: #fff;
    /* Плавный скролл */
    scroll-behavior: smooth;
}

/* =========================================
   9. БЛОКИ КОНТЕНТА ВНУТРИ ПОПАПА
   ========================================= */
.user-block {
    margin-bottom: 30px;
    animation: fadeIn 0.4s ease forwards;
    width: 100%;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Заголовки внутри блоков (текст, слайдер, вопрос) */
.user-block-title {
    font-size: 19px;
    font-weight: 700;
    color: #2c1e1e;
    margin-bottom: 12px;
    line-height: 1.3;
}
.user-block-label {
    font-size: 17px;
    font-weight: 700;
    color: #2c1e1e;
    margin-bottom: 10px;
}

/* Текстовый блок */
.user-block-text p {
    font-size: 17px;
    line-height: 1.6;
    color: #333;
    white-space: pre-wrap;
    margin: 0;
    word-break: break-word;
}

/* Картинка */
.user-block-image img {
    max-height: 500px;
    width: auto;
    max-width: 100%;
    display: block;
    object-fit: contain;
    border-radius: 12px;
    margin: 0 auto;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

/* Инпут (Ваш ответ) */
.user-input-field {
    width: 100%;
    padding: 16px;
    background: #fafafa;
    border: 2px solid #eee;
    border-radius: 14px;
    font-family: inherit;
    font-size: 16px;
    color: #333;
    line-height: 1.5;
    
    /* АВТО-ВЫСОТА (Магия CSS) */
    field-sizing: content; 
    min-height: 80px;
    resize: none; /* Убираем ручной ресайз, раз есть авто */
    transition: all 0.2s;
}

.user-input-field:focus {
    outline: none;
    border-color: var(--color-primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(229, 57, 53, 0.1);
}

/* Слайдер (Шкала 1-10) */
.user-rate-wrapper {
    background: #fff;
    padding: 20px 25px;
    border-radius: 16px;
    border: 2px solid #ffcdd2;
    text-align: center;
    box-shadow: 0 5px 15px rgba(229, 57, 53, 0.05);
}

.user-range-value {
    font-size: 32px;
    font-weight: 800;
    color: var(--color-primary);
    margin: 5px 0 15px 0;
}

.user-range-input {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    outline: none;
    -webkit-appearance: none;
    margin-bottom: 10px;
}

.user-range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 28px; height: 28px;
    background: var(--color-primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: transform 0.1s;
}
.user-range-input::-webkit-slider-thumb:active { transform: scale(1.1); }

/* БЛОК "НЕДОСТУПНО" (ЗАМОЧЕК) */
.locked-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    
    background: #fdfdfd;
    border: 2px dashed #e0e0e0;
    border-radius: 16px;
    padding: 50px 20px;
    margin-bottom: 25px;
    color: #999;
}
.locked-icon { font-size: 48px; margin-bottom: 15px; opacity: 0.6; }

/* =========================================
   10. ССЫЛКИ НА ТЕЛЕГРАМ
   ========================================= */
.popup-tg-links-area {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tg-link-btn,
.social-post-link {
    text-decoration: none;
    padding: 15px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 1px solid #b3e5fc;
    transition: all 0.2s;
}
.social-post-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
}
.social-post-link-telegram {
    background: #f0f9ff;
    color: #0088cc;
    border-color: #b3e5fc;
}
.social-post-link-telegram:hover {
    background: #0088cc;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 136, 204, 0.2);
}
.social-post-link-facebook {
    background: #e8f0fe;
    color: #1976d2;
    border-color: #bbdefb;
}
.social-post-link-facebook:hover {
    background: #1976d2;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(25, 118, 210, 0.2);
}
.social-post-link-vk {
    background: #e3f2fd;
    color: #0277bd;
    border-color: #90caf9;
}
.social-post-link-vk:hover {
    background: #0277bd;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(2, 119, 189, 0.2);
}
.tg-link-btn {
    background: #f0f9ff;
    color: #0088cc;
}
.tg-link-btn:hover {
    background: #0088cc;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 136, 204, 0.2);
}

/* =========================================
   10a. ПОЛЕ ПРИМЕЧАНИЕ В ПОПАПЕ
   ========================================= */
.popup-note-block {
    margin-top: 30px;
    padding-top: 25px;
    border-top: 1px dashed #eee;
}

.popup-note-label {
    display: block;
    font-size: 15px;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.popup-note-input {
    width: 100%;
    padding: 16px;
    background: #fafafa;
    border: 2px solid #eee;
    border-radius: 14px;
    font-family: inherit;
    font-size: 16px;
    color: #333;
    line-height: 1.5;
    resize: vertical;
    min-height: 80px;
    transition: all 0.2s;
}

.popup-note-input:focus {
    outline: none;
    border-color: var(--color-primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(229, 57, 53, 0.1);
}

/* =========================================
   11. ФУТЕР ПОПАПА (КНОПКА ГОТОВО)
   ========================================= */
.popup-footer {
    padding: 25px 35px;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
    text-align: center;
}

.btn-complete {
    background: #f5f5f5;
    color: #777;
    border: none;
    padding: 18px;
    width: 100%;
    border-radius: 16px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    display: flex; align-items: center; justify-content: center; gap: 10px;
}

.btn-complete:hover:not(:disabled) {
    background: #eee;
}

.btn-complete.active {
    background: var(--color-success);
    color: #fff;
    box-shadow: 0 8px 25px rgba(46, 125, 50, 0.3);
}

.btn-complete:disabled {
    opacity: 0.6; cursor: not-allowed;
}

/* =========================================
   12. УПРАВЛЕНИЕ ДАННЫМИ (Импорт/Экспорт)
   ========================================= */
.data-management {
    background: #fff;
    border: 2px dashed #ffcdd2;
    border-radius: 16px;
    padding: 30px;
    text-align: center;
    margin-top: 60px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.02);
}

.data-management h3 {
    font-size: 18px;
    color: #2c1e1e;
    margin-bottom: 8px;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}

.data-management p {
    font-size: 14px; color: #7f5f5f; margin-bottom: 25px;
}

.data-buttons {
    display: flex; justify-content: center; gap: 15px; flex-wrap: wrap;
}

.data-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    padding: 14px 24px; border-radius: 12px;
    font-size: 15px; font-weight: 600; cursor: pointer; border: none;
    transition: all 0.2s; min-width: 200px;
}

.btn-export {
    background: var(--color-primary); color: #fff;
    box-shadow: 0 4px 10px rgba(229, 57, 53, 0.2);
}
.btn-export:hover {
    background: var(--color-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(229, 57, 53, 0.3);
}

.btn-import {
    background: #fff; color: var(--color-primary); border: 2px solid #ffcdd2;
}
.btn-import:hover {
    border-color: var(--color-primary); background: #fff5f5;
    transform: translateY(-2px);
}
.btn-import input { display: none; }

.data-hint { font-size: 12px; color: #bbb; margin-top: 15px; font-family: monospace; }

/* =========================================
   13. АДАПТИВ (RESPONSIVE)
   ========================================= */
@media (max-width: 768px) {
    .container { padding: 10px 15px 40px; }
    .header h1 { font-size: 26px; }
    .month-grid { grid-template-columns: 1fr; } /* Одна колонка на мобилках */
    
    .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 15px; }
    .stat-card h3 { font-size: 11px; }
    .stat-card .value { font-size: 24px; }
    
    .stage-navigation { padding: 20px 40px; }
    .stage-nav-btn { width: 36px; height: 36px; font-size: 20px; }
    
    .user-popup { width: 100%; height: 100%; border-radius: 0; max-height: none; }
    .popup-header { padding: 20px; }
    .popup-scroll-area { padding: 15px 20px 40px 20px; }
    .popup-title { font-size: 22px; }
    
    .btn-complete { padding: 15px; font-size: 15px; }
}

@media (max-width: 480px) {
    .legend { gap: 15px; }
    .legend-item { font-size: 14px; }
    .data-btn { min-width: 100%; } /* Кнопки на всю ширину */
}