/* ===================================================
   1. ЗМІННІ ТА БАЗОВІ НАЛАШТУВАННЯ
   =================================================== */
:root {
    --bg: #f0f2f5;
    --card: #ffffff;
    --text: #1c1e21;
    --sub-text: #606770;
    
    /* Кольорові мітки предметів */
    --c-math: #ff4757;
    --c-lang: #1e90ff;
    --c-science: #2ed573;
    --c-art: #a55eea;
    --c-tech: #4b6584;
    --c-history: #ffa502;
    --c-phys: #ffa502;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 15px;
}

/* ===================================================
   2. МАКЕТ СТОРІНКИ ТА АДАПТИВНІСТЬ
   =================================================== */
.main-wrapper {
    width: 100%;
    max-width: 1200px; /* Оптимальна ширина для ПК */
    margin: 0 auto;
}

/* Основна сітка (Зліва картки, справа ДЗ) */
.grid-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    align-items: start;
}

/* Сітка карток уроків на ПК (2 стовпчики) */
.zoom-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-content: start;
}

/* Планшети (до 1100px) */
@media (max-width: 1100px) {
    .zoom-list { grid-template-columns: 1fr; }
    .grid-layout { grid-template-columns: 1.4fr 1fr; }
}

/* Смартфони (до 850px) */
@media (max-width: 850px) {
    .grid-layout { grid-template-columns: 1fr; }
    body { padding: 10px 8px; }
}

/* ===================================================
   3. РОЗКЛАД ДЗВІНКІВ
   =================================================== */
.schedule-container {
    background: #ffffff;
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 20px;
    border: 2px dashed #d1d8e0;
    width: 100%;
}

.schedule-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
    gap: 6px;
}

.schedule-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 4px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #edf0f2;
    transition: all 0.2s ease;
}

.schedule-item .num {
    font-size: 0.65rem;
    color: #1e90ff;
    font-weight: 800;
    margin-bottom: 2px;
}

.schedule-item .time {
    font-size: 0.8rem;
    font-weight: 700;
    color: #2c3e50;
    white-space: nowrap;
}

/* ===================================================
   4. КАРТКИ ПРЕДМЕТІВ ТА КНОПКИ
   =================================================== */
.card {
    background: var(--card);
    border-radius: 12px;
    padding: 8px 12px;
    border-left: 5px solid #ccc;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.3s ease;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
    gap: 6px;
}

.subject-title {
    display: flex;
    align-items: center;
    gap: 6px;
}

.icon {
    font-size: 1.1rem;
    min-width: 22px;
}

.name {
    font-weight: 700;
    font-size: 0.95rem;
    color: #2c3e50;
}

/* Блок підручників */
.books-container {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 55%;
}

.book-mini-btn {
    text-decoration: none;
    background: #eef7fe;
    color: #007bff;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 5px;
    border: 1px solid #d1e9ff;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.2s;
}

.book-mini-btn:hover { background: #d9edff; }

/* Кнопки Zoom */
.btn-row {
    display: flex;
    gap: 6px;
    width: 100%;
}

.btn {
    flex: 1;
    text-decoration: none;
    background: #f1f3f5;
    color: #495057;
    text-align: center;
    padding: 6px 4px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.8rem;
    border: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    transition: all 0.15s ease;
}

.btn:hover { background: #e9ecef; border-color: #adb5bd; }
.btn:active { transform: translateY(1px); background: #dee2e6; }

/* ===================================================
   5. ДИНАМІЧНА ПІДСВІТКА (ЖИВИЙ УРОК)
   =================================================== */
/* Дзвінок: Скоро почнеться (Жовтий) */
.schedule-item.upcoming {
    background-color: #fff9c4 !important;
    border-color: #fbc02d !important;
    animation: pulse-yellow 2s infinite;
}

/* Дзвінок: Йде урок (Зелений) */
.schedule-item.active {
    background-color: #c8e6c9 !important;
    border-color: #4caf50 !important;
    font-weight: bold;
    transform: scale(1.04);
}

/* Сама картка предмета (Жовта) */
.card.upcoming {
    background-color: #fcf6d6 !important;
    border-color: #fbc02d !important;
}

/* Сама картка предмета (Зелена) */
.card.active {
    background-color: #f1fcf1 !important;
    border-color: #4caf50 !important;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.2);
    transform: scale(1.02);
}

@keyframes pulse-yellow {
    0% { box-shadow: 0 0 0 0 rgba(251, 192, 45, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(251, 192, 45, 0); }
    100% { box-shadow: 0 0 0 0 rgba(251, 192, 45, 0); }
}

/* ===================================================
   6. БЛОК ДОМАШНЬОГО ЗАВДАННЯ
   =================================================== */
.hw-container {
    background: #ffffff;
    border-radius: 12px;
    padding: 15px;
    border: 1px solid #dbe2e8;
    border-top: 4px solid #a55eea;
    position: sticky;
    top: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.hw-container h3 {
    margin: 0 0 15px 0;
    font-size: 1.1rem;
    color: #2f3542;
    text-align: left;
}

.hw-item {
    text-align: left;
    padding-bottom: 12px;
    border-bottom: 1px solid #edf0f2;
    margin-bottom: 12px;
}

.hw-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.hw-subject {
    font-weight: 800;
    font-size: 0.95rem;
    color: #2f3542;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
}

.hw-text {
    font-size: 0.9rem;
    color: #4b6584;
    white-space: pre-wrap;
    line-height: 1.4;
    text-align: left;
    margin: 0;
    padding: 0;
    width: 100%;
}

/* Посилання всередині тексту ДЗ */
.hw-link {
    color: #007bff;
    text-decoration: none;
    word-break: break-all;
    font-weight: 600;
    border-bottom: 1px dashed #007bff;
}

.hw-link:hover {
    color: #0056b3;
    border-bottom-style: solid;
}

/* ===================================================
   7. СЕКЦІЯ: КНИЖКИ НА ЛІТО
   =================================================== */
.summer-section {
    width: 100%;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 3px solid #ff9f43;
}

.summer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
    margin-top: 15px;
}

.summer-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 12px;
    border: 1px solid #f1f2f6;
    border-bottom: 4px solid #ff9f43;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.summer-card .author {
    font-size: 0.75rem;
    color: #ee5253;
    font-weight: 800;
    text-transform: uppercase;
}

.summer-card .title {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 4px 0 10px 0;
    color: #2d3436;
}

.download-box {
    display: flex;
    gap: 6px;
}

.dl-btn {
    flex: 1;
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 6px;
    border-radius: 6px;
    text-align: center;
    transition: transform 0.1s;
}

.dl-pdf { background: #ffeaa7; color: #d35400; border: 1px solid #f39c12; }
.dl-epub { background: #dff9fb; color: #0984e3; border: 1px solid #74b9ff; }
.dl-btn:active { transform: scale(0.96); }

/* ===================================================
   8. МОДАЛЬНЕ ВІКНО: РОЗКЛАД НА ТИЖДЕНЬ
   =================================================== */
/* Кнопка відкриття попапу */
.btn-weekly {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;                  /* Розтягуємо на всю ширину правої колонки */
    background: #ffffff;
    color: #2c3e50;
    border: 1px solid #dbe2e8;
    border-radius: 12px;
    padding: 10px 15px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    margin-bottom: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
    transition: all 0.2s ease;
}
.btn-weekly:hover {
    background: #f8f9fa;
    border-color: #1e90ff;
    color: #1e90ff;
}

.btn-weekly:active {
    transform: translateY(1px);
    background: #edf2f7;
}

/* Фон затемнення */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 15px;
}
.modal-overlay.show { display: flex; }

/* Вікно попапу */
.modal-content {
    background: #f8f9fa;
    border-radius: 16px;
    max-width: 950px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    animation: modalIn 0.25s ease-out;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Кнопка закриття */
.modal-close {
    position: absolute;
    top: 15px; right: 18px;
    font-size: 1.8rem;
    font-weight: bold;
    color: #7f8c8d;
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
}
.modal-close:hover { color: #ff4757; }

/* Сітка днів */
.weekly-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

/* Картка дня */
.day-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 12px 14px;
    border: 1px solid #e1e8ed;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}
.day-card.today {
    border: 2px solid #1e90ff;
    box-shadow: 0 4px 12px rgba(30, 144, 255, 0.15);
}

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 800;
    font-size: 1rem;
    color: #2c3e50;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 2px solid #f1f2f6;
}

.today-badge {
    background: #1e90ff;
    color: white;
    font-size: 0.65rem;
    padding: 2px 7px;
    border-radius: 10px;
    text-transform: uppercase;
    font-weight: 800;
}

/* Рядок уроку в попапі */
.timetable-row {
    display: flex;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px dashed #f0f2f5;
    font-size: 0.85rem;
    gap: 8px;
}
.timetable-row:last-child { border-bottom: none; }

.tt-num {
    font-weight: 800;
    font-size: 0.75rem;
    color: #1e90ff;
    min-width: 15px;
}
.tt-time {
    font-size: 0.72rem;
    color: #7f8c8d;
    font-weight: 600;
    white-space: nowrap;
    min-width: 80px;
}
.tt-subject {
    font-weight: 600;
    color: #2f3542;
    display: flex;
    align-items: center;
    gap: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Блок прикріплених файлів у ДЗ */
.hw-attachments {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
    align-items: center;
}

/* Прев'ю картинок */
.hw-img-preview {
    display: block;
    width: 70px;
    height: 70px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #dbe2e8;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.hw-img-preview:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.hw-img-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Бейдж для PDF та документів */
.hw-file-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 8px 12px;
    border-radius: 8px;
    background: #f1f2f6;
    color: #2f3542;
    border: 1px solid #dfe4ea;
    transition: all 0.2s ease;
}
.hw-file-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 6px rgba(0,0,0,0.08);
}

/* Кольорові акценти для популярних форматів */
.hw-file-pdf {
    background: #ffeaa7;
    color: #d63031;
    border-color: #fdcb6e;
}
.hw-file-doc {
    background: #e3f2fd;
    color: #0984e3;
    border-color: #74b9ff;
}
.hw-file-zip {
    background: #f8efba;
    color: #b33939;
    border-color: #e55039;
}