/* Google Classroom Design System Overhauled - Premium Obsidian & Gold */
:root {
  /* Luxury Color Palette Tokens */
  --color-prestige-dark: #111622;     /* Obsidian Navy/Charcoal */
  --color-prestige-gold: #C5A880;     /* Champagne Gold */
  --color-prestige-gold-dark: #B89047;/* Brushed Gold */
  --color-prestige-cream: #FCFBF9;    /* Alabaster Porcelain Background */
  --color-prestige-slate: #5A606C;    /* Muted Slate Grey */
  --color-prestige-border: #E8E5DF;   /* Delicate Cream-Gray Border */
  --color-prestige-divider: #F1EFEA;  /* Soft Warm Divider */

  /* Google Palette Mapping overrides to maintain core codebase integrity */
  --google-blue-600: var(--color-prestige-gold-dark);
  --google-blue-700: #A27D39;
  --google-green-600: #2E5A44;         /* Rich Forest Green */
  
  --google-grey-50: var(--color-prestige-cream);
  --google-grey-100: #F6F5F2;
  --google-grey-200: var(--color-prestige-divider);
  --google-grey-300: var(--color-prestige-border);
  --google-grey-400: #D8D5CD;
  --google-grey-500: #B8B5AD;
  --google-grey-600: var(--color-prestige-slate);
  --google-grey-700: #444952;
  --google-grey-800: #2C3038;
  --google-grey-900: var(--color-prestige-dark);
  --white: #ffffff;

  /* Semantic Variables */
  --color-primary: var(--color-prestige-dark);
  --color-primary-hover: #1E293B;
  --color-bg: var(--color-prestige-cream);
  --color-surface: var(--white);
  --color-surface-variant: var(--google-grey-100);
  --color-text-primary: var(--color-prestige-dark);
  --color-text-secondary: var(--color-prestige-slate);
  --color-border: var(--color-prestige-border);
  --color-divider: var(--color-prestige-divider);

  /* Elevation / Shadows (Softer, luxurious diffuse shadows) */
  --shadow-1: 0 4px 20px 0 rgba(17, 22, 34, 0.02), 0 1px 3px 0 rgba(17, 22, 34, 0.03);
  --shadow-2: 0 10px 30px 0 rgba(17, 22, 34, 0.04), 0 2px 8px 0 rgba(17, 22, 34, 0.02);
  --shadow-3: 0 20px 50px 0 rgba(17, 22, 34, 0.06), 0 4px 12px 0 rgba(17, 22, 34, 0.03);

  /* Typography (Elegant Outfit/Inter combo) */
  --font-family-base: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-family-headings: 'Outfit', 'Google Sans', 'Inter', sans-serif;

  /* Spacing */
  --header-height: 64px;
  --sidebar-width: 300px;
  --sidebar-collapsed-width: 0px;
}

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

body {
  font-family: var(--font-family-base);
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  line-height: 1.5;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  /* Prevent horizontal bounce/scroll on mobile */
  width: 100%;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  /* Premium Android touch behavior */
  min-height: 100vh;
  min-height: 100dvh;
}

html {
  overflow-x: hidden;
  width: 100%;
  scroll-behavior: smooth;
}

/* Custom Scrollbar - Android/Webkit Premium Polish */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--google-grey-300);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--google-grey-400);
}

/* Ensure code blocks are scrollable and don't break layout */
pre,
code {
  white-space: pre;
  overflow-x: auto;
  max-width: 100%;
}

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

ul {
  list-style: none;
}

/* Typography Helpers */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-family-headings);
  font-weight: 500;
  color: var(--color-text-primary);
}

/* Typography Scaling */
h1,
.text-h1 {
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  line-height: 1.2;
}

h2,
.text-h2 {
  font-size: clamp(1.5rem, 4vw, 1.75rem);
  line-height: 1.3;
}

h3,
.text-h3 {
  font-size: clamp(1.25rem, 3vw, 1.375rem);
  line-height: 1.4;
}

.text-body-1 {
  font-size: 1rem;
  line-height: 1.5rem;
  letter-spacing: 0.00938em;
}

.text-body-2 {
  font-size: 0.875rem;
  line-height: 1.25rem;
  letter-spacing: 0.01071em;
  color: var(--color-text-secondary);
}

.text-caption {
  font-size: 0.75rem;
  line-height: 1rem;
  letter-spacing: 0.025em;
  color: var(--color-text-secondary);
}

/* --- Layout Structure --- */
.layout-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Top Bar */
.top-bar {
  height: var(--header-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--white);
  border-bottom: 1px solid var(--color-divider);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

.topbar-left {
  display: flex;
  align-items: center;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  /* Standard spacing between buttons */
}

.nav-icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 1.25rem;
}

.nav-icon-btn:hover {
  background-color: rgba(60, 64, 67, 0.08);
}


.logo-container {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text-secondary);
  font-family: var(--font-family-headings);
  font-size: 1.375rem;
  line-height: normal;
}

.logo-container img {
  height: 32px;
  width: auto;
}

.logo-container span {
  position: relative;
  top: 1px;
}

.logo-container:hover {
  text-decoration: none;
  color: var(--color-text-primary);
}

/* App Launcher (9 dots) Premium Redesign - Refined */
.app-launcher-container {
  position: relative;
  display: flex;
  align-items: center;
}

.app-launcher-popover {
  position: absolute;
  top: 56px;
  right: -10px;
  width: 320px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(25px) saturate(190%);
  -webkit-backdrop-filter: blur(25px) saturate(190%);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.05);
  padding: 20px;
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  /* Tighter grid */
  z-index: 1100;
  transform: translateY(12px) scale(0.98);
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  opacity: 0;
  pointer-events: none;
}

.app-launcher-popover.active {
  display: grid;
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 600px) {
  .app-launcher-popover {
    position: fixed;
    /* Fixed to viewport instead of relative to parent */
    top: 64px;
    left: 8px;
    right: 8px;
    width: auto;
    /* Fill screen width with margins */
    max-width: none;
    grid-template-columns: repeat(3, 1fr);
    /* Back to 3 columns if space allows, but optimized */
    border-radius: 24px;
    padding: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  }
}

@media (max-width: 400px) {
  .app-launcher-popover {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .app-launcher-popover {
    width: calc(100vw - 32px);
    right: 16px;
    left: 16px;
    grid-template-columns: repeat(2, 1fr);
    border-radius: 20px;
    padding: 12px;
  }

  .app-item {
    min-height: 80px;
    padding: 8px 4px;
  }

  .app-item i {
    font-size: 28px;
  }
}

.app-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 14px 4px;
  border-radius: 20px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  cursor: pointer;
  min-height: 100px;
  width: 100%;
}

.app-item:hover {
  background-color: rgba(26, 115, 232, 0.08);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.app-item i {
  font-size: 34px;
  margin-bottom: 6px;
  /* Reduced gap for "connected" feel */
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.08));
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  color: #1a73e8;
  /* Default brand blue */
}

.app-item:hover i {
  transform: scale(1.1) translateY(-2px);
}

.app-item span {
  font-size: 0.75rem;
  font-weight: 500;
  color: #3c4043;
  line-height: 1.2;
  width: 90%;
  display: block;
}


/* Sidebar (Drawer) Premium Redesign */
.sidebar-drawer {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-right: 1px solid rgba(255, 255, 255, 0.3);
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 900;
  padding-top: 20px;
}

.sidebar-drawer.open {
  transform: translateX(0);
  box-shadow: 10px 0 40px rgba(0, 0, 0, 0.05);
}

.sidebar-nav-list {
  display: flex;
  flex-direction: column;
}

.sidebar-item {
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 20px;
  margin: 4px 12px;
  border-radius: 16px;
  color: #5f6368;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
}

.sidebar-item:hover {
  background-color: rgba(26, 115, 232, 0.08);
  color: var(--color-primary);
  transform: translateX(4px);
}

.sidebar-item.active {
  background: rgba(26, 115, 232, 0.1);
  color: var(--color-primary);
  border: 1px solid rgba(26, 115, 232, 0.2);
  box-shadow: 0 4px 12px rgba(26, 115, 232, 0.08);
}

.sidebar-item.active span,
.sidebar-item.active i {
  color: var(--color-primary);
  font-weight: 700;
}

.sidebar-item i,
.sidebar-item .material-symbols-outlined {
  font-size: 24px;
  width: 24px;
  text-align: center;
  color: inherit;
  transition: all 0.3s;
}

.sidebar-devider {
  height: 1px;
  background-color: var(--color-divider);
  margin: 8px 0;
}

.sidebar-subheader {
  padding: 16px 24px 8px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-transform: uppercase;
}

/* Main Content Area */
.main-content {
  margin-top: var(--header-height);
  padding: 24px;
  width: 100%;
  /* If sidebar pushes content: margin-left: var(--sidebar-width); */
  /* But Google Classroom usually overlays or pushes. Let's assume overlay/toggle for now to start, or we can make it push. */
  transition: margin-left 0.3s;
}

/* --- Components: Course Cards (Home) --- */
.course-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.g-card {
  background: var(--white);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  /* Softer, more modern luxury radius */
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 300px;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), 
              box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.g-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 40px rgba(17, 22, 34, 0.08);
  border-color: var(--color-prestige-gold);
  z-index: 2;
}

.g-card-header {
  height: 100px;
  padding: 16px;
  background-size: cover;
  background-position: center;
  color: var(--white);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* --- Advanced Course Banner Patterns --- */

/* Base settings for all patterns to handle stacking */
[class*="g-pattern-"] {
  position: relative;
  overflow: hidden;
  z-index: 0;
}

/* Ensure content is always above the background details */
.g-card-header .g-card-title-group,
.g-card-header .g-card-instructor-name,
.g-card-header .g-card-info-btn,
.g-card-header .g-card-avatar {
  position: relative;
  z-index: 10;
}

/* BLUE: Deep prestige navy with gold accents */
.g-pattern-blue {
  background: linear-gradient(135deg, #0a0f1d 0%, #161e33 60%, #243050 100%);
}

.g-pattern-blue::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: radial-gradient(circle at top right, rgba(197, 168, 128, 0.15), transparent 50%),
              radial-gradient(circle at bottom left, rgba(255, 255, 255, 0.05), transparent 40%);
  z-index: 1;
}

/* GREEN: Muted forest emerald */
.g-pattern-green {
  background: linear-gradient(135deg, #091b12 0%, #133525 60%, #1d4d38 100%);
}

.g-pattern-green::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(45deg, rgba(197, 168, 128, 0.03) 0px, rgba(197, 168, 128, 0.03) 2px, transparent 2px, transparent 12px);
  z-index: 1;
}

/* ORANGE: Prestige amber/bronze */
.g-pattern-orange {
  background: linear-gradient(135deg, #181109 0%, #2c2012 60%, #43311c 100%);
}

.g-pattern-orange::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 90% 10%, rgba(197, 168, 128, 0.15) 0%, transparent 50%);
  z-index: 1;
}

/* PURPLE: Deep royal obsidian plum */
.g-pattern-purple {
  background: linear-gradient(135deg, #13091c 0%, #221232 60%, #341e4b 100%);
}

.g-pattern-purple::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 10% 90%, rgba(197, 168, 128, 0.1), transparent 50%);
  z-index: 1;
}

/* PINK: Matte rose-gold */
.g-pattern-pink {
  background: linear-gradient(135deg, #1c0910 0%, #32121f 60%, #4b1d30 100%);
}

.g-pattern-pink::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 80% 20%, rgba(197, 168, 128, 0.12) 0%, transparent 50%);
  z-index: 1;
}

/* RED: Deep crimson obsidian */
.g-pattern-red {
  background: linear-gradient(135deg, #1c0909 0%, #321212 60%, #4d1d1d 100%);
}

.g-pattern-red::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 80%, rgba(197, 168, 128, 0.1) 0%, transparent 50%);
  z-index: 1;
}

/* TEAL: Muted dark jade */
.g-pattern-teal {
  background: linear-gradient(135deg, #091a1a 0%, #123232 60%, #1e4a4a 100%);
}

.g-pattern-teal::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(197, 168, 128, 0.1) 0%, transparent 50%);
  z-index: 1;
}

/* INDIGO: Prestige cobalt */
.g-pattern-indigo {
  background: linear-gradient(135deg, #080d1e 0%, #111a36 60%, #1b2850 100%);
}

.g-pattern-indigo::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at bottom right, rgba(197, 168, 128, 0.12) 0%, transparent 50%);
  z-index: 1;
}

/* BLUE GREY: Textured steel */
.g-pattern-blue-grey {
  background: linear-gradient(135deg, #13171e 0%, #232a35 60%, #364050 100%);
}

.g-pattern-blue-grey::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.02) 0px, rgba(255, 255, 255, 0.02) 1px, transparent 1px, transparent 8px);
  z-index: 1;
}

/* CYAN: Platinum metallic */
.g-pattern-cyan {
  background: linear-gradient(135deg, #09171b 0%, #122b32 60%, #1e434e 100%);
}

.g-pattern-cyan::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(197, 168, 128, 0.08) 0%, transparent 60%);
  z-index: 1;
}

/* BROWN: Warm slate espresso */
.g-pattern-brown {
  background: linear-gradient(135deg, #140f0d 0%, #251d1a 60%, #3b302b 100%);
}

/* BLACK: Matte obsidian graphite */
.g-pattern-black {
  background: linear-gradient(135deg, #05070a 0%, #0e121a 60%, #171d29 100%);
}

.g-pattern-black::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top left, rgba(197, 168, 128, 0.12) 0%, transparent 50%);
  z-index: 1;
}

/* Enhanced Header Text */
.g-card-title {
  font-family: var(--font-family-headings);
  font-size: 1.5rem;
  /* Larger title */
  line-height: 1.2;
  font-weight: 500;
  color: var(--white);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  /* Subtle shadow for legibility */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.g-card-section {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.9);
}

.g-card-instructor-name {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
  margin-top: 4px;
}

.g-card-info-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  color: var(--white);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
}

.g-card-info-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.g-card-avatar {
  position: absolute;
  top: 70px;
  /* Overlops header boundary */
  right: 16px;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: var(--white);
  /* To show spacing */
  display: flex;
  align-items: center;
  justify-content: center;
}

.g-card-avatar img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
}

/* Modern "Skibidi" Example Block Styles */
.skibidi-example {
  background: linear-gradient(145deg, #ffffff, #f0f4f8);
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 8px 32px rgba(31, 38, 135, 0.07);
  backdrop-filter: blur(4px);
  border-radius: 12px;
  padding: 24px;
  margin-top: 24px;
  position: relative;
  overflow: hidden;
}

.skibidi-example::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(to bottom, #1a73e8, #9334e6);
}

.skibidi-example h3 {
  background: linear-gradient(90deg, #1a73e8, #9334e6);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 700;
  margin-bottom: 16px;
  display: inline-block;
}

.example-item {
  padding: 12px;
  border-radius: 8px;
  transition: background 0.2s;
}

.example-item:hover {
  background: rgba(26, 115, 232, 0.05);
}


.g-card-avatar-placeholder {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.g-card-body {
  flex: 1;
  padding: 16px;
  padding-top: 40px;
  /* Space for avatar */
  display: flex;
  flex-direction: column;
}

.g-card-body-text {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.g-card-footer {
  height: 48px;
  border-top: 1px solid var(--color-divider);
  display: flex;
  justify-content: flex-end;
  /* Icons on right */
  align-items: center;
  padding: 0 8px;
}

.g-card-footer-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  border-radius: 50%;
  transition: background 0.2s;
  background: transparent;
  border: none;
  cursor: pointer;
}

.g-card-footer-btn:hover {
  background: rgba(60, 64, 67, 0.08);
}


/* --- Components: Course View (Stream) --- */
.stream-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 200px 1fr;
  /* Sidebar widget | Stream */
  gap: 24px;
}

@media (max-width: 800px) {
  .stream-container {
    grid-template-columns: 1fr;
  }

  /* Course Page Mobile Layout - Show sidebar widgets before lessons */
  .stream-container {
    display: flex;
    flex-direction: column;
  }

  .stream-left-col {
    display: block;
    width: 100%;
    max-width: 100%;
    order: 1;
    /* Show widgets BEFORE lessons */
    margin-bottom: 24px;
    padding: 0 12px;
  }

  .stream-right-col {
    width: 100%;
    order: 2;
    /* Lessons after widgets */
    padding: 0 12px;
  }

  .stream-hero {
    order: 0;
    /* Hero banner stays on top */
    padding: 20px 12px;
    height: 180px;
  }

  .stream-hero h1 {
    font-size: 1.75rem;
  }

  .stream-hero p {
    font-size: 0.875rem;
  }

  .g-widget {
    margin-bottom: 16px;
    width: 100%;
  }
}

.stream-hero {
  grid-column: 1 / -1;
  height: 240px;
  background-color: transparent;
  border-radius: 8px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  color: var(--white);
  margin-bottom: 24px;
  background-size: cover;
  background-position: center;
}

.stream-hero h1 {
  font-size: 2.25rem;
  font-weight: 500;
  color: white;
}

.stream-hero p {
  font-size: 1rem;
  opacity: 0.9;
}

/* Premium Redesign v2 (The "Sick" Style) */
.hero-premium-v2 {
  position: relative;
  padding: 100px 40px;
  overflow: hidden;
  background: #fff;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border-radius: 40px;
  margin-bottom: 48px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.03);
}

.hero-mesh-v2 {
  position: absolute;
  inset: 0;
  background-color: #ffffff;
  background-image:
    radial-gradient(at 0% 0%, hsla(253, 16%, 95%, 1) 0, transparent 50%),
    radial-gradient(at 50% 0%, hsla(225, 39%, 98%, 1) 0, transparent 50%),
    radial-gradient(at 100% 0%, hsla(339, 49%, 98%, 1) 0, transparent 50%);
  opacity: 0.8;
  pointer-events: none;
}

.hero-content-v2 {
  position: relative;
  z-index: 2;
  max-width: 800px;
}

.hero-title-v2 {
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 800;
  color: #1f1f1f;
  line-height: 1.05;
  margin-bottom: 20px;
  letter-spacing: -2px;
}

.hero-subtitle-v2 {
  font-size: 1.25rem;
  color: #5f6368;
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.6;
}

/* Content Grid System */
.content-grid-system {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 48px;
  align-items: start;
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 24px;
  /* Prevent horizontal overflow on any screen size */
  box-sizing: border-box;
  width: 100%;
}

.stream-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.widgets-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 100px;
}

@media (max-width: 1100px) {
  .content-grid-system {
    grid-template-columns: 1fr;
    padding: 0 16px;
  }

  .widgets-container {
    position: static;
    order: -1;
    display: grid;
    /* FIX: use min() so widgets never force wider than viewport */
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  }
}

@media (max-width: 600px) {
  .content-grid-system {
    padding: 0 12px;
    gap: 24px;
  }

  .widgets-container {
    grid-template-columns: 1fr;
  }

  .hero-premium-v2 {
    padding: 48px 20px;
    margin-bottom: 24px;
    border-radius: 20px;
  }

  .hero-title-v2 {
    letter-spacing: -1px;
  }

  .glass-widget-v2 {
    padding: 20px 16px;
    border-radius: 20px;
  }

  .premium-card-v2 {
    padding: 20px 16px;
    border-radius: 20px;
  }
}

/* Premium Card Section */
.premium-card-v2 {
  background: #fff;
  border-radius: 28px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  border: 1px solid #f1f3f4;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.premium-card-v2:hover {
  transform: translateY(-6px) scale(1.01);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.06);
  border-color: rgba(26, 115, 232, 0.3);
}

.premium-icon-box-v2 {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: #f8f9fa;
  color: var(--google-blue-600);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  transition: all 0.3s;
  border: 1px solid #f1f3f4;
}

.premium-card-v2:hover .premium-icon-box-v2 {
  background: var(--google-blue-600);
  color: #fff;
  border-color: var(--google-blue-600);
  transform: scale(1.1) rotate(-5deg);
}

.premium-title-v2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #202124;
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.premium-summary-v2 {
  font-size: 1rem;
  color: #5f6368;
  line-height: 1.7;
  margin-bottom: 24px;
}

/* Glass Widget v2 */
.glass-widget-v2 {
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 32px;
  padding: 32px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
  transition: all 0.3s;
}

.glass-widget-v2:hover {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.05);
}

.glass-widget-title-v2 {
  font-size: 0.85rem;
  font-weight: 800;
  color: #202124;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}


.stream-right-col {
  /* Assignments list */
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.g-widget {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 16px;
  background: var(--white);
}

.g-widget-title {
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 12px;
}

.g-widget-link {
  font-size: 0.875rem;
  color: var(--color-primary);
  display: block;
  margin-top: 16px;
  text-align: right;
  font-weight: 500;
}

.stream-item {
  background: var(--white);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: box-shadow 0.2s, background 0.2s;
}

.stream-item:hover {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  background-color: rgba(60, 64, 67, 0.02);
}

.stream-item.seen {
  background-color: #f8f9fa;
  /* Slightly darker/greyer */
  opacity: 0.8;
}

.stream-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

.stream-item.seen .stream-icon {
  background: var(--google-grey-500);
  /* Grey out icon for seen items */
}

.stream-text {
  flex: 1;
}

.stream-title {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-text-primary);
}

.stream-date {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
}


/* --- Auth Modal Overrides for Google Style --- */
/* (Assuming auth-modal.css handles basic layout, we just want to ensure it matches fonts/colors) */
.auth-modal-content {
  font-family: var(--font-family-base) !important;
  border-radius: 8px !important;
}

.auth-submit-btn {
  background-color: var(--color-primary) !important;
  border-radius: 4px !important;
  /* Material 2 style buttons often used in older Classroom, Material 3 uses capsules. let's stick to standard rounded rect for now or capsule */
  border-radius: 20px !important;
}

/* FAB */
.fab-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
}

.fab-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: white;
  color: var(--color-primary);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
  /* Google FAB shadow */
  border: none;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.2s;
}

.fab-btn:hover {
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.25);
}

/* Dossier Status Icon */
.dossier-status {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Article Cards (Dossier Theme) */
.article-card {
  display: block;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  transition: all 0.3s;
  text-decoration: none;
  color: inherit;
}

.article-card:hover {
  background: rgba(255, 207, 125, 0.05);
  border-color: var(--dossier-gold);
  transform: translateY(-2px);
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.author-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--dossier-gold);
}

.author-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--dossier-gold);
}

.article-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff !important;
  margin-bottom: 8px;
  line-height: 1.4;
}

.article-description {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.5;
}

.article-tag {
  font-size: 0.7rem;
  color: var(--dossier-gold);
  opacity: 0.7;
  margin-right: 8px;
}

/* Utility */
.d-none {
  display: none !important;
}

.d-block {
  display: block !important;
}

.text-center {
  text-align: center;
}

/* Mobile Adjustments */
@media (max-width: 800px) {
  .top-bar {
    height: 56px;
    padding: 0 8px;
  }

  .logo-container span {
    display: none;
  }

  /* Hide text logo on small screens like real Gmail/Classroom apps usually do or shrink it */
  .logo-container img {
    margin-right: 0;
  }

  .main-content {
    padding: 16px;
    margin-left: 0 !important;
  }

  /* Ensure content is full width */

  .course-cards-grid {
    grid-template-columns: 1fr;
    /* Single column on mobile */
    gap: 16px;
  }

  .g-card {
    height: auto;
    min-height: 260px;
  }

  /* Sidebar always overlay on mobile */
  .sidebar-drawer {
    transform: translateX(-100%);
    width: 280px;
    /* Slightly narrower */
    box-shadow: none;
  }

  .sidebar-drawer.open {
    transform: translateX(0);
    box-shadow: 0 0 16px rgba(0, 0, 0, 0.3);
  }
}

/* Tablet / Desktop */
@media (min-width: 801px) {

  /* If we wanted persistent sidebar */
  /* .sidebar-drawer { transform: none; width: 72px; } ... logic for collapsed/expanded state needs more JS.
       For now, let's keep drawer behavior consistent (hidden by default or toggle) or make it persistent.
       Google Classroom desktop usually has persistent mini-sidebar or full sidebar.
       Let's leave it as drawer for now to be safe, but ensure grid is nice.
    */
  .course-cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
}

/* ==================================================
   External Articles Widget (dev.to integration)
   ================================================== */

.articles-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.article-card {
  display: block;
  padding: 12px;
  margin-bottom: 12px;
  border-left: 3px solid var(--color-divider);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  color: inherit;
}

.article- {
  background: var(--google-grey-50);
  border-left-color: var(--color-primary);
  box-shadow: var(--shadow-1);
}

.article-card:active {
  transform: scale(0.98);
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 0.75rem;
  color: var(--color-text-secondary);
}

.author-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
}

.author-name {
  font-weight: 500;
  color: var(--color-text-secondary);
}

.article-dot {
  color: var(--google-grey-400);
}

.article-date {
  color: var(--google-grey-500);
}

.article-title {
  font-size: 14px;
  font-weight: 500;
  margin: 6px 0 4px 0;
  color: var(--color-text-primary);
  line-height: 1.4;
}

.article-description {
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--color-text-secondary);
  margin: 4px 0 8px 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.article-tag {
  display: inline-block;
  padding: 2px 8px;
  background: #e8f0fe;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--color-primary);
  line-height: 1.4;
}

.article-reading-time {
  font-size: 11px;
  color: var(--google-grey-500);
  margin-top: 6px;
}

.article-empty-state {
  text-align: center;
  padding: 24px 12px;
}

.article-empty-state .material-symbols-outlined {
  display: block;
  margin: 0 auto 8px;
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
  .article-card {
    padding: 10px;
    margin-bottom: 8px;
  }

  .article-title {
    font-size: 13px;
  }

  .article-description {
    font-size: 0.7rem;
  }
}


/* ==================================================
   Course Categories Layout
   ================================================== */

.course-categories-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0;
}

.category-section {
  margin-bottom: 56px;
  animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.category-section:last-child {
  margin-bottom: 24px;
}

/* Category Header */
.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 0 4px;
}

.category-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.category-icon {
  font-size: 32px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.category-title h2 {
  font-family: var(--font-family-headings);
  font-size: 1.75rem;
  font-weight: 500;
  color: var(--color-text-primary);
  margin: 0;
  line-height: 1.2;
}

.category-count {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  font-weight: 500;
  padding: 6px 16px;
  background: var(--google-grey-100);
  border-radius: 16px;
}

/* Category Divider */
.category-divider {
  height: 3px;
  background: linear-gradient(90deg, var(--color-primary) 0%, transparent 100%);
  margin-bottom: 24px;
  border-radius: 2px;
  opacity: 0.6;
}

/* Category Grid */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

/* Responsive Adjustments */
@media (max-width: 1200px) {
  .category-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
  }

  .category-title h2 {
    font-size: 1.5rem;
  }

  .category-icon {
    font-size: 28px;
  }
}

@media (max-width: 768px) {
  .category-section {
    margin-bottom: 40px;
  }

  .category-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .category-count {
    align-self: flex-start;
  }

  .category-title h2 {
    font-size: 1.375rem;
  }

  .category-icon {
    font-size: 24px;
  }

  .category-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

@media (max-width: 480px) {
  .category-title {
    gap: 8px;
  }

  .category-title h2 {
    font-size: 1.25rem;
  }

  .category-icon {
    font-size: 22px;
  }

  .category-divider {
    height: 2px;
    margin-bottom: 16px;
  }
}


/* ==================================================
   Mobile Responsiveness & Overflow Fixes
   ================================================== */

/* Ensure main content has proper mobile padding */
@media (max-width: 768px) {
  .main-content {
    padding: 16px 12px;
  }
}

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

/* Prevent course cards from overflowing on mobile */
@media (max-width: 768px) {
  .g-card {
    max-width: 100%;
    margin: 0 auto;
  }

  .g-card-title {
    font-size: 1.25rem;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .g-card-body-text {
    font-size: 0.813rem;
  }
}

/* Fix category grid on very small screens */
@media (max-width: 400px) {
  .category-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .course-categories-container {
    padding: 0 4px;
  }

  .category-header {
    padding: 0 2px;
  }
}

/* Prevent horizontal overflow globally */
body {
  overflow-x: hidden;
  max-width: 100vw;
}

.layout-shell {
  overflow-x: hidden;
  max-width: 100vw;
}

/* Ensure all text wraps properly */
.g-card-title,
.g-card-section,
.g-card-instructor-name,
.category-title h2 {
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

/* Make sure icons don't cause overflow */
.category-icon {
  flex-shrink: 0;
}

/* Responsive course cards - smaller minmax on mobile */
@media (max-width: 640px) {
  .category-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .course-cards-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* Touch-friendly spacing on mobile */
@media (max-width: 768px) {
  .g-card {
    min-height: auto;
  }

  .g-card-header {
    min-height: 90px;
  }

  .g-card-body {
    padding: 12px;
    padding-top: 36px;
  }

  .g-card-avatar {
    width: 60px;
    height: 60px;
    top: 65px;
  }

  .g-card-avatar-placeholder {
    width: 54px;
    height: 54px;
    font-size: 1.25rem;
  }
}

/* ==================================================
   Profile Page Mobile Optimization
   ================================================== */

/* Enhanced mobile styles for profile page */
@media (max-width: 480px) {
  .profile-container {
    padding: 8px;
    margin-top: 56px;
  }

  .profile-header {
    gap: 12px;
    margin-bottom: 24px;
  }

  .profile-avatar {
    width: 64px;
    height: 64px;
    font-size: 24px;
  }

  .profile-info h1 {
    font-size: 1.5rem;
  }

  .profile-info p {
    font-size: 0.875rem;
  }

  /* Stat cards */
  .stat-card {
    padding: 16px;
    gap: 12px;
  }

  .stat-icon {
    width: 48px;
    height: 48px;
  }

  .stat-icon span {
    font-size: 24px;
  }

  .stat-info .stat-value {
    font-size: 20px;
  }

  .stat-info .stat-label {
    font-size: 12px;
  }

  /* Course cards */
  .active-courses-grid {
    gap: 12px;
  }

  .active-course-card {
    padding: 16px;
    gap: 12px;
  }

  .course-mini-avatar {
    width: 36px;
    height: 36px;
    font-size: 12px;
  }

  .course-mini-title {
    font-size: 14px;
  }

  /* Settings cards */
  .settings-card {
    padding: 16px;
    margin-bottom: 16px;
  }

  .settings-card h2 {
    font-size: 1.25rem;
  }

  /* Form inputs - prevent zoom on iOS */
  .form-input {
    font-size: 16px;
  }

  /* Buttons */
  .btn {
    padding: 12px 20px;
    font-size: 0.9rem;
    width: 100%;
  }

  .btn-outline {
    width: 100%;
  }

  /* Profile tabs */
  .profile-tab {
    padding: 10px 12px;
    font-size: 0.85rem;
  }
}

/* Extra small screens */
@media (max-width: 360px) {
  .profile-container {
    padding: 4px;
  }

  .profile-header {
    gap: 8px;
    margin-bottom: 20px;
  }

  .profile-avatar {
    width: 56px;
    height: 56px;
    font-size: 20px;
  }

  .profile-info h1 {
    font-size: 1.375rem;
  }

  .stat-card {
    padding: 12px;
    flex-direction: column;
    text-align: center;
  }

  .settings-card {
    padding: 12px;
  }

  .profile-tab {
    padding: 10px 8px;
    font-size: 0.8rem;
  }
}

/* Prevent text overflow on profile page */
.profile-info h1,
.profile-info p,
.stat-label,
.course-mini-title {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Form button groups on mobile */
@media (max-width: 480px) {
  .settings-card [style*="display: flex"] {
    flex-direction: column !important;
    gap: 8px !important;
  }
}

/* --- Homepage Redesign Styles --- */

/* Hero Section */
.hero-section {
  background: linear-gradient(135deg, #1a73e8 0%, #0d47a1 100%);
  color: white;
  padding: 80px 24px 60px;
  text-align: center;
  border-radius: 0 0 40px 40px;
  margin: -24px -24px 40px -24px;
  /* Counteract main-content padding */
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 60%);
  animation: rotate 60s linear infinite;
  z-index: 0;
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 800px;
  margin: 0 auto;
}

.hero-title {
  font-size: clamp(2.5rem, 5vw, 3.5rem);
  font-weight: 700;
  margin-bottom: 8px;
  /* Reduced from 16px */
  line-height: 1.1;
  color: #ffffff;
  /* Explicitly white */
  transition: opacity 0.5s ease-in-out;
}

.hero-title.fade-out {
  opacity: 0;
}

.hero-powered-by {
  font-size: 0.9rem;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.85);
  /* White but lighter/transparent */
  margin-bottom: 24px;
  letter-spacing: 0.5px;
}

.hero-subtitle {
  font-size: clamp(1.1rem, 3vw, 1.375rem);
  opacity: 0.9;
  margin-bottom: 40px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* Search Container */
.search-container {
  background: white;
  border-radius: 50px;
  padding: 8px 8px 8px 24px;
  display: flex;
  align-items: center;
  max-width: 600px;
  margin: 0 auto 48px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  transition: transform 0.3s, box-shadow 0.3s;
}

.search-container:focus-within {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.search-icon {
  color: var(--google-grey-600);
  margin-right: 12px;
  font-size: 24px;
}

.search-input {
  border: none;
  outline: none;
  flex: 1;
  font-size: 1.1rem;
  font-family: inherit;
  color: var(--color-text-primary);
}

.search-btn {
  background: var(--color-primary);
  color: white;
  border: none;
  padding: 12px 28px;
  border-radius: 40px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

.search-btn:hover {
  background: var(--color-primary-hover);
}

/* Hero Stats */
.hero-stats {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  opacity: 0.9;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-number {
  font-size: 1.5rem;
  font-weight: 700;
}

.stat-label {
  font-size: 0.875rem;
  opacity: 0.8;
}

.stat-separator {
  width: 1px;
  height: 40px;
  background: rgba(255, 255, 255, 0.3);
}

/* Home Section (Categories) */
.home-section {
  max-width: 1280px;
  margin: 0 auto 60px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.section-title {
  font-family: 'Google Sans', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: #202124;
  letter-spacing: -0.5px;
}

.section-link {
  color: var(--color-primary);
  font-weight: 500;
  font-size: 0.9rem;
}

.section-link:hover {
  text-decoration: underline;
}

.categories-grid-home {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.category-card-home {
  background: var(--white);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  height: 100%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  text-decoration: none;
}

.category-card-home:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-color: var(--color-primary);
}

.category-icon-large {
  font-size: 40px;
  margin-bottom: 16px;
  display: block;
  line-height: 1;
}

.category-name-home {
  font-weight: 500;
  color: var(--color-text-primary);
  margin-bottom: 4px;
  font-size: 1.1rem;
}

.category-count-home {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

/* Results Container */
#results-container {
  max-width: 1280px;
  margin: 0 auto 40px;
  padding-top: 20px;
  border-top: 1px solid var(--color-divider);
  animation: fadeInUp 0.5s ease-out;
}

#clear-results {
  background: rgba(0, 0, 0, 0.04);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: #5f6368;
  padding: 10px 24px;
  border-radius: 100px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  display: none;
  align-items: center;
  gap: 8px;
}

#clear-results::before {
  content: 'close';
  font-family: 'Material Symbols Outlined';
  font-size: 18px;
}

#clear-results:hover {
  background: rgba(0, 0, 0, 0.08);
  color: #202124;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.no-results-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  text-align: center;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 32px;
  border: 1px dashed rgba(0, 0, 0, 0.1);
  margin: 40px 0;
}

.no-results-state span {
  font-size: 64px;
  color: #dadce0;
  margin-bottom: 24px;
}

.no-results-state p {
  font-size: 1.1rem;
  color: #5f6368;
  font-weight: 500;
  max-width: 400px;
  line-height: 1.6;
}

/* Responsive */
@media (max-width: 600px) {
  .hero-section {
    padding: 60px 20px 40px;
    margin: -24px -24px 30px -24px;
    border-radius: 0 0 30px 30px;
  }

  .hero-title {
    font-size: 2rem;
  }

  .categories-grid-home {
    grid-template-columns: repeat(2, 1fr);
  }

  .search-btn {
    padding: 12px 20px;
  }
}

/* --- Custom Alert Styles --- */
.custom-alert-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.custom-alert-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.custom-alert-box {
  background: var(--white);
  width: 90%;
  max-width: 400px;
  border-radius: 28px;
  /* Material 3 style */
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  transform: scale(0.9);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  /* Bouncy pop */
}

.custom-alert-box.active {
  transform: scale(1);
  opacity: 1;
}

.custom-alert-title {
  font-size: 1.25rem;
  font-weight: 500;
  margin-bottom: 12px;
  color: var(--color-text-primary);
}

.custom-alert-message {
  font-size: 1rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
  margin-bottom: 24px;
}

.custom-alert-actions {
  display: flex;
  justify-content: flex-end;
}

.custom-alert-btn {
  background: transparent;
  color: var(--color-primary);
  border: none;
  padding: 10px 24px;
  font-weight: 500;
  font-size: 0.95rem;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s;
}

/* --- Library Page Styles --- */

.library-hero {
  background: linear-gradient(135deg, #2c3e50 0%, #bdc3c7 100%);
  /* Elegant Grey/Blue gradient for Library */
  color: white;
}



.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 24px;
  padding: 20px 0;
}

.book-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  /* Minimal shadow */
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 1px solid #f0f0f0;
  display: flex;
  flex-direction: column;
}

.book-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.book-cover {
  height: 240px;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 10px;
}

.book-cover img {
  max-height: 100%;
  max-width: 100%;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  /* Book shadow */
  transition: transform 0.2s;
}

.book-card:hover .book-cover img {
  transform: scale(1.05);
}

/* .book-placeholder styles moved to library.html and updated for responsiveness */

.placeholder-title {
  font-family: 'Google Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: #3c4043;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.2;
}

.placeholder-author {
  font-size: 0.65rem;
  color: #70757a;
  margin-top: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.book-info {
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.book-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: #202124;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
}

.book-author {
  font-size: 0.85rem;
  color: #5f6368;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-rating {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 14px;
}

.book-rating .star {
  font-size: 16px;
  color: #dadce0;
  font-variation-settings: 'FILL' 1;
}

.book-rating .star.filled {
  color: #fbbc04;
  /* Google Star Yellow */
}

.rating-count {
  font-size: 0.75rem;
  color: #70757a;
  margin-left: 4px;
}

/* Loading Spinner */
.loading-spinner {
  display: flex;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #1a73e8;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* Book Modal */
.book-modal-box {
  background: white;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  border-radius: 20px;
  padding: 30px;
  position: relative;
  overflow-y: auto;
  animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.close-modal-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  cursor: pointer;
  color: #5f6368;
  z-index: 10;
}

.book-modal-header {
  display: flex;
  gap: 30px;
  margin-bottom: 30px;
}

.book-modal-cover {
  width: 140px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.book-modal-details {
  flex: 1;
}

.book-modal-details h2 {
  font-size: 1.75rem;
  margin-bottom: 8px;
  color: #202124;
}

.modal-author {
  font-size: 1.1rem;
  color: #5f6368;
  margin-bottom: 8px;
}

.modal-meta {
  font-size: 0.9rem;
  color: #70757a;
  margin-bottom: 16px;
}

.modal-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.category-chip {
  background: #e8f0fe;
  color: #1967d2;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 500;
}

.modal-actions {
  display: flex;
  gap: 12px;
}

.g-btn {
  padding: 10px 24px;
  border-radius: 24px;
  font-weight: 500;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

.g-btn.primary {
  background: #1a73e8;
  color: white;
}

.g-btn.primary:hover {
  background: #1557b0;
}

.g-btn.secondary {
  background: white;
  color: #1a73e8;
  border: 1px solid #dadce0;
}

.g-btn.secondary:hover {
  background: #f8f9fa;
}

.book-modal-desc {
  line-height: 1.6;
  color: #3c4043;
  border-top: 1px solid #f0f0f0;
  padding-top: 20px;
}

.book-modal-desc h3 {
  font-size: 1.25rem;
  margin-bottom: 12px;
}

@media (max-width: 600px) {
  .book-modal-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .book-modal-cover {
    width: 120px;
  }

  .modal-actions {
    justify-content: center;
  }
}

.custom-alert-btn:hover {
  background: rgba(26, 115, 232, 0.08);
}

/* --- Talks & Insights --- */
.talks-hero {
  background: linear-gradient(135deg, #1a237e 0%, #0d47a1 100%);
  color: white;
  padding: 60px 24px;
}

.category-tabs {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 32px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar {
  display: none;
}

.category-tab {
  padding: 8px 20px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: transparent;
  color: white;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font-family-headings);
  font-weight: 500;
  transition: all 0.2s;
}

.category-tab:hover {
  background: rgba(255, 255, 255, 0.1);
}

.category-tab.active {
  background: white;
  color: #1a237e;
  border-color: white;
}

.talks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  padding: 40px 0;
}

.talk-card {
  background: white;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-1);
  cursor: pointer;
  transition: transform 0.3s, box-shadow 0.3s;
  display: flex;
  flex-direction: column;
}

.talk-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-3);
}

.talk-thumbnail {
  position: relative;
  aspect-ratio: 16/9;
  overflow: hidden;
}

.talk-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.play-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
}

.talk-card:hover .play-overlay {
  opacity: 1;
}

.play-overlay span {
  font-size: 48px;
  color: white;
  background: rgba(26, 35, 126, 0.8);
  border-radius: 50%;
  padding: 8px;
}

.talk-info {
  padding: 16px;
  flex: 1;
}

.talk-category {
  font-size: 0.75rem;
  font-weight: 700;
  color: #1a237e;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  display: block;
}

.talk-title {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--color-text-primary);
  line-height: 1.4;
}

.talk-channel {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}


/* --- Talks & Insights (Library-Style Refresh) --- */
.talks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 30px;
  padding: 20px 0;
}

.talk-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  border: 1px solid #f1f3f4;
  height: 100%;
}

.talk-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
  border-color: var(--color-primary);
}

.talk-poster {
  width: 100%;
  aspect-ratio: 2/3;
  /* Vertical Poster Style like Library */
  position: relative;
  background: #f8f9fa;
  overflow: hidden;
}

.talk-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.talk-card:hover .talk-poster img {
  transform: scale(1.05);
}

/* Stylized Text Poster (Fallback) */
.talk-poster-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #1a237e 0%, #0d47a1 100%);
  color: white;
  text-align: center;
}

.fallback-category {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 12px;
  opacity: 0.8;
}

.fallback-title {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.talk-info {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.talk-card .talk-category {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--color-primary);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.talk-card .talk-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: #202124;
  margin-bottom: 4px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.talk-card .talk-channel {
  font-size: 0.8rem;
  color: #5f6368;
  margin-top: auto;
}

/* Talks Modal (Perfectly aligned with Library) */
.talk-modal-box {
  background: white;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  border-radius: 20px;
  padding: 30px;
  position: relative;
  overflow-y: auto;
  animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.talk-modal-header {
  display: flex;
  gap: 30px;
  margin-bottom: 30px;
}

.modal-poster-container {
  width: 140px;
  flex-shrink: 0;
}

.talk-modal-poster {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.talk-modal-details {
  flex: 1;
}

.modal-talk-title {
  font-size: 1.75rem;
  margin-bottom: 8px;
  color: #202124;
}

.modal-channel {
  font-size: 1.1rem;
  color: #5f6368;
  margin-bottom: 8px;
}

.talk-modal-desc {
  border-top: 1px solid #f1f3f4;
  padding-top: 24px;
  color: #3c4043;
  line-height: 1.6;
}

.loading-hint {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px;
  color: #5f6368;
}

@media (max-width: 600px) {
  .talk-modal-header {
    flex-direction: column;
  }
}

/* --- Auth Wall & Premium Login Popup --- */
.auth-wall-blurred {
  filter: blur(8px) grayscale(0.5);
  pointer-events: none;
  user-select: none;
  transition: filter 0.3s ease;
}

.premium-auth-wall {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
}

.premium-auth-wall.active {
  display: flex;
}

.premium-auth-card {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 32px;
  padding: 48px;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.15);
  max-width: 400px;
  width: 90%;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.premium-auth-wall.active .premium-auth-card {
  transform: translateY(0);
  opacity: 1;
}

.premium-auth-icon {
  width: 64px;
  height: 64px;
  background: #1a73e8;
  color: white;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  font-size: 32px;
}

.premium-auth-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: #202124;
  margin-bottom: 12px;
}

.premium-auth-subtitle {
  font-size: 1rem;
  color: #5f6368;
  margin-bottom: 32px;
  line-height: 1.5;
}

.premium-auth-btn {
  background: #1a73e8;
  color: white;
  border: none;
  padding: 14px 32px;
  border-radius: 100px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.premium-auth-btn:hover {
  background: #1557b0;
  transform: scale(1.02);
}