/* ─── Reset & Base ─── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1E2A3A;
  background: #F3F5F9;
  line-height: 1.5;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

a {
  text-decoration: none;
  color: inherit;
}

/* ─── Sidebar ─── */
.app {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: 300px;
  min-height: 100vh;
  background: #E9EDF4;
  border-right: 1px solid #D6DFEA;
  padding: 24px 16px 16px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 0 12px 30px;
  font-size: 18px;
  color: #1E2A3A;
  flex-shrink: 0;
}

.brand small {
  display: block;
  font-size: 13px;
  color: #6B7A90;
  margin-top: 2px;
  font-weight: 400;
}

.brand-icon {
  font-size: 38px;
  color: #C7D3E6;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* ─── Main Navigation ─── */
.main-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 18px;
  border-bottom: 1px solid #D6DFEA;
  flex-shrink: 0;
}

.main-nav a {
  padding: 11px 15px;
  border-radius: 12px;
  font-size: 16px;
  color: #1E2A3A;
  display: flex;
  gap: 14px;
  align-items: center;
  transition: background 0.2s;
}

.main-nav a:hover {
  background: #C7D3E6;
}

.main-nav a.active {
  background: #A6FA5;
  font-weight: 500;
  color: #1E2A3A;
}

.nav-icon {
  display: inline-block;
  width: 24px;
  text-align: center;
}

/* ─── Topics Menu (двухуровневое) ─── */
.topics-menu {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0 12px;
}

.menu-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6B7A90;
  padding: 0 12px 12px;
  font-weight: 600;
}

.menu-item {
  margin-bottom: 2px;
}

.menu-header {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
  gap: 10px;
  font-size: 15px;
  font-weight: 500;
  color: #1E2A3A;
}

.menu-header:hover {
  background: #C7D3E6;
}

.menu-item.active .menu-header {
  background: #A6FA5;
}

.menu-icon {
  font-size: 18px;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.menu-title {
  flex: 1;
}

.menu-arrow {
  font-size: 18px;
  color: #6B7A90;
  transition: transform 0.25s ease;
  font-weight: 300;
}

.menu-arrow.open {
  transform: rotate(90deg);
}

/* ─── Submenu ─── */
.submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.25s ease;
  opacity: 0;
  padding-left: 20px;
}

.submenu.open {
  max-height: 600px;
  opacity: 1;
}

.submenu-item {
  display: flex;
  align-items: center;
  padding: 7px 12px 7px 8px;
  border-radius: 10px;
  font-size: 14px;
  color: #1E2A3A;
  gap: 8px;
  transition: background 0.2s, color 0.2s;
}

.submenu-item:hover {
  background: #C7D3E6;
  color: #1E2A3A;
}

.submenu-item.active {
  background: #A6FA5;
  color: #1E2A3A;
  font-weight: 500;
}

.submenu-dot {
  color: #6B7A90;
  font-size: 12px;
}

.submenu-duration {
  margin-left: auto;
  font-size: 12px;
  color: #6B7A90;
  flex-shrink: 0;
}

.submenu-item.active .submenu-duration {
  color: #1E2A3A;
}

/* ─── Logout ─── */
.logout {
  padding: 13px 17px;
  border-radius: 12px;
  font-size: 16px;
  color: #1E2A3A;
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: auto;
  flex-shrink: 0;
  transition: background 0.2s;
}

.logout:hover {
  background: #C7D3E6;
}

/* ─── Topbar ─── */
.topbar {
  height: 80px;
  background: #E9EDF4;
  border-bottom: 1px solid #D6DFEA;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.menu-toggle {
  display: none;
  font-size: 26px;
  color: #1E2A3A;
  padding: 4px 8px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.bell {
  font-size: 24px;
  color: #6B7A90;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #C7D3E6;
  display: grid;
  place-items: center;
  font-weight: 600;
  color: #1E2A3A;
}

.name {
  font-size: 15px;
  color: #1E2A3A;
}

/* ─── Content ─── */
.content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 40px 60px;
  width: 100%;
}

.intro h1 {
  font-size: 34px;
  line-height: 1.2;
  margin: 0 0 4px;
  color: #1E2A3A;
}

.intro p {
  font-size: 17px;
  color: #6B7A90;
  margin: 0 0 24px;
}

/* ─── Breadcrumbs ─── */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #6B7A90;
  padding: 10px 0 20px;
  flex-wrap: wrap;
}

.breadcrumbs a {
  color: #6B7A90;
  transition: color 0.2s;
}

.breadcrumbs a:hover {
  color: #1E2A3A;
  text-decoration: underline;
}

.breadcrumbs .separator {
  color: #6B7A90;
}

.breadcrumbs .current {
  color: #1E2A3A;
  font-weight: 500;
}

/* ─── Topic Content ─── */
.topic-content {
  background: #E9EDF4;
  border-radius: 16px;
  border: 1px solid #D6DFEA;
  overflow: hidden;
  margin-bottom: 32px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.topic-header {
  padding: 24px 28px;
  background: #F3F5F9;
  display: flex;
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid #D6DFEA;
}

.topic-play {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #C7D3E6;
  color: #1E2A3A;
  display: grid;
  place-items: center;
  font-size: 22px;
  flex-shrink: 0;
  transition: background 0.2s;
}

.topic-play:hover {
  background: #A6FA5;
}

.topic-header h2 {
  font-size: 22px;
  margin: 0 0 2px;
  color: #1E2A3A;
}

.topic-duration {
  font-size: 14px;
  color: #6B7A90;
}

.topic-body {
  padding: 28px;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 30px;
}

.video-container {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #1E2A3A;
  position: relative;
}

.video-player {
  width: 100%;
  height: auto;
  max-height: 400px;
  display: block;
  background: #1E2A3A;
  border-radius: 12px;
}

.video-player::-webkit-media-controls-panel {
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
}

.video-placeholder {
  background: #F3F5F9;
  border-radius: 12px;
  padding: 60px 20px;
  text-align: center;
  border: 2px dashed #D6DFEA;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-height: 240px;
  justify-content: center;
}

.video-icon {
  font-size: 52px;
  color: #6B7A90;
}

.video-placeholder p {
  font-size: 17px;
  color: #1E2A3A;
  margin: 0;
}

.video-duration {
  font-size: 14px;
  color: #6B7A90;
  background: #E9EDF4;
  padding: 4px 18px;
  border-radius: 20px;
}

.topic-materials h3 {
  font-size: 17px;
  color: #1E2A3A;
  margin-bottom: 16px;
}

.topic-materials ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topic-materials ul li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-radius: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.material-link.download {
  background: #F3F5F9;
  border: 1px solid #D6DFEA;
  color: #1E2A3A;
}

.material-link.download:hover {
  background: #C7D3E6;
  border-color: #6B7A90;
}

.material-link.test {
  background: #C7D3E6;
  border: 1px solid #6B7A90;
  color: #1E2A3A;
}

.material-link.test:hover {
  background: #A6FA5;
  border-color: #1E2A3A;
}

.material-link.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.material-icon {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  object-fit: contain;
  transition: transform 0.2s ease;
}

.material-link:hover .material-icon {
  transform: scale(1.05);
}

.topic-placeholder {
  padding: 60px 28px;
  text-align: center;
  color: #6B7A90;
}

.topic-placeholder h2 {
  color: #1E2A3A;
  margin-bottom: 8px;
}

/* ─── Section Topics Grid ─── */
.section-topics {
  margin-top: 16px;
}

.section-topics h3 {
  font-size: 18px;
  color: #1E2A3A;
  margin-bottom: 16px;
}

.topics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.topic-card {
  background: #E9EDF4;
  border: 1px solid #D6DFEA;
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.topic-card:hover {
  background: #C7D3E6;
  border-color: #6B7A90;
  transform: translateY(-2px);
}

.topic-card.active {
  background: #A6FA5;
  border-color: #1E2A3A;
}

.topic-card .play {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #D6DFEA;
  color: #6B7A90;
  display: grid;
  place-items: center;
  font-size: 12px;
  flex-shrink: 0;
}

.topic-card.active .play {
  background: #C7D3E6;
  color: #1E2A3A;
}

.topic-card strong {
  font-size: 14px;
  display: block;
  color: #1E2A3A;
}

.topic-card .duration {
  font-size: 12px;
  color: #6B7A90;
}

.topic-card.active .duration {
  color: #1E2A3A;
}

/* ─── Bottom Nav ─── */
.bottom-nav {
  display: none;
}

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .topics-grid {
    grid-template-columns: 1fr 1fr;
  }

  .topic-body {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: -320px;
    width: 300px;
    height: 100vh;
    z-index: 100;
    transition: left 0.3s ease;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.08);
    border-right: 1px solid #D6DFEA;
  }

  .sidebar.open {
    left: 0;
  }

  .menu-toggle {
    display: block;
  }

  .mobile-brand-wrapper {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
  }

  .mobile-brand {
    font-weight: 700;
    font-size: 18px;
    color: #1E2A3A;
  }

  .mobile-brand-sub {
    font-weight: 700;
    font-size: 18px;
    color: #1E2A3A;
  }

  .name {
    display: none;
  }

  .content {
    padding: 20px 16px 92px;
  }

  .intro h1 {
    font-size: 28px;
  }

  .topics-grid {
    grid-template-columns: 1fr;
  }

  .topic-header {
    padding: 18px 20px;
    flex-wrap: wrap;
  }

  .topic-header h2 {
    font-size: 18px;
  }

  .topic-body {
    padding: 18px;
  }

  .topic-play {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }

  .bottom-nav {
    position: fixed;
    z-index: 50;
    bottom: 0;
    left: 0;
    right: 0;
    height: 68px;
    background: rgba(233, 237, 244, 0.97);
    border-top: 1px solid #D6DFEA;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding-bottom: env(safe-area-inset-bottom);
    backdrop-filter: blur(6px);
  }

  .bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: #6B7A90;
    font-size: 22px;
  }

  .bottom-nav a span {
    font-size: 10px;
  }

  .bottom-nav a.active {
    color: #1E2A3A;
    font-weight: 500;
  }

  .overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(30, 42, 58, 0.3);
    z-index: 99;
  }

  .overlay.open {
    display: block;
  }

  .sidebar .logout {
    margin-top: auto;
  }

  .video-player {
    max-height: 250px;
  }

  .video-placeholder {
    padding: 40px 16px;
    min-height: 180px;
  }
}

@media (max-width: 480px) {
  .content {
    padding: 14px 12px 80px;
  }

  .topic-header {
    padding: 14px 16px;
    gap: 12px;
  }

  .topic-body {
    padding: 14px;
  }

  .video-placeholder {
    padding: 28px 16px;
  }
}

/* ─── Scrollbar ─── */
.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: #6B7A90;
  border-radius: 4px;
}

/* ─── Desktop brand hidden on mobile ─── */
@media (min-width: 769px) {
  .mobile-brand-wrapper {
    display: none;
  }
}