/* =================================================== */
/* --- 1. ОБЩИЕ СТИЛИ И ПЕРЕМЕННЫЕ --- */
/* =================================================== */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

:root {
    --primary-color: #483644;
    --secondary-color: #6D5C67;
    --background-color: #f4f4f8;
    --card-bg: #ffffff;
    --text-color: #333;
    --light-text: #888;
    --danger-color: #e74c3c;
    --danger-hover-color: #c0392b;
    --success-color: #2ecc71;
    --border-color: #e0e0e0;
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    margin: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    -webkit-tap-highlight-color: transparent;
}

.hidden {
    display: none !important;
}

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

.screen {
    min-height: 100vh;
    box-sizing: border-box;
}

.error {
    color: var(--danger-color);
    text-align: center;
    margin-top: 1rem;
    font-weight: 500;
}

.loader {
    border: 4px solid #f3f3f3;
    border-radius: 50%;
    border-top: 4px solid var(--secondary-color);
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 3rem auto;
}

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

/* =================================================== */
/* --- 2. СТАНДАРТНЫЕ UI-ЭЛЕМЕНТЫ (КНОПКИ, ПОЛЯ ВВОДА) --- */
/* =================================================== */

button {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 8px;
    width: 100%;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s;
    -webkit-appearance: none;
}

button:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
    opacity: 0.7;
}

button:hover:not(:disabled) {
    background-color: #5a4b54;
}

.button-secondary {
    background-color: #aaa;
}

.button-secondary:hover:not(:disabled) {
    background-color: #888;
}

.button-danger {
    background-color: var(--danger-color);
}

.button-danger:hover:not(:disabled) {
    background-color: var(--danger-hover-color);
}

input[type="text"],
input[type="email"],
input[type="password"] {
    display: block;
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
}

input:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(109, 92, 103, 0.2);
    outline: none;
}

/* =================================================== */
/* --- 3. ОСНОВНОЙ ХЕДЕР ПРИЛОЖЕНИЯ --- */
/* =================================================== */

.main-header {
    background-color: var(--primary-color);
    color: white;
    padding: 0 1rem;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-logo {
    height: 36px;
    opacity: 0.9;
}

.header-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    max-width: 65%; /* Немного увеличим доступное место */
    
    /* Превращаем в контейнер для двух строк */
    display: flex;
    flex-direction: column; /* Элементы друг под другом */
    align-items: center;   /* Центрируем по горизонтали */
    justify-content: center; /* Центрируем по вертикали */
    line-height: 1.2; /* Уменьшаем межстрочный интервал */
}

.header-button {
    background: none;
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    font-size: 1.4rem;
    line-height: 44px;
    padding: 0;
    cursor: pointer;
    border-radius: 50%;
    transition: background-color 0.2s;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.header-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.profile-avatar-btn {
    padding: 0;
    background: none;
    border: 2px solid rgba(255, 255, 255, 0.5);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
}

.profile-avatar-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.date-nav {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.date-nav button {
    width: auto;
    padding: 8px 12px;
    background-color: var(--primary-color);
    font-size: 0.9rem;
}

#today-button {
    background-color: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

/* =================================================== */
/* --- 4. ЭКРАНЫ ПРИЛОЖЕНИЯ --- */
/* =================================================== */

/* --- 4.1. ЭКРАН ЛОГИНА --- */
#login-screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.app-header {
    text-align: center;
    margin-bottom: 2rem;
}

.app-header .logo {
    width: 80px;
    height: 80px;
}

.app-header h1 {
    margin-top: 0.5rem;
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 700;
}

/* --- 4.2. ЭКРАН КУРСОВ --- */
.course-list-item {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border: 1px solid var(--border-color);
}

.course-list-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
    border-color: var(--secondary-color);
}

.course-list-item h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.course-list-item .description {
    color: var(--light-text);
    font-size: 0.9rem;
    margin: 0;
}

/* --- 4.3. ЭКРАН РАСПИСАНИЯ --- */
#schedule-container {
    display: grid;
    gap: 1rem;
}

.lesson-card-new {
    background-color: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.lesson-card-new:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
}

.lesson-card-new .indicator {
    flex-shrink: 0;
    width: 8px;
}

.lesson-card-new .content {
    padding: 1rem;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.lesson-card-new .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.lesson-card-new .time {
    font-size: 0.9rem;
    color: var(--light-text);
    font-weight: 500;
}

.lesson-card-new .cancel-lesson-btn {
    width: auto; /* <-- ВОТ ЭТО ИСПРАВЛЕНИЕ */
    font-size: 0.85rem;
    padding: 0.25rem 0.7rem;
    background-color: transparent;
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
    flex-shrink: 0;
}

.lesson-card-new .cancel-lesson-btn:hover {
    background-color: var(--danger-color);
    color: #fff;
}

.lesson-card-new .topic {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0 0 0.25rem 0;
    color: var(--text-color);
}

.lesson-card-new .group {
    font-size: 1rem;
    color: var(--secondary-color);
    margin: 0 0 1rem 0;
}

.lesson-card-new .footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.lesson-card-new .action-text {
    font-weight: 600;
    color: var(--primary-color);
}

.lesson-card-new .action-arrow {
    font-size: 1.5rem;
    color: var(--primary-color);
    transition: transform 0.2s;
}

.lesson-card-new:hover .action-arrow {
    transform: translateX(5px);
}

.lesson-card-new.cancelled {
    background-color: #f8f9fa;
    opacity: 0.7;
    cursor: default;
}

.lesson-card-new.cancelled:hover {
    transform: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.lesson-card-new .cancelled-indicator {
    background-color: var(--danger-color);
    color: white;
    padding: 1rem;
    text-align: center;
    font-weight: 500;
}

/* --- 4.4. ЭКРАН ЖУРНАЛА --- */
.journal-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 1rem;
}

.journal-actions button {
    flex: 1;
    padding: 10px;
    font-size: 0.9rem;
}

.participant-row {
    display: flex;
    align-items: center;
    padding: 12px 1rem;
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
}
.participant-row:first-child { border-top-left-radius: 12px; border-top-right-radius: 12px; }
.participant-row:last-child { border-bottom: none; border-bottom-left-radius: 12px; border-bottom-right-radius: 12px; }

.participant-name {
    flex-grow: 1;
    font-weight: 500;
    padding-right: 1rem;
}

.mark-input {
    width: 30%;
    max-width: 80px;
    height: 40px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: bold;
    border: 1px solid #ccc;
    border-radius: 8px;
    flex-shrink: 0;
    -webkit-appearance: none;
}

.mark-P { background-color: #cff4fc; }
.mark-N { background-color: #f8d7da; }

.saving-indicator {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ccc;
    border-top-color: var(--secondary-color);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 8px;
}

/* --- 4.5. ЭКРАН ПРОФИЛЯ --- */
.profile-form {
    display: flex;
    flex-direction: column;
}

.profile-form .form-group {
    margin-bottom: 1.5rem;
}

.profile-form label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    display: block;
}

.avatar-upload-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
}

#profile-avatar-preview {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--card-bg);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
}

#change-avatar-btn {
    width: auto;
    font-size: 0.9rem;
}

.button-logout {
    margin-top: 1rem;
    padding: 0.8rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--danger-color);
    background-color: transparent;
    border: 1px solid var(--danger-color);
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.button-logout:hover {
    background-color: var(--danger-color);
    color: #fff;
}

/* =================================================== */
/* --- 5. КОМПОНЕНТЫ И УВЕДОМЛЕНИЯ --- */
/* =================================================== */

.empty-state {
    text-align: center;
    color: var(--light-text);
    padding: 3rem 1rem;
    background-color: var(--card-bg);
    border-radius: 12px;
}

.notification-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
    z-index: 1000;
    transform: translateY(100%);
    transition: transform 0.3s ease-in-out;
}

.notification-banner.show {
    transform: translateY(0);
}

.notification-banner p {
    margin: 0;
}

.notification-banner button {
    width: auto;
    padding: 8px 16px;
    background-color: var(--success-color);
}


/* =================================================== */
/* --- 6. ОТЛАДОЧНАЯ КОНСОЛЬ --- */
/* =================================================== */

#debug-console-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--danger-color);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    z-index: 2000;
    font-size: 1.5rem;
    padding: 0;
    line-height: 50px;
    text-align: center;
}

.debug-console {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40vh;
    background-color: #1e1e1e;
    color: #d4d4d4;
    font-family: monospace;
    z-index: 1999;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -4px 10px rgba(0,0,0,0.2);
    transform: translateY(100%);
    transition: transform 0.3s ease-in-out;
}

.debug-console.show {
    transform: translateY(0);
}

.debug-console .debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background-color: #333;
    font-weight: bold;
    flex-shrink: 0;
}

.debug-console .debug-header button {
    width: auto;
    background: #555;
    color: white;
    padding: 4px 10px;
    font-size: 0.8rem;
    border-radius: 5px;
}

#debug-console-log {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
    font-size: 0.9rem;
}

.log-entry {
    padding: 4px 0;
    border-bottom: 1px solid #444;
    white-space: pre-wrap;
    word-break: break-all;
}

.log-entry.log-error { color: #f48771; }
.log-entry.log-warn { color: #f9d678; }
.log-entry.log-info { color: #80bfff; }
.header-course-name,
.header-date-display {
    width: 100%;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-course-name {
    font-size: 1rem; /* Можно сделать чуть меньше базового */
    font-weight: 500;
    color: #ffffff;
}

.header-date-display {
    font-size: 0.8rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.8); /* Делаем дату менее заметной */
}