/**
 * EC-IELTS Design System - Classes Module Styles
 * Unified styles for catalog and detail pages.
 */

/* ============================================================================
   LAYOUT & CONTAINERS
   ============================================================================ */
.classes-page,
.class-detail-page {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.classes-page {
  width: min(100%, 1280px);
  margin: 0 auto;
}

.classes-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  transition:
    border-color 0.3s ease,
    box-shadow 0.3s ease;
}

.classes-page-header-main {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.classes-page-header-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: var(--accent-subtle);
  color: var(--accent);
  flex-shrink: 0;
}

.classes-page-header-icon svg {
  width: 28px;
  height: 28px;
}

.classes-page-header:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.classes-page-header .material-icons-outlined {
  font-size: 48px;
  color: var(--accent);
}

.classes-page-header h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.classes-page-header p {
  margin: var(--space-1) 0 0 0;
  color: var(--muted);
  font-size: 1.1rem;
  max-width: 72ch;
}

/* ============================================================================
   SESSION STATUS TABS (segmented control)
   --------------------------------------------------------------------------
   The four session-status views (All / Upcoming / Ongoing / Past) are
   exposed as a segmented control rather than a text-nav so the active
   option reads as "selected" at a glance, matching the .plan-tab pattern
   used elsewhere in the codebase.
   ============================================================================ */
.classes-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  margin: 0 0 var(--space-3);
  background: var(--color-bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.classes-tabs::-webkit-scrollbar {
  display: none;
}

.classes-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.2;
  transition:
    background-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
}

.classes-tab:hover,
.classes-tab:focus-visible {
  color: var(--text);
  background: rgba(255, 255, 255, 0.65);
  outline: none;
}

.classes-tab--active,
.classes-tab--active:hover,
.classes-tab--active:focus-visible {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.classes-tab__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  border: 1px solid var(--border-subtle);
  line-height: 1;
}

.classes-tab--active .classes-tab__count {
  background: var(--accent);
  color: var(--text-on-accent);
  border-color: var(--accent);
}

/* Dark theme — translucent track + raised blue-tinted active pill */
html[data-theme="dark"] .classes-tabs {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}
html[data-theme="dark"] .classes-tab:hover,
html[data-theme="dark"] .classes-tab:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}
html[data-theme="dark"] .classes-tab--active,
html[data-theme="dark"] .classes-tab--active:hover,
html[data-theme="dark"] .classes-tab--active:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  color: #93c5fd;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.4),
    0 4px 14px rgba(59, 130, 246, 0.25);
}

/* ============================================================================
   CATALOG COMPONENTS
   ============================================================================ */
.classes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  padding: 0 var(--space-1);
}

.classes-title {
  margin: 0 0 var(--space-1);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.classes-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.classes-summary {
  display: flex;
  gap: var(--space-3);
}

.classes-summary-item {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-5);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 120px;
  transition: all 0.3s ease;
}

.classes-summary-item:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.classes-summary-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.classes-summary-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
}

.classes-filters {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.classes-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.classes-filter label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.classes-filter select {
  min-width: 170px;
  padding: 8px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.classes-filter select:hover {
  border-color: var(--accent);
}

.classes-filter-clear {
  padding: 8px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

.classes-filter-clear:hover {
  text-decoration: underline;
}

.classes-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.classes-section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

.classes-section-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

.classes-section-title .material-icons-outlined {
  color: var(--accent);
}

.classes-section-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin: var(--space-1) 0 0;
}

.classes-section-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.classes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-6);
}

/* ============================================================================
   CLASS CARD
   ============================================================================ */
.class-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
}

.class-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.class-media {
  position: relative;
  aspect-ratio: 16/9;
  overflow: hidden;
  background: var(--bg);
}

.class-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.class-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent-subtle) 0%, var(--bg) 100%);
  color: var(--accent);
  opacity: 0.5;
}

.class-tags {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
}

.tag {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid var(--border-subtle);
}

html[data-theme="dark"] .class-card .tag {
  background: color-mix(in oklab, var(--color-surface) 85%, #000);
  color: var(--color-text);
  border-color: var(--color-border-subtle);
}

.tag-enrolled {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.tag-status--enrolled {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.tag-status--ongoing {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
  animation: tag-ongoing-pulse 1.8s ease-in-out infinite;
}

@keyframes tag-ongoing-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}

.tag-status--next {
  background: #ede9fe;
  color: #5b21b6;
  border-color: #c4b5fd;
}

.tag-status--starts-soon {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}

.tag-status--completed {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}

.tag-status--missed {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}

.tag-status--not-enrolled {
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  border-color: var(--border-subtle);
}

.tag-topic {
  background: #f3f4ff;
  color: #4e5dd3;
  border-color: #a6b1ff;
}

.tag-duration {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  border-color: var(--border-subtle);
}

.class-content {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  flex: 1;
}

.class-meta-info {
  display: flex;
  gap: var(--space-4);
  margin-bottom: var(--space-1);
}

.class-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.4;
}

.class-title a {
  color: inherit;
  text-decoration: none;
}

.class-title a:hover {
  color: var(--accent);
}

.class-subtitle {
  font-size: 0.9rem;
  color: var(--muted);
  margin: var(--space-1) 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.time-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--muted);
}

.time-item .material-icons-outlined {
  font-size: 18px;
}

.time-value {
  font-size: 0.85rem;
  font-weight: 600;
}

.class-actions {
  margin-top: auto;
}

.class-actions .button {
  width: 100%;
  justify-content: center;
  padding: 10px;
  font-weight: 700;
}

/* ============================================================================
   DETAIL PAGE COMPONENTS
   ============================================================================ */
.class-detail-content {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: var(--space-8);
  margin-top: var(--space-4);
}

.class-detail-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.class-hero-image {
  aspect-ratio: 16/9;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-subtle);
  background: var(--surface);
}

.hero-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: var(--bg);
}

.class-header {
  padding: var(--space-4) 0;
}

.class-badges {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.class-category {
  background: var(--accent);
  color: white;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.class-family,
.class-variant {
  background: var(--surface);
  color: var(--text);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  border: 1px solid var(--border-subtle);
}

.class-variant {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.2);
}

.class-detail-main .class-title {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-2);
  color: var(--text);
}

.class-detail-main .class-subtitle {
  font-size: 1.25rem;
  color: var(--muted);
  line-height: 1.5;
  -webkit-line-clamp: unset;
}

.class-description,
.class-recording {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
}

.class-description h3,
.class-recording h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: var(--space-4);
}

.description-text {
  color: var(--text);
  line-height: 1.7;
  font-size: 1.05rem;
}

.recording-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--accent);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: 700;
  transition: all 0.2s ease;
}

.recording-link:hover {
  background: var(--accent-strong);
  transform: translateY(-2px);
}

/* Sidebar & Enrollment */
.class-detail-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.enrollment-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  position: sticky;
  top: var(--space-6);
  box-shadow: var(--shadow-md);
}

.enrollment-status {
  text-align: center;
  margin-bottom: var(--space-6);
}

.status-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
}

.status-badge.free {
  background: #dcfce7;
  color: #166534;
}
.status-badge.paid {
  background: #fee2e2;
  color: #991b1b;
}
.status-badge.restricted {
  background: #fef3c7;
  color: #92400e;
}

.class-time-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
}

.time-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  background: var(--bg);
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

.time-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.time-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.enrollment-action {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.enrolled-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-4);
  background: #dcfce7;
  color: #166534;
  border-radius: var(--radius-lg);
  font-weight: 700;
  font-size: 1rem;
}

.countdown-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-4);
  background: var(--accent);
  color: white;
  border-radius: var(--radius-lg);
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.countdown-badge .material-icons-outlined {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(0.9);
  }
}

.countdown-text {
  font-variant-numeric: tabular-nums;
}

/* ============================================================================
   SHARED COMPONENTS
   ============================================================================ */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 32px;
  background: var(--surface);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-xl);
}

.classes-empty-wrap {
  display: flex;
  justify-content: center;
}

.classes-empty-wrap > .empty-state {
  width: min(100%, 560px);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: var(--space-3);
  opacity: 0.3;
}

.empty-state-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 var(--space-1);
}

.empty-state-subtitle {
  color: var(--muted);
  font-size: 1rem;
}

/* Pagination styles live in /static/css/components/pagination.css so the
   classes catalog uses the same component as the rest of the codebase.
   The block below adds a small visual breathing room between each
   classes section and its pagination control. */
.classes-section .pagination {
  margin-top: var(--space-4);
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */
@media (max-width: 1024px) {
  .class-detail-content {
    grid-template-columns: 1fr;
  }
  .enrollment-card {
    position: static;
  }
}

@media (max-width: 768px) {
  .classes-page {
    max-width: 100%;
  }
  .classes-page-header {
    padding: var(--space-5);
  }
  .classes-page-header-main {
    flex-direction: column;
    text-align: center;
  }
  .classes-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .classes-grid {
    grid-template-columns: 1fr;
  }
  .class-detail-main .class-title {
    font-size: 2rem;
  }
  .classes-tab {
    padding: 8px 10px;
    font-size: 0.8125rem;
  }
}
