/*
 * StudyVerse — Sidebar Layout
 * Боковая панель для кабинета ученика, учителя и родителя.
 * Подключать ПОСЛЕ base.css: <link rel="stylesheet" href="{% static 'sidebar.css' %}">
 */

/* ═══════════════════════════════════════════
   LAYOUT SHELL
   ═══════════════════════════════════════════ */
.sv-app {
  display: flex;
  min-height: 100vh;
}

/* ═══════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════ */
.sv-sidebar {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  scrollbar-width: none;
}

.sv-sidebar::-webkit-scrollbar { display: none; }

/* Логотип */
.sv-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.sv-sidebar__logo {
  height: 34px;
  width: auto;
}

.sv-sidebar__brand-text {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* Навигационные секции */
.sv-sidebar__section {
  padding: 12px 10px 4px;
}

.sv-sidebar__section-label {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 0 10px;
  margin-bottom: 4px;
}

/* Ссылки */
.sv-sidebar__nav {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sv-sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
  transition: background var(--tr), color var(--tr);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sv-sidebar__link:hover {
  background: var(--accent-light);
  color: var(--accent-deep);
}

.sv-sidebar__link.active {
  background: linear-gradient(135deg, var(--accent-light), #d0e9ff);
  color: var(--accent-deep);
}

.sv-sidebar__link.active .sv-sidebar__icon {
  color: var(--accent);
}

.sv-sidebar__link--danger:hover {
  background: var(--error-bg);
  color: var(--error);
}

.sv-sidebar__icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--ink-muted);
  transition: color var(--tr);
}

.sv-sidebar__link:hover .sv-sidebar__icon,
.sv-sidebar__link.active .sv-sidebar__icon {
  color: inherit;
}

/* Бейдж уведомлений */
.sv-sidebar__badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  border-radius: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sv-sidebar__badge--red { background: var(--error); }
.sv-sidebar__badge--yellow { background: var(--warn); }

/* Разделитель */
.sv-sidebar__divider {
  height: 1px;
  background: var(--line);
  margin: 8px 10px;
}

/* Блок пользователя внизу */
.sv-sidebar__user {
  margin-top: auto;
  padding: 12px 10px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.sv-sidebar__user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--r-md);
  background: var(--bg);
  transition: background var(--tr);
}

.sv-sidebar__user-card:hover {
  background: var(--accent-light);
}

.sv-sidebar__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--line);
}

.sv-sidebar__user-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sv-sidebar__user-role {
  font-size: 0.75rem;
  color: var(--ink-muted);
  white-space: nowrap;
}

/* ═══════════════════════════════════════════
   MAIN CONTENT AREA
   ═══════════════════════════════════════════ */
.sv-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Topbar внутри кабинета */
.sv-topbar {
  height: 60px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 90;
  flex-shrink: 0;
}

.sv-topbar__title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--ink);
  flex: 1;
}

.sv-topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Кнопка бургера (мобайл) */
.sv-sidebar__burger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  margin-right: 4px;
  flex-shrink: 0;
  flex-direction: column;
  gap: 5px;
  border-radius: var(--r-sm);
}

.sv-sidebar__burger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: transform var(--tr), opacity var(--tr);
}

.sv-sidebar__burger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.sv-sidebar__burger.open span:nth-child(2) { opacity: 0; }
.sv-sidebar__burger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Контент страницы */
.sv-page {
  flex: 1;
  padding: 28px 28px 40px;
  max-width: 1200px;
  width: 100%;
}

.sv-page--wide {
  max-width: 100%;
}

.sv-page-header {
  margin-bottom: 28px;
}

.sv-page-header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 4px;
}

.sv-page-header p {
  color: var(--ink-muted);
  font-size: 0.9rem;
  margin: 0;
}

/* ═══════════════════════════════════════════
   ОВЕРЛЕЙ ДЛЯ МОБАЙЛА
   ═══════════════════════════════════════════ */
.sv-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 42, 102, 0.4);
  backdrop-filter: blur(4px);
  z-index: 99;
}

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */
@media (max-width: 900px) {
  .sv-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
    z-index: 100;
    box-shadow: var(--shadow-lg);
  }

  .sv-sidebar.open {
    transform: translateX(0);
  }

  .sv-sidebar-overlay.open {
    display: block;
  }

  .sv-sidebar__burger {
    display: flex;
  }

  .sv-topbar {
    padding: 0 16px;
  }

  .sv-page {
    padding: 20px 16px 32px;
  }
}

@media (max-width: 480px) {
  .sv-page {
    padding: 16px 12px 28px;
  }
}

/* ═══════════════════════════════════════════
   СТРАНИЦА АВТОРИЗАЦИИ / РЕГИСТРАЦИИ
   ═══════════════════════════════════════════ */
.auth-shell {
  display: flex;
  min-height: 100vh;
}

.auth-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 40px 32px;
  min-height: 100vh;
}

/* Левая декоративная панель */
.auth-brand {
  background: linear-gradient(145deg, #0a2a66 0%, #1fa2ff 100%);
  color: #fff;
  flex: 0 0 460px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 60px 52px;
  position: relative;
  overflow: hidden;
}

.auth-brand::before {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  top: -150px;
  right: -150px;
  pointer-events: none;
}

.auth-brand::after {
  content: '';
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  bottom: -80px;
  left: -80px;
  pointer-events: none;
}

.auth-brand__logo {
  height: 42px;
  margin-bottom: 48px;
  position: relative;
  z-index: 1;
}

.auth-brand__tagline {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 20px;
  position: relative;
  z-index: 1;
  color: #fff;
}

.auth-brand__tagline span {
  color: var(--sun);
}

.auth-brand__sub {
  font-size: 1rem;
  opacity: 0.8;
  line-height: 1.6;
  margin-bottom: 48px;
  position: relative;
  z-index: 1;
}

.auth-brand__stats {
  display: flex;
  gap: 32px;
  position: relative;
  z-index: 1;
}

.auth-stat__num {
  display: block;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--sun);
}

.auth-stat__label {
  font-size: 0.8rem;
  opacity: 0.75;
}

/* Правая панель с формой */
.auth-form-panel {
  background: var(--bg);
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 48px 40px;
  overflow-y: auto;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--line);
  padding: 40px 40px 36px;
  width: 100%;
  max-width: 440px;
}

.auth-card__head {
  margin-bottom: 28px;
}

.auth-card__title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 6px;
}

.auth-card__sub {
  font-size: 0.9rem;
  color: var(--ink-muted);
  margin: 0;
}

.auth-card__form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-card__footer {
  margin-top: 20px;
  text-align: center;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.auth-card__footer a {
  color: var(--accent-deep);
  font-weight: 700;
}

/* Роль-switcher */
.role-tabs {
  display: flex;
  background: #f1f4fb;
  border-radius: var(--r-md);
  padding: 4px;
  gap: 4px;
}

.role-tab {
  flex: 1;
  padding: 9px 12px;
  border: none;
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
  transition: background var(--tr), color var(--tr), box-shadow var(--tr);
  background: transparent;
  text-align: center;
}

.role-tab.active {
  background: var(--surface);
  color: var(--accent-deep);
  box-shadow: var(--shadow-xs);
}

/* Адаптив auth */
@media (max-width: 1024px) {
  .auth-brand { flex: 0 0 380px; padding: 48px 36px; }
  .auth-brand__tagline { font-size: 1.65rem; }
}

@media (max-width: 768px) {
  .auth-shell { flex-direction: column; }
  .auth-brand {
    flex: 0 0 auto;
    min-height: unset;
    padding: 36px 28px 32px;
    align-items: center;
    text-align: center;
  }
  .auth-brand__stats { justify-content: center; }
  .auth-brand__logo { margin-bottom: 24px; }
  .auth-brand__tagline { font-size: 1.4rem; margin-bottom: 12px; }
  .auth-brand__sub { margin-bottom: 24px; }
  .auth-form-panel { padding: 32px 20px 40px; }
  .auth-card { padding: 28px 24px; max-width: 100%; }
}

@media (max-width: 400px) {
  .auth-card { padding: 24px 18px; border-radius: var(--r-lg); }
  .auth-brand { padding: 28px 20px 24px; }
}
