/* =========================================================
   Реестр домашних заданий — тёплая палитра, мобильная адаптация
   ========================================================= */

[hidden] { display: none !important; }

:root {
  --bg:            #fdf7f1;
  --bg-soft:       #fbf1e6;
  --surface:       #ffffff;
  --surface-2:     #fdf2e9;

  --primary:       #d97757;
  --primary-dark:  #b95f42;
  --primary-soft:  #f7e2d6;

  --text:          #3a2e26;
  --text-muted:    #8b7a6b;

  --border:        #efe1d3;
  --border-strong: #e2cdb8;

  --success:       #6b9b7a;
  --danger:        #c9584a;
  --danger-soft:   #fbe3df;

  --radius:        16px;
  --radius-sm:     10px;
  --shadow:        0 6px 24px rgba(150, 100, 70, 0.09);
  --shadow-sm:     0 2px 10px rgba(150, 100, 70, 0.07);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  background-image:
    radial-gradient(circle at 0% 0%, rgba(217, 119, 87, 0.10), transparent 45%),
    radial-gradient(circle at 100% 100%, rgba(217, 119, 87, 0.08), transparent 45%);
  background-attachment: fixed;
}

button { font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ---------- Общие элементы ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 16px rgba(217, 119, 87, 0.28);
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-outline {
  background: transparent;
  color: var(--primary-dark);
  border: 1.5px solid var(--border-strong);
}
.btn-outline:hover { background: var(--surface-2); border-color: var(--primary); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid transparent;
}
.btn-ghost:hover { background: rgba(0,0,0,0.04); color: var(--text); }

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-small { padding: 8px 14px; font-size: 14px; }
.btn-block { width: 100%; }

/* ---------- Экран входа ---------- */

.screen { min-height: 100vh; }

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: 24px;
  padding: 40px 28px 32px;
  box-shadow: var(--shadow);
  text-align: center;
  border: 1px solid var(--border);
}

.logo-circle {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--primary-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  margin: 0 auto 18px;
}

.app-title {
  font-size: 26px;
  font-weight: 800;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}
.app-subtitle {
  color: var(--text-muted);
  margin: 0 0 28px;
  font-size: 15px;
}

.login-form { text-align: left; }

.field { display: block; margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.field-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 6px 0 0;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="file"],
textarea,
select {
  width: 100%;
  padding: 13px 15px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 16px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(217, 119, 87, 0.13);
}
textarea { resize: vertical; min-height: 100px; }

input[type="file"] {
  padding: 10px;
  background: var(--surface-2);
  font-size: 14px;
  cursor: pointer;
}

.login-error {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

.group-choice { margin-top: 22px; text-align: left; }
.group-choice-title {
  font-weight: 600;
  margin: 0 0 12px;
  font-size: 15px;
  text-align: center;
  color: var(--text-muted);
}
.group-choice-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.group-choice-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: all .15s ease;
}
.group-choice-item:hover {
  border-color: var(--primary);
  background: var(--surface-2);
  transform: translateY(-1px);
}
.group-choice-item .gc-name { font-weight: 700; }
.group-choice-item .gc-group { font-size: 13px; color: var(--text-muted); }

/* ---------- Экран ДЗ ученика ---------- */

.app-header {
  background: linear-gradient(135deg, #ffffff 0%, #fdf2e9 100%);
  border-bottom: 1px solid var(--border);
  padding: 20px 20px 0;
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(8px);
}
.app-header-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.header-hello {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.header-group {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 2px;
}
.nearest-lesson {
  max-width: 720px;
  margin: 14px auto 0;
  padding: 10px 0 14px;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.nearest-lesson::before {
  content: "🗓";
  font-size: 15px;
}

.homework-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.homework-list { display: flex; flex-direction: column; gap: 20px; }

.hw-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  animation: cardIn .35s ease both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hw-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--surface-2) 0%, #fff 100%);
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}
.hw-date-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  color: var(--primary-dark);
}
.hw-date-badge .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary);
}
.hw-status {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 100px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.hw-status.today    { background: var(--primary-soft); color: var(--primary-dark); }
.hw-status.upcoming { background: #e5f1e8; color: var(--success); }
.hw-status.done     { background: #efe6df; color: var(--text-muted); }

.hw-card-body { padding: 20px; }
.hw-text {
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0 0 16px;
  font-size: 16px;
  line-height: 1.6;
}
.hw-text:empty { display: none; }

.hw-links { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.hw-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 100px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--primary-dark);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: all .15s ease;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hw-link:hover { background: var(--primary-soft); border-color: var(--primary); }
.hw-link::before { content: "🔗"; font-size: 13px; }

.hw-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 4px;
}
.hw-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.hw-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .25s ease;
}
.hw-thumb:hover img { transform: scale(1.06); }

/* =========================================================
   Аккордеон «Прошедшие задания»
   ========================================================= */

.past-accordion {
  margin-top: 8px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  animation: cardIn .35s ease both;
}

.past-accordion-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  transition: background .15s ease;
}
.past-accordion-head:hover { background: var(--surface-2); }
.past-accordion-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.past-accordion-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-2);
  border-radius: 100px;
  padding: 2px 9px;
}
.past-accordion-chev {
  font-size: 12px;
  color: var(--text-muted);
  transition: transform .2s ease;
}
.past-accordion.open .past-accordion-chev { transform: rotate(180deg); }

.past-accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .28s ease;
  border-top: 1px solid transparent;
}
.past-accordion.open .past-accordion-body {
  max-height: 5000px; /* большой потолок для плавности */
  border-top-color: var(--border);
}

.past-item {
  border-bottom: 1px solid var(--border);
}
.past-item:last-child { border-bottom: none; }

.past-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  cursor: pointer;
  user-select: none;
  transition: background .15s ease;
  gap: 12px;
}
.past-item-head:hover { background: var(--surface-2); }

.past-item-date {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}
.past-item-date .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.past-item-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
}
.past-item-meta .badge {
  background: var(--surface-2);
  border-radius: 100px;
  padding: 2px 8px;
  font-weight: 600;
}
.past-item-chev {
  font-size: 11px;
  color: var(--text-muted);
  transition: transform .2s ease;
}
.past-item.open .past-item-chev { transform: rotate(180deg); }

.past-item-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .28s ease;
  padding: 0 20px;
}
.past-item.open .past-item-body {
  max-height: 5000px;
  padding-bottom: 18px;
}
.past-item-body .hw-text { font-size: 15px; }
.past-item-body .hw-images { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }

/* ---------- Пустое состояние, загрузка ---------- */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-emoji { font-size: 48px; margin-bottom: 10px; }

.loading { display: flex; justify-content: center; padding: 40px; }
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Лайтбокс ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(30, 20, 15, 0.92);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.lightbox-image-wrap {
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.lightbox-image-wrap img {
  max-width: 100%;
  max-height: calc(100vh - 160px);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  background: #fff;
  user-select: none;
}
.lightbox-counter {
  color: rgba(255,255,255,0.75);
  font-size: 14px;
  font-weight: 600;
}
.lightbox-close {
  position: absolute;
  top: 16px; right: 20px;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: none;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s;
}
.lightbox-close:hover { background: rgba(255,255,255,0.25); }

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px; height: 52px;
  border-radius: 50%;
  background: rgba(255,255,255,0.14);
  color: #fff;
  border: none;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s;
  padding-bottom: 4px;
}
.lightbox-nav:hover { background: rgba(255,255,255,0.28); }
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
.lightbox-nav[disabled] { opacity: 0.25; cursor: default; }

/* =========================================================
   АДМИНКА
   ========================================================= */

.admin-dashboard {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 100vh;
}

.admin-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px;
}
.sidebar-title { font-weight: 800; font-size: 17px; }
.groups-list { display: flex; flex-direction: column; gap: 6px; flex: 1; }

.group-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  border: 1.5px solid transparent;
  background: transparent;
  color: var(--text);
  text-align: left;
  transition: all .13s ease;
  width: 100%;
}
.group-item:hover { background: var(--surface-2); }
.group-item.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-dark);
}
.group-item .g-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(0,0,0,0.05);
  border-radius: 100px;
  padding: 2px 8px;
}
.group-item.active .g-count { background: rgba(255,255,255,0.7); color: var(--primary-dark); }

.sidebar-footer { padding-top: 8px; border-top: 1px solid var(--border); }

.admin-main { padding: 28px 32px 60px; overflow-x: hidden; }

.group-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.group-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.group-title { font-size: 26px; font-weight: 800; margin: 0; letter-spacing: -0.02em; }
.group-subtitle { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

.admin-section {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.section-title { font-size: 17px; font-weight: 700; margin: 0; }

.inline-form {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.inline-form input { flex: 1; }

.students-list { display: flex; flex-wrap: wrap; gap: 8px; }
.student-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 8px 14px;
  border-radius: 100px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
}
.student-chip button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  transition: color .15s;
}
.student-chip button:hover { color: var(--danger); }

.homeworks-list { display: flex; flex-direction: column; gap: 12px; }

.hw-admin-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: box-shadow .15s ease;
  flex-wrap: wrap;
}
.hw-admin-item:hover { box-shadow: var(--shadow-sm); }
.hw-admin-info { flex: 1; min-width: 200px; }
.hw-admin-date {
  font-weight: 700;
  color: var(--primary-dark);
  font-size: 15px;
  margin-bottom: 4px;
}
.hw-admin-preview {
  color: var(--text-muted);
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.hw-admin-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}
.hw-admin-actions { display: flex; gap: 6px; }

/* ---------- Модальное окно ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(40, 25, 18, 0.45);
  backdrop-filter: blur(2px);
  animation: fadeIn .15s ease;
}
.modal-card {
  position: relative;
  background: var(--surface);
  border-radius: 20px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,0.25);
  animation: modalIn .22s ease;
  overflow: hidden;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 18px; font-weight: 700; margin: 0; }
.modal-close {
  border: none;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.links-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.link-row { display: grid; grid-template-columns: 1fr 1fr 40px; gap: 8px; align-items: center; }
.link-row input { padding: 10px 12px; font-size: 14px; }
.link-remove {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}
.link-remove:hover { color: var(--danger); }

.existing-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.existing-image {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.existing-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.existing-image button {
  position: absolute;
  top: 4px; right: 4px;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.existing-image button:hover { background: var(--danger); }

/* =========================================================
   Мобильная адаптация
   ========================================================= */

@media (max-width: 820px) {
  .admin-dashboard { grid-template-columns: 1fr; }
  .admin-sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .groups-list { max-height: 260px; }
  .admin-main { padding: 20px 16px 60px; }
  .group-title { font-size: 22px; }
}

@media (max-width: 560px) {
  .login-card { padding: 32px 20px 26px; border-radius: 20px; }
  .app-title { font-size: 22px; }

  .app-header { padding: 16px 16px 0; }
  .homework-container { padding: 18px 14px 50px; }
  .hw-card-body { padding: 16px; }
  .hw-card-head { padding: 14px 16px; }
  .hw-images { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }

  .link-row { grid-template-columns: 1fr 40px; }
  .link-row .link-label-input { grid-column: 1 / -1; }

  .lightbox-nav { width: 44px; height: 44px; font-size: 28px; }
  .lightbox-prev { left: 6px; }
  .lightbox-next { right: 6px; }

  .inline-form { flex-direction: column; }
  .section-head { flex-wrap: wrap; }

  .past-accordion-head { padding: 14px 16px; }
  .past-item-head { padding: 12px 16px; }
  .past-item-body { padding: 0 16px; }
  .past-item.open .past-item-body { padding-bottom: 16px; }
  .past-item-meta { display: none; }
}
