/* =========================================
   LMS COFFEE STYLE - FINAL v7.0 (High Contrast)
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Merriweather:wght@300;700&family=Inter:wght@400;500;600&display=swap');

:root {
    /* --- СВЕТЛАЯ ТЕМА (LATTE) --- */
    --bg-body: #F5F2EA;
    --bg-sidebar: #3E2723;
    --bg-card: #FFFFFF;
    --bg-dropdown: #FFFFFF;
    
    --text-main: #3E2723;     /* Темный шоколад */
    --text-muted: #6D4C41;    /* Корица */
    --text-light: #F5F2EA;

    --primary: #5D4037;       /* Основной коричневый */
    --primary-hover: #3E2723;
    --accent: #A1887F;        /* Акцент */
    --highlight-bg: rgba(93, 64, 55, 0.1); 
    
    --border-soft: 1px solid #D7CCC8;
    --shadow-card: 0 4px 12px rgba(62, 39, 35, 0.08);

    --success: #2E7D32;
    --error: #C62828;
    --warn: #F9A825;
    
    --grid-color: rgba(93, 64, 55, 0.2);

    --input-bg: #FFFFFF;
    --input-border: #BCAAA4;
    
    --sidebar-width: 260px;
    --radius: 10px;
}

/* --- ТЁМНАЯ ТЕМА (ESPRESSO) --- */
body.dark-theme {
    --bg-body: #282220;       /* Черный кофе */
    --bg-sidebar: #1B1614;    /* Очень темный */
    --bg-card: #322A26;       /* Темный шоколад */
    --bg-dropdown: #3E3430;
    
    --text-main: #EFEBE9;     /* Пенка */
    --text-muted: #BCAAA4;
    --text-light: #EFEBE9;    

    --primary: #A1887F;       /* Светло-коричневый */
    --primary-hover: #8D6E63;
    --accent: #5D4037;
    --highlight-bg: rgba(161, 136, 127, 0.2);
    
    --border-soft: 1px solid #4E342E;
    --shadow-card: 0 4px 15px rgba(0, 0, 0, 0.5);
    
    --grid-color: rgba(161, 136, 127, 0.2);

    --input-bg: #3E3430;
    --input-border: #5D4037;
}

* { box-sizing: border-box; }

body {
    margin: 0; font-family: 'Inter', sans-serif;
    background-color: var(--bg-body); color: var(--text-main);
    min-height: 100vh; line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
}

h1, h2, h3, h4 {
    font-family: 'Merriweather', serif; font-weight: 700;
    color: var(--primary); margin-top: 0;
}

.background-animation { display: none; }

/* --- UI ELEMENTS --- */
.card {
    background: var(--bg-card); border: var(--border-soft);
    border-radius: var(--radius); padding: 30px;
    box-shadow: var(--shadow-card); margin-bottom: 25px;
}

.avatar-large {
    width: 120px !important;
    height: 120px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    border: 3px solid var(--accent);
    margin-bottom: 10px;
    background: #FFF;
    display: block; /* Важно, чтобы не растягивался */
}

/* График */
.chart-container {
    background: var(--bg-card); border-radius: var(--radius);
    padding: 20px; height: 400px; min-height: 400px;
    border: var(--border-soft); position: relative;
}

/* --- КНОПКИ (УЛУЧШЕННЫЙ КОНТРАСТ) --- */
button {
    width: 100%; padding: 12px; margin-top: 10px; border: none; border-radius: 6px;
    background: var(--primary); color: #FFF; font-weight: 600; cursor: pointer;
    transition: 0.2s; font-size: 0.95rem; box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
button:hover { background: var(--primary-hover); transform: translateY(-1px); }

/* Контурные кнопки (Профиль) */
.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    width: auto; padding: 5px 15px; font-size: 0.85rem; margin-top: 5px;
    font-weight: 600; /* Жирнее, чтобы видно было */
}
.btn-outline:hover {
    background: var(--primary); color: #FFF;
}
/* В темной теме делаем их светлее по дефолту, если нужно */
body.dark-theme .btn-outline {
    border-color: var(--text-muted); color: var(--text-muted);
}
body.dark-theme .btn-outline:hover {
    border-color: var(--text-main); color: var(--text-main); background: transparent;
}

.profile-section {
    display: flex;
    flex-direction: column;
    align-items: center; /* Центрирование по горизонтали */
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.profile-section input[type="text"] {
    text-align: center;
    width: 100% !important; /* На всю ширину контейнера */
    margin-bottom: 5px;
}
/* Меню (Nav Buttons) - Выделяем их */
.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 10px; /* Равномерный отступ между ВСЕМИ кнопками */
    flex-grow: 1; /* Чтобы меню занимало место */
}

.nav-btn {
    background: rgba(255, 255, 255, 0.05); /* Легкий фон */
    color: rgba(255, 255, 255, 0.7);       /* Серый текст */
    text-align: left; padding: 12px 18px;
    border-radius: 8px; font-size: 0.95rem; border: none;
    width: 100%; cursor: pointer; font-weight: 500; transition: 0.2s;
    display: flex; align-items: center; gap: 10px;
}
.text-error { color: var(--error) !important; }
.text-success { color: var(--success) !important; }
.risk-item {
    border-left: 3px solid var(--error) !important;
    background: rgba(198, 40, 40, 0.05); /* Легкая красная подсветка */
}
body.dark-theme .risk-item {
    background: rgba(229, 115, 115, 0.1);
}
.nav-spacer {
    
    flex-grow: 1; /* Это сдвинет Тему и Выход в самый низ */
}
.nav-btn:hover {
    background: rgba(255, 255, 255, 0.15); /* Ярче при наведении */
    color: #FFF;
}
.nav-btn.active {
    background: var(--primary); 
    color: #FFF;
    font-weight: 700;
    border-left: 4px solid var(--accent); /* Полоска */
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

/* Инпуты */
input, select, textarea {
    width: 100%; padding: 10px 12px; margin: 8px 0;
    border: 1px solid var(--input-border); border-radius: 6px;
    background: var(--input-bg); color: var(--text-main);
    font-size: 1rem; font-family: 'Inter', sans-serif; outline: none;
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(93, 64, 55, 0.2); }

/* --- ЖУРНАЛ (СЕТКА) --- */
.journal-wrapper { background: var(--bg-card); border: var(--border-soft); border-radius: var(--radius); overflow: auto; max-height: 70vh; }
.journal-table { width: 100%; border-collapse: separate; border-spacing: 0; }

/* Кофейная сетка */
.journal-table td, .journal-table th {
    border-right: 1px solid var(--grid-color) !important;
    border-bottom: 1px solid var(--grid-color) !important;
}
.journal-table tr td:last-child { border-right: none !important; }

.journal-table th {
    background: var(--bg-body); color: var(--primary); padding: 10px;
    position: sticky; top: 0; z-index: 10;
}
.journal-table td {
    padding: 8px; text-align: center; color: var(--text-main); font-size: 0.9rem;
}
/* Липкая колонка ФИО */
.journal-table td:first-child, .journal-table th:first-child {
    position: sticky; left: 0; z-index: 11;
    background: var(--bg-card); /* Фон карты, чтобы не просвечивал */
    text-align: left; padding-left: 15px; font-weight: 600; color: var(--primary);
    border-right: 2px solid var(--grid-color) !important;
}
.journal-table th:first-child { background: var(--bg-body); z-index: 12; }
.j-cell:hover { background: var(--bg-body); cursor: pointer; }

/* Оценки (Чипсы) */
.grades-wrapper { display: flex !important; flex-direction: row !important; flex-wrap: wrap; gap: 6px; align-items: center; }
.grade-chip {
    width: 32px; height: 32px; display: flex; justify-content: center; align-items: center;
    border-radius: 6px; font-weight: 600; font-size: 0.95rem; position: relative; cursor: default;
    border: 1px solid transparent;
}
.g-10, .g-9, .g-8 { background: rgba(46, 125, 50, 0.2); color: #2E7D32; border-color: #2E7D32; }
body.dark-theme .g-10, body.dark-theme .g-9, body.dark-theme .g-8 { background: rgba(76, 175, 80, 0.2); color: #81C784; border-color: #81C784; }
.g-2, .g-1 { background: rgba(198, 40, 40, 0.2); color: #C62828; border-color: #C62828; }
body.dark-theme .g-2 { color: #E57373; border-color: #E57373; }
.g-N { background: rgba(0,0,0,0.05); color: var(--text-muted); border: 1px solid var(--text-muted); }

.grade-date {
    position: absolute; bottom: 120%; left: 50%; transform: translateX(-50%);
    background: var(--bg-sidebar); color: #FFF; padding: 4px 8px;
    border-radius: 4px; font-size: 0.75rem; white-space: nowrap;
    opacity: 0; visibility: hidden; transition: 0.2s; pointer-events: none; z-index: 20;
}
.grade-chip:hover .grade-date { opacity: 1; visibility: visible; }

/* Остальное */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-box { background: var(--bg-card); padding: 20px; border-radius: var(--radius); border: var(--border-soft); text-align: center; }
.stat-val { font-size: 2rem; font-weight: 700; color: var(--primary); font-family: 'Merriweather', serif; }
.stat-label { color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase; margin-top: 5px; }

.list-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 15px; border-bottom: var(--border-soft); color: var(--text-main); }
.list-item:hover { background: var(--bg-body); }
.list-item.me { background-color: var(--highlight-bg); border: 1px solid var(--primary); color: var(--text-main); font-weight: 500; }

.upload-area { border: 2px dashed var(--primary); background: var(--bg-body); border-radius: 15px; padding: 30px; transition: 0.2s; color: var(--text-main); }
.upload-area:hover { background: var(--bg-card); cursor: pointer; }
.upload-area.highlight { border-color: var(--success); background-color: rgba(46, 125, 50, 0.1); transform: scale(1.02); }
.upload-area * {
    pointer-events: none;
}

.toggle-group { display: inline-flex; background: var(--bg-body); padding: 4px; border-radius: 6px; gap: 4px; border: var(--border-soft); }
.toggle-group button { margin: 0; padding: 6px 15px; width: auto; font-size: 0.85rem; color: var(--text-muted); background: transparent; box-shadow: none; }
.toggle-group button.active { background: var(--primary); color: #FFF; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
/* --- ATTENDANCE ACCORDION (Пропуски) --- */

/* Контейнер года */
.att-year-block {
    margin-bottom: 15px;
    border: var(--border-soft);
    border-radius: var(--radius);
    background: var(--bg-card);
    overflow: hidden;
}

/* Заголовок года */
.att-year-header {
    padding: 15px;
    background: rgba(93, 64, 55, 0.05); /* Легкий оттенок */
    cursor: pointer;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid transparent;
    transition: 0.2s;
}
body.dark-theme .att-year-header {
    background: rgba(255, 255, 255, 0.05);
}
.att-year-header:hover {
    background: rgba(93, 64, 55, 0.1);
}
.att-year-header.active {
    border-bottom: var(--border-soft);
}

/* Контейнер списка дней внутри года */
.att-year-body {
    display: none; /* Скрыто по умолчанию */
    padding: 0;
}
.att-year-body.open {
    display: block;
}

/* Строка ДНЯ (сводка) */
.att-day-header {
    padding: 12px 15px;
    border-bottom: 1px solid var(--grid-color);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}
.att-day-header:hover {
    background: var(--bg-body);
}
.att-date-title {
    font-weight: 600;
    color: var(--text-main);
}
.att-day-total {
    font-size: 0.9rem;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(0,0,0,0.05);
    color: var(--text-muted);
}
body.dark-theme .att-day-total {
    background: rgba(255,255,255,0.1);
}

/* Детали внутри дня (список уроков) */
.att-day-details {
    display: none;
    background: var(--bg-body);
    padding: 5px 0;
    border-bottom: 1px solid var(--grid-color);
}
.att-day-details.open {
    display: block;
}

/* Конкретный урок внутри детализации */
.att-lesson-item {
    padding: 8px 15px 8px 30px; /* Отступ слева побольше */
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-left: 3px solid transparent;
}
.att-lesson-item.unjustified {
    border-left-color: var(--error);
    background: rgba(198, 40, 40, 0.05);
}
body.dark-theme .att-lesson-item.unjustified {
    background: rgba(229, 115, 115, 0.05);
}
.att-lesson-item.justified {
    border-left-color: var(--success);
}

/* Стрелочки */
.arrow {
    transition: transform 0.3s;
    font-size: 0.8rem;
    margin-right: 10px;
    display: inline-block;
}
.active .arrow, .open .arrow {
    transform: rotate(90deg);
}






/* --- SIDEBAR FIXES (Контрастность) --- */

/* Инпуты в сайдбаре (Telegram) */
.sidebar input[type="text"] {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    color: #FFF !important;
}
.sidebar input[type="text"]::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* Кнопки в сайдбаре (OK, Пароль, Изменить фото) */
.sidebar .btn-outline, 
.sidebar .avatar-btn {
    border-color: rgba(255, 255, 255, 0.4) !important;
    color: rgba(255, 255, 255, 0.9) !important;
    background: transparent !important;
}
.sidebar .btn-outline:hover, 
.sidebar .avatar-btn:hover {
    border-color: #FFF !important;
    color: #FFF !important;
    background: rgba(255, 255, 255, 0.1) !important;
}

/* Имя и ВУЗ */
.sidebar h3, .sidebar p {
    color: #F5F2EA !important; /* Всегда светлый текст в сайдбаре */
}
/* --- ATTENDANCE: MONTH LEVEL (НОВОЕ) --- */

/* Блок месяца */
.att-month-block {
    margin: 5px 10px 10px 10px; /* Отступы внутри года */
    border-left: 2px solid var(--border-soft);
}

/* Заголовок месяца */
.att-month-header {
    padding: 10px 15px;
    background: var(--bg-body); /* Чуть светлее/темнее чем год */
    cursor: pointer;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid transparent;
    transition: 0.2s;
    border-radius: 6px;
}
.att-month-header:hover {
    background: rgba(0,0,0,0.03);
}
body.dark-theme .att-month-header:hover {
    background: rgba(255,255,255,0.03);
}
.att-month-header.active {
    background: rgba(93, 64, 55, 0.05); /* Легкий акцент активного месяца */
    font-weight: 700;
}
body.dark-theme .att-month-header.active {
    background: rgba(255, 255, 255, 0.05);
}

/* Тело месяца (список дней) */
.att-month-body {
    display: none;
    padding-left: 10px; /* Сдвиг дней вправо */
}
.att-month-body.open {
    display: block;
}

/* Корректировка дня, чтобы он вписывался в иерархию */
.att-day-header {
    background: var(--bg-card); /* Возвращаем фон карточки */
    border-bottom: 1px solid var(--border-soft);
}







#notifDropdown { background-color: var(--bg-dropdown) !important; border: var(--border-soft) !important; color: var(--text-main) !important; box-shadow: var(--shadow-card) !important; }
#notifDropdown .notif-header { background: var(--bg-body); color: var(--primary); border-bottom: var(--border-soft); }
.notif-item { border-bottom: var(--border-soft); }
.notif-item:hover { background: var(--bg-body); }
.notif-btn { background: var(--bg-card) !important; color: var(--primary) !important; border: var(--border-soft) !important; font-weight: 600; padding: 8px 15px; border-radius: 6px; }

/* Адаптив */
.dashboard-layout { display: flex; min-height: 100vh; width: 100%; }
.sidebar { width: var(--sidebar-width); background: var(--bg-sidebar); color: var(--text-light); display: flex; flex-direction: column; padding: 25px 15px; position: fixed; top: 0; left: 0; height: 100vh; z-index: 1000; box-shadow: 2px 0 10px rgba(0,0,0,0.2); overflow-y: auto; transition: background-color 0.3s; }
.main-content { flex: 1; margin-left: var(--sidebar-width); padding: 40px; background: var(--bg-body); width: calc(100% - var(--sidebar-width)); transition: background-color 0.3s; }
.avatar-btn { background: transparent; border: 1px solid rgba(255,255,255,0.3); color: rgba(255,255,255,0.7); font-size: 0.8rem; padding: 4px 8px; border-radius: 4px; cursor: pointer; margin-top: 5px; }
.avatar-btn:hover { color: #FFF; border-color: #FFF; }
.mobile-header { display: none; }
/* --- МОБИЛЬНЫЙ АДАПТИВ (BURGER MENU v2.0) --- */
@media (max-width: 900px) {
    .dashboard-layout { flex-direction: column; }
    
    /* 1. Сайдбар (Скрыт слева) */
    .sidebar { 
        width: 280px; 
        max-width: 85vw; /* Чтобы не был шире экрана */
        height: 100vh; 
        position: fixed; 
        top: 0; 
        left: -300px; /* Спрятан полностью */
        z-index: 2000; 
        transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
        transform: translateX(0);
        box-shadow: 5px 0 15px rgba(0,0,0,0.3);
        
        /* Вертикальный список */
        flex-direction: column; 
        justify-content: flex-start; /* Все элементы сверху */
        padding: 20px 15px 80px 15px; /* Отступ снизу для скролла */
        overflow-y: auto; /* ВАЖНО: Разрешаем скролл меню */
        -webkit-overflow-scrolling: touch;
    }
    
    /* Класс для открытия меню (используем transform для плавности) */
    .sidebar.active {
        transform: translateX(300px);
    }

    /* Скрываем распорку на мобиле, чтобы кнопки шли подряд */
    .nav-spacer { display: none; }

    /* 2. Профиль */
    .profile-section { 
        display: flex !important;
        flex-direction: column;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        padding-bottom: 20px;
        margin-bottom: 15px;
    }
    
    /* 3. Меню навигации */
    .nav-menu { 
        position: static;
        width: 100%; 
        border-top: none; 
        padding: 0;
        flex-direction: column;
        gap: 8px;
        background: transparent;
    }

    .nav-btn {
        width: 100%;
        font-size: 1rem; /* Чуть крупнее для пальца */
        padding: 14px 18px; /* Больше область нажатия */
        flex-direction: row;
        justify-content: flex-start;
        border-bottom: none;
    }
    
    .nav-btn.active {
        border-bottom: none;
        border-left: 4px solid var(--accent);
        background: var(--primary);
    }

    /* 4. Основной контент */
    .main-content { 
        margin-left: 0; 
        width: 100%; 
        padding: 15px; 
        padding-top: 80px; /* Отступ сверху */
    }

    /* 5. Мобильная шапка */
    .mobile-header {
        display: flex !important;
        position: fixed;
        top: 0; left: 0; width: 100%;
        height: 60px;
        background: var(--bg-card);
        border-bottom: var(--border-soft);
        z-index: 1500;
        align-items: center;
        justify-content: space-between; /* Чтобы разнести бургер и колокольчик */
        padding: 0 15px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    }

    .burger-btn {
        font-size: 1.6rem;
        background: none;
        border: none;
        color: var(--primary);
        padding: 5px;
        margin: 0;
        width: auto;
        box-shadow: none;
    }

    /* Затемнение */
    .overlay {
        display: none;
        position: fixed; top: 0; left: 0; width: 100%; height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 1900;
        backdrop-filter: blur(3px);
        transition: opacity 0.3s;
    }
    .overlay.active { display: block; }
    
    /* Скрываем десктопный заголовок с колокольчиком в контенте */
    .desktop-only-header {
        display: none !important;
    }
}



.hidden { display: none !important; }
.fade-in { animation: fadeIn 0.4s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Login styles */
.container { display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 100vh; padding: 20px; width: 100%; }
.role-selection { display: flex; flex-direction: row; justify-content: center; align-items: center; gap: 30px; margin: 40px auto; width: 100%; max-width: 800px; flex-wrap: wrap; }
.role-card { background: var(--bg-card); border: var(--border-soft); padding: 40px 30px; border-radius: var(--radius); text-align: center; cursor: pointer; transition: 0.2s; box-shadow: var(--shadow-card); color: var(--text-main); width: 280px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.role-card:hover { border-color: var(--primary); transform: translateY(-5px); background: var(--bg-body); }
.role-card img { margin-bottom: 20px; width: 80px; height: 80px; opacity: 0.9; }
.link-text { color: var(--text-muted); cursor: pointer; border-bottom: 1px dashed var(--text-muted); font-size: 0.9rem; }
.link-text:hover { color: var(--primary); border-bottom-style: solid; }
/* ВАЖНО: Делаем содержимое зоны загрузки "прозрачным" для мыши, 
   чтобы событие drop всегда попадало на родительский блок .upload-area */
.upload-area * {
    pointer-events: none;
}