/* =========================================
   1. НАСТРОЙКИ И ЦВЕТОВАЯ ПАЛИТРА (VARIABLES)
   ========================================= */
:root {
    --bg-main: #18181b;
    --bg-card: #27272a;
    --bg-card-hover: #3f3f46;
    
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    
    --color-blue: #38bdf8;
    --color-orange: #fbbf24;
    --color-green: #34d399;
    --color-purple: #a78bfa;
    --color-red: #f87171;
    
    --accent-ui: #6366f1;
    
    --radius-outer: 16px;
    --radius-inner: 8px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    
    --font-main: 'Montserrat', -apple-system, sans-serif;
}

/* =========================================
   2. БАЗА И ФОН (GLOBAL)
   ========================================= */
body {
    font-family: var(--font-main);
    background-color: var(--bg-main);
    color: var(--text-primary);
    margin: 0;
    padding: 15px;
    padding-bottom: 80px;
    background-image: radial-gradient(#3f3f46 1px, transparent 1px);
    background-size: 20px 20px;
    line-height: 1.4;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

/* =========================================
   3. ШАПКА (HEADER)
   ========================================= */
header {
    background-color: var(--bg-card);
    padding: var(--spacing-md);
    border-radius: var(--radius-outer);
    box-shadow: 0 4px 0 rgba(0,0,0,0.3); 
    margin-bottom: 20px;
    border: 2px solid #3f3f46;
}

.header-top {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

@media (min-width: 768px) {
    .header-top {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

h1 {
    font-size: 1.4em;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.5px;
}

/* =========================================
   4. КНОПКИ (BUTTONS)
   ========================================= */
button, .schedule-selection-btn, #boosty-header-link {
    font-family: var(--font-main);
    border: none;
    cursor: pointer;
    transition: transform 0.1s, background-color 0.2s;
    font-weight: 600;
}

button {
    background-color: var(--accent-ui);
    color: #fff;
    padding: 10px 20px;
    border-radius: var(--radius-inner);
    font-size: 0.9em;
    box-shadow: 0 4px 0 #4338ca; 
}

button:hover {
    transform: translateY(-2px);
}

button:active {
    transform: translateY(2px);
    box-shadow: 0 0 0 #4338ca;
}

#back-to-selection-btn {
    background-color: #3f3f46;
    box-shadow: 0 4px 0 #27272a;
}

#boosty-header-link {
    display: inline-block;
    background-color: transparent;
    border: 2px solid var(--color-orange);
    color: var(--color-orange);
    padding: 8px 16px;
    border-radius: var(--radius-inner);
    text-decoration: none;
    font-size: 0.9em;
}

#boosty-header-link:hover {
    background-color: var(--color-orange);
    color: #000;
}

/* =========================================
   5. НАВИГАЦИЯ ПО НЕДЕЛЯМ
   ========================================= */
#week-navigation {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-main);
    padding: 5px;
    border-radius: var(--radius-inner);
    margin-top: 15px;
    border: 1px solid #3f3f46;
}

#prev-week-btn, #next-week-btn {
    background: transparent;
    box-shadow: none;
    color: var(--text-secondary);
    font-size: 1.2em;
    padding: 5px 15px;
    margin: 0;
}

#prev-week-btn:hover, #next-week-btn:hover {
    color: var(--accent-ui);
    transform: none;
    background-color: rgba(255,255,255,0.05);
}

#current-week-display {
    font-family: monospace;
    font-size: 1em;
    color: var(--text-primary);
}

/* =========================================
   6. ВЫБОР ПЛАНА
   ========================================= */
#schedule-list {
    display: grid;
    gap: 15px;
    background: transparent;
    box-shadow: none;
    padding: 0;
}

.schedule-selection-btn {
    background-color: var(--bg-card);
    color: var(--text-primary);
    padding: 20px;
    border-radius: var(--radius-outer);
    border: 2px solid transparent;
    text-align: left;
    font-size: 1.1em;
    box-shadow: 0 4px 0 rgba(0,0,0,0.2);
}

.schedule-selection-btn:hover {
    border-color: var(--accent-ui);
    background-color: var(--bg-card-hover);
    transform: translateY(-2px);
}

/* =========================================
   7. ДНИ (DAYS)
   ========================================= */
#schedule-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.day-card {
    background-color: var(--bg-card);
    border-radius: var(--radius-outer);
    padding: 15px;
    border: 1px solid #3f3f46;
}

.day-card.today {
    border: 2px solid var(--color-orange);
    position: relative;
}

.day-card h2 {
    font-size: 1.1em;
    margin: 0 0 10px 0;
    padding-bottom: 8px;
    border-bottom: 2px dashed #3f3f46;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.day-card.today h2 {
    color: var(--color-orange);
}

/* =========================================
   8. ЗАНЯТИЯ (LESSONS)
   ========================================= */
.lesson-card {
    background-color: rgba(255,255,255,0.03);
    border-radius: var(--radius-inner);
    padding: 12px 15px;
    margin-bottom: 8px;
    display: grid;
    grid-template-columns: 85px 1fr; /* Ширина для времени */
    grid-template-areas: 
        "time discipline"
        "time details";
    column-gap: 10px;
    row-gap: 6px;
    align-items: center;
    border-left: 4px solid var(--text-secondary);
    transition: background-color 0.2s;
}

.lesson-card:last-child {
    margin-bottom: 0;
}

.lesson-card:hover {
    background-color: rgba(255,255,255,0.07);
}

/* Color Coding */
.lesson-type-Wyklad { border-left-color: var(--color-blue); }
.lesson-type-Wyklad .lesson-time { color: var(--color-blue); }
.lesson-type-Wyklad .lesson-type-badge { background-color: rgba(56, 189, 248, 0.15); color: var(--color-blue); }

.lesson-type-Konwersatorium { border-left-color: var(--color-orange); }
.lesson-type-Konwersatorium .lesson-time { color: var(--color-orange); }
.lesson-type-Konwersatorium .lesson-type-badge { background-color: rgba(251, 191, 36, 0.15); color: var(--color-orange); }

.lesson-type-CL { border-left-color: var(--color-green); }
.lesson-type-CL .lesson-time { color: var(--color-green); }
.lesson-type-CL .lesson-type-badge { background-color: rgba(52, 211, 153, 0.15); color: var(--color-green); }

.lesson-type-AU { border-left-color: var(--color-purple); }
.lesson-type-AU .lesson-time { color: var(--color-purple); }
.lesson-type-AU .lesson-type-badge { background-color: rgba(167, 139, 250, 0.15); color: var(--color-purple); }

/* Время */
.lesson-time {
    grid-area: time;
    font-size: 1.58em;
    font-weight: 800;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.lesson-time span {
    font-size: 0.8em;
    opacity: 0.6;
    font-weight: 500;
    margin-top: 2px;
}

/* Предмет */
.lesson-discipline {
    grid-area: discipline;
    font-size: 1em;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    white-space: normal;
    overflow: visible;
}

.lesson-discipline span:first-child {
    margin-right: 10px;
    line-height: 1.3;
}

/* Бэйджик типа занятия */
.lesson-type-badge {
    font-size: 0.7em;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
    flex-shrink: 0;
    margin-left: auto;
}

/* Детали (Препод и Аудитория) */
.lesson-details {
    grid-area: details;
    font-size: 0.9em;
    color: var(--text-secondary);
    
    /* Изменение: Вертикальный стек */
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px; 
}

.lesson-details div {
    display: inline-flex;
    align-items: center;
}

.lesson-details .detail-teacher::before { 
    content: "👤"; 
    margin-right: 6px; 
    filter: grayscale(1);
    font-size: 0.9em;
}

.lesson-details .detail-auditory {
    color: var(--text-primary);
    font-weight: 700;
    background: rgba(255,255,255,0.05);
    padding: 2px 8px;
    border-radius: 4px;
}

.lesson-details .detail-auditory::before { 
    content: "🚪"; 
    margin-right: 6px; 
    filter: grayscale(0);
}

.lesson-groups { display: none; }

/* =========================================
   9. ФИЛЬТРЫ
   ========================================= */
.filter-toggle-btn {
    width: 100%;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9em;
    padding: 10px 0;
    border: none;
    border-top: 1px solid #3f3f46;
    margin-top: 10px;
    text-align: center;
}

.filter-toggle-btn:hover {
    color: var(--text-primary);
}

#filters {
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    background: var(--bg-main);
    border-radius: var(--radius-inner);
}

#filters:not(.is-closed) {
    padding: 15px;
    border: 1px solid #3f3f46;
    margin-top: 10px;
}

#filters.is-closed {
    max-height: 0;
    padding: 0;
    border: none;
}

#filters label {
    display: inline-block;
    margin: 5px 10px 5px 0;
    cursor: pointer;
    font-size: 0.9em;
    color: var(--text-secondary);
}

#filters input {
    accent-color: var(--accent-ui);
}

/* =========================================
   10. РАЗНОЕ
   ========================================= */
.is-hidden { display: none !important; }

#loader .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.1);
    border-left-color: var(--accent-ui);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 40px auto;
}

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

#schedule-container .placeholder {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
    font-style: italic;
}

.error-message {
    background-color: rgba(248, 113, 113, 0.2);
    color: var(--color-red);
    padding: 15px;
    border-radius: var(--radius-inner);
    text-align: center;
    border: 1px solid var(--color-red);
}

.admin-link {
    text-align: center;
    display: block;
    margin-top: 30px;
    color: #52525b;
    font-size: 0.8em;
    text-decoration: none;
}

/* =========================================
   11. ПЛАВАЮЩАЯ КНОПКА "СЕГОДНЯ"
   ========================================= */
#today-float {
    position: fixed;
    bottom: 25px;
    right: 25px;
}

#today-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    padding: 0;
    background-color: var(--color-orange);
    color: #000;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    font-size: 0; 
    display: flex;
    align-items: center;
    justify-content: center;
}

#today-btn::after {
    content: "⬇";
    font-size: 20px;
}

#today-btn:hover {
    transform: scale(1.1);
    background-color: #fcd34d;
}

/* =========================================
   12. МОБИЛЬНАЯ АДАПТАЦИЯ
   ========================================= */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .lesson-card {
        grid-template-columns: 75px 1fr;
        padding: 10px;
        column-gap: 8px;
    }
    
    .lesson-discipline {
         font-size: 0.95em;
    }
    
    .lesson-type-badge {
        margin-top: 2px;
    }

    .header-actions {
        display: flex;
        width: 100%;
        gap: 10px;
    }
    
    .header-actions button, 
    .header-actions a {
        flex: 1;
        text-align: center;
        padding: 12px 0;
    }
}