/* Main Container */
.container {
  padding: var(--padding-container);
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 100vh;
  background-color: var(--bg-app);
  background-image:
    linear-gradient(rgba(168, 85, 247, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(168, 85, 247, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 0 100px rgba(0, 0, 0, 0.5);
  width: 100%;
  max-width: var(--app-max-width);
  margin: 0 auto;
  flex: 1;
}

@media (max-width: 768px) {
  .container {
    padding: var(--padding-mobile);
  }
}

main {
  padding-bottom: 20px;
}

/* Header & Branding */
header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(10, 10, 10, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 12px 0; /* Tighter padding */
  margin-bottom: clamp(16px, 3vw, 24px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  /* CLS Fix: Reduced height */
  min-height: 70px;
  box-sizing: border-box;
}

/* View Switcher Capsule */
.view-switcher {
  position: relative;
  display: flex;
  background: rgba(255, 255, 255, 0.03); /* Extremely subtle matte base */
  border-radius: 999px;
  padding: 2px;
  border: 1px solid var(--border);
  min-width: 160px; /* Consistent width */
}

/* Sliding Glider (The Active 'Border' / Background) */
.view-switcher::before {
  content: "";
  position: absolute;
  top: 2px; /* Precision fit */
  bottom: 2px;
  left: 2px;
  width: calc(50% - 2px);
  /* Premium Glider: Apple-style "raised" material look (but flat/matte) */
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  z-index: 1;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); /* Very subtle elevation, no glow */
  pointer-events: none;
}

.view-switcher.active-live::before {
  transform: translateX(100%);
}

.toggle-btn {
  position: relative;
  z-index: 2;
  background: transparent !important; /* Force override browser defaults */
  border: none !important;
  outline: none; /* Remove default, replaced by :focus-visible below */
  color: var(--text-dim);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.toggle-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.toggle-btn:hover {
  color: var(--text-main);
}

.toggle-btn.active {
  background: transparent !important;
  color: var(--accent); /* Premium Purple */
  text-shadow: 0 0 10px rgba(168, 85, 247, 0.2);
}

.toggle-btn i {
  font-size: 0.85em;
}
@media (max-width: 768px) {
  header {
    flex-direction: column;
    gap: 12px; /* Tighter distribution */
    align-items: center;
    text-align: center;
    padding: 12px 0 8px 0;
  }

  .brand {
    flex-direction: column;
    text-align: center;
    gap: 6px;
  }

  .brand-logo {
    width: 32px; /* Thinner for mobile density */
    height: 32px;
    font-size: 16px;
    border-radius: 8px;
  }

  .brand-title-row {
    display: flex;
    flex-direction: row; /* Try to keep on one line or wrap tightly */
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
  }

  .brand-info h1 {
    font-size: 18px;
  }

  .brand-badge {
    margin-left: 0;
    font-size: 8px;
    padding: 2px 6px;
  }

  .brand-subtitle {
    justify-content: center;
    gap: 6px;
  }

  .subtitle-tag {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 4px;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px; /* Slightly more room for the new app icon box */
  min-width: 260px;
}

/* Premium App Icon Style */
.brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  border-radius: 12px;
  color: var(--accent);
  font-size: 20px;
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.05); /* Slight glass reflection */
}

/* Structural Title Row */
.brand-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.brand-info h1 {
  font-size: 21px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: #ffffff;
}

/* Premium Pill Subtitles */
.brand-subtitle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px; /* Breathing room between tags */
}

.subtitle-tag {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06); /* Premium frosted glass base */
  color: rgba(255, 255, 255, 0.9); /* High contrast, crisp white-gray */
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Special Tags (Ramadan / Academic) inherit their brand colors but fit the tag shape */
#ramadan-indicator.special-tag {
  background: rgba(251, 191, 36, 0.1);
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.2);
  font-family: var(--font-ramadan);
}

#academic-indicator.special-tag {
  background: rgba(168, 85, 247, 0.1);
  color: var(--accent);
  border-color: rgba(168, 85, 247, 0.2);
}

.brand-badge {
  font-size: 10px;
  background: var(--accent-bg);
  color: var(--accent);
  padding: 3px 8px;
  border-radius: 6px; /* Match subtitle-tag radius for consistency */
  border: 1px solid rgba(168, 85, 247, 0.2);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: all var(--transition-fast);
}

a.brand-badge:hover,
a.brand-badge:focus-visible {
  background: rgba(168, 85, 247, 0.2);
  border-color: var(--accent);
  outline: none;
}

a.brand-badge i {
  font-size: 1.1em;
}

/* View Switcher (Segmented Control) */
.view-switcher {
  position: relative;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  /* Premium Well: Inset background for depth without borders */
  background: rgba(0, 0, 0, 0.25);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
  border-radius: 999px;
  padding: 3px; /* Slightly tighter */
  gap: 0;
  width: fit-content;
  min-width: 200px; /* Better balance between the super-small and large */
}

/* Data Source Toggle (Lectures / Sections) — Compact Inline Pills */
.data-source-toggle {
  display: inline-flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
  border: 1px solid var(--border);
}

.source-pill {
  background: transparent;
  border: 1px solid transparent;
  outline: none;
  color: var(--text-dim, #71717a);
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-ui);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.25s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.source-pill:hover {
  color: var(--text-main, #ededed);
}

.source-pill.active {
  background: rgba(168, 85, 247, 0.12);
  color: var(--accent);
  border-color: rgba(168, 85, 247, 0.3);
}

.source-pill i {
  font-size: 0.9em;
}

@media (max-width: 768px) {
  .source-pill {
    padding: 2px 6px;
    font-size: 9px;
  }
}

/* WIDGET MODE */
body.widget-mode .container {
  max-width: 100%;
  width: 100%;
  padding: 10px;
  border-radius: 0;
  margin: 0;
}

body.widget-mode header {
  display: none;
}
body.widget-mode main {
  padding: 0;
}
body.widget-mode .controls {
  margin-bottom: 15px;
}
body.widget-mode .brand-badge {
  display: none;
}

/* FAB - Floating Action Button */
.fab {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 48px;
  height: 48px;
  min-width: 48px; /* Accessibility: Touch Target */
  min-height: 48px;
  border-radius: 50%;
  background: rgba(168, 85, 247, 0.15);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(168, 85, 247, 0.3);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2000;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.8);
}

.fab.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  box-shadow: 0 10px 30px rgba(168, 85, 247, 0.2);
}

.fab:hover {
  background: var(--accent);
  color: white;
  transform: translateY(-5px) scale(1.1);
}

.fab:active {
  transform: scale(0.95);
}

@media (max-width: 768px) {
  .fab {
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
  }
}
