/* =========================================================
   School Homework — система дизайна
   Палитра: indigo→violet бренд, нейтральный slate, мягкие тени.
   ========================================================= */

:root {
  /* Бренд (indigo / violet) */
  --brand-50:  #eef2ff;
  --brand-100: #e0e7ff;
  --brand-200: #c7d2fe;
  --brand-400: #818cf8;
  --brand-500: #6366f1;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;
  --brand-grad: linear-gradient(135deg, #6366f1 0%, #7c3aed 55%, #9333ea 100%);

  /* Нейтральные (slate) */
  --bg:        #f6f7fb;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --border:    #e7e9f0;
  --border-strong: #d4d8e3;
  --text:      #1e2330;
  --text-soft: #475069;
  --text-mut:  #8b93a7;

  /* Семантика */
  --success:   #10b981;
  --success-bg:#ecfdf5;
  --warning:   #f59e0b;
  --warning-bg:#fffbeb;
  --danger:    #ef4444;
  --danger-bg: #fef2f2;
  --info:      #3b82f6;

  /* Радиусы / тени */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-pill: 999px;
  --shadow-xs: 0 1px 2px rgba(16,24,40,.05);
  --shadow-sm: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
  --shadow-md: 0 8px 24px -6px rgba(16,24,40,.12), 0 2px 6px rgba(16,24,40,.06);
  --shadow-lg: 0 24px 48px -12px rgba(49,33,120,.28);

  --ring: 0 0 0 3px rgba(99,102,241,.28);
}

* { box-sizing: border-box; }

/* Атрибут hidden должен скрывать элемент даже если у него задан display
   (иначе .auth-screen{display:grid} перекрыл бы [hidden]). */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }

button { font-family: inherit; }

/* =========================================================
   Бренд-лого
   ========================================================= */
.brand { display: flex; align-items: center; gap: 10px; }
.brand__mark {
  display: inline-grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 11px;
  background: var(--brand-grad);
  color: #fff;
  box-shadow: var(--shadow-md);
}
.brand__name { font-weight: 800; font-size: 1.05rem; letter-spacing: -0.02em; }
.brand--sm .brand__mark { width: 34px; height: 34px; border-radius: 9px; }

/* =========================================================
   ЭКРАН ВХОДА
   ========================================================= */
.auth-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}

/* Левая брендовая панель */
.auth-brand {
  position: relative;
  overflow: hidden;
  background: var(--brand-grad);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 56px;
}
.auth-brand__inner { position: relative; z-index: 1; max-width: 460px; }
.auth-brand .brand__mark {
  background: rgba(255,255,255,.16);
  backdrop-filter: blur(4px);
  box-shadow: none;
}
.auth-brand .brand { margin-bottom: 48px; }
.auth-brand__title {
  font-size: 2.4rem;
  font-weight: 800;
  margin: 0 0 16px;
}
.auth-brand__subtitle {
  font-size: 1.05rem;
  line-height: 1.6;
  color: rgba(255,255,255,.85);
  margin: 0;
}
/* Декоративное свечение */
.auth-brand__glow {
  position: absolute;
  width: 520px; height: 520px;
  right: -160px; bottom: -200px;
  background: radial-gradient(circle, rgba(255,255,255,.22), transparent 70%);
  pointer-events: none;
}

/* Правая панель с формой */
.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 40px 24px;
  background:
    radial-gradient(60% 50% at 80% 0%, var(--brand-50), transparent 70%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 408px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 32px;
  box-shadow: var(--shadow-md);
}
.auth-switch { text-align: center; color: var(--text-mut); font-size: .9rem; margin: 4px 0 0; }
.auth-footnote { margin-top: 24px; color: var(--text-mut); font-size: .8rem; }
.link {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--brand-600); font-weight: 600; font-size: inherit;
}
.link:hover { text-decoration: underline; }

/* =========================================================
   APP SHELL
   ========================================================= */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 28px;
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.user-info { display: flex; align-items: center; gap: 14px; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 12px 5px 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: var(--brand-grad); color: #fff;
  font-weight: 700; font-size: .85rem;
  text-transform: uppercase;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta__name { font-weight: 600; font-size: .9rem; }

.badge {
  align-self: flex-start;
  background: var(--brand-100);
  color: var(--brand-700);
  padding: 1px 8px;
  border-radius: var(--r-pill);
  font-size: .7rem;
  font-weight: 600;
  text-transform: capitalize;
  letter-spacing: .02em;
}

/* =========================================================
   Контейнер
   ========================================================= */
.container {
  max-width: 900px;
  margin: 28px auto;
  padding: 0 20px;
}

/* =========================================================
   Карточки
   ========================================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.card__head { margin-bottom: 18px; }
.card__head h2 { margin: 0; font-size: 1.15rem; font-weight: 700; }
.card__sub { margin: 4px 0 0; color: var(--text-mut); font-size: .88rem; }

/* =========================================================
   Auth-вкладки (Вход / Регистрация)
   ========================================================= */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 22px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 4px;
}
.tab {
  flex: 1;
  background: none; border: none;
  padding: 9px 16px;
  cursor: pointer;
  font-size: .92rem; font-weight: 600;
  color: var(--text-mut);
  border-radius: var(--r-pill);
  transition: all .18s ease;
}
.tab.active { color: var(--brand-700); background: var(--surface); box-shadow: var(--shadow-xs); }

.tab-content { display: none; flex-direction: column; gap: 14px; }
.tab-content.active { display: flex; }

/* =========================================================
   Role-tabs (сегментированная навигация внутри роли)
   ========================================================= */
.role-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 22px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-xs);
  overflow-x: auto;
}
.role-tab {
  background: none; border: none;
  padding: 9px 18px;
  cursor: pointer;
  font-size: .9rem; font-weight: 600;
  color: var(--text-mut);
  border-radius: var(--r-pill);
  white-space: nowrap;
  transition: all .18s ease;
}
.role-tab:hover { color: var(--text); }
.role-tab.active { color: #fff; background: var(--brand-600); box-shadow: var(--shadow-sm); }

/* =========================================================
   Панели
   ========================================================= */
.panel { display: none; animation: fade-in .25s ease; }
.panel.active { display: block; }
@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   Формы
   ========================================================= */
form { display: flex; flex-direction: column; gap: 16px; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-soft);
}
.hint { color: var(--text-mut); font-weight: 400; font-size: .78rem; }
.hint-block {
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
  border-left: 3px solid var(--brand-500);
  padding: 12px 14px;
  border-radius: var(--r-sm);
  font-size: .9rem;
  color: var(--text-soft);
  margin: 0 0 6px;
}

input, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  font-size: .95rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input::placeholder { color: var(--text-mut); }
input:focus, select:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: var(--ring);
}
input[type="file"] { padding: 8px 12px; cursor: pointer; }

.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row label { flex: 1; min-width: 150px; }

.filter-row {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.filter-row label { flex: 1; min-width: 150px; }

/* =========================================================
   Кнопки
   ========================================================= */
.btn-primary {
  background: var(--brand-600);
  color: #fff;
  border: none;
  padding: 11px 20px;
  border-radius: var(--r-sm);
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-start;
  box-shadow: var(--shadow-xs);
  transition: transform .12s ease, background .15s ease, box-shadow .15s ease;
}
.btn-primary:hover { background: var(--brand-700); box-shadow: var(--shadow-sm); }
.btn-primary:active { transform: translateY(1px); }
.btn-block { width: 100%; align-self: stretch; text-align: center; }

.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text-soft);
  padding: 8px 14px;
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: .85rem;
  cursor: pointer;
  transition: all .15s ease;
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--text-mut); color: var(--text); }

.btn-small {
  padding: 6px 12px;
  font-size: .8rem;
  font-weight: 600;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  transition: all .15s ease;
}
.btn-small:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { border-color: #f4b4b4; color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); }

.btn-outline {
  padding: 6px 14px;
  font-size: .8rem;
  font-weight: 600;
  border-radius: var(--r-sm);
  border: 1px solid var(--brand-200);
  background: var(--brand-50);
  color: var(--brand-700);
  cursor: pointer;
  transition: all .15s ease;
}
.btn-outline:hover { background: var(--brand-100); border-color: var(--brand-400); }

/* Кнопка-ссылка для скачивания */
.download-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .82rem; font-weight: 600;
  color: var(--brand-600);
  text-decoration: none;
}
.download-link:hover { text-decoration: underline; }
.download-link svg { width: 15px; height: 15px; }

/* =========================================================
   Списки заданий / работ / заявок
   ========================================================= */
.item-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.item-list > li {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px 18px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .15s ease, box-shadow .15s ease, transform .12s ease;
}
.item-list > li:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.item-list > li.empty {
  align-items: center;
  text-align: center;
  color: var(--text-mut);
  font-size: .9rem;
  border-style: dashed;
  background: var(--surface-2);
}
.item-title { font-weight: 700; font-size: .98rem; }
.item-meta { color: var(--text-mut); font-size: .84rem; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.item-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* =========================================================
   Чипы-статусы
   ========================================================= */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: .74rem; font-weight: 600;
  border: 1px solid transparent;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip--pending { background: var(--warning-bg); color: #b45309; border-color: #fde68a; }
.chip--graded  { background: var(--success-bg); color: #047857; border-color: #a7f3d0; }
.chip--neutral { background: var(--surface-2); color: var(--text-soft); border-color: var(--border); }

/* =========================================================
   Оценки
   ========================================================= */
.grade-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grade-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border-radius: 9px;
  font-weight: 700; font-size: .92rem;
  color: #fff;
  flex-shrink: 0;
}
.grade-1, .grade-2 { background: var(--danger); }
.grade-3 { background: var(--warning); }
.grade-4 { background: var(--info); }
.grade-5 { background: var(--success); }

.grade-input {
  width: 84px;
  padding: 7px 10px;
}

/* =========================================================
   Таблица расписания
   ========================================================= */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); }
.sched-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.sched-table th, .sched-table td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.sched-table th {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--text-soft);
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.sched-table tbody tr:last-child td { border-bottom: none; }
.sched-table tbody tr:hover { background: var(--brand-50); }

/* =========================================================
   Toast
   ========================================================= */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  padding: 13px 18px;
  border-radius: var(--r-md);
  color: #fff;
  font-size: .9rem; font-weight: 500;
  z-index: 100;
  max-width: 340px;
  box-shadow: var(--shadow-lg);
  animation: toast-in .25s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.toast.success { background: #059669; }
.toast.error   { background: #dc2626; }

/* =========================================================
   Адаптивность
   ========================================================= */
@media (max-width: 880px) {
  .auth-screen { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-panel {
    min-height: 100vh;
    background:
      radial-gradient(80% 40% at 50% 0%, var(--brand-100), transparent 70%),
      var(--bg);
  }
}
@media (max-width: 560px) {
  .topbar { padding: 10px 16px; }
  .brand--sm .brand__name { display: none; }
  .card { padding: 18px; }
  .auth-card { padding: 24px; }
  .user-meta__name { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
