/* ==========================================================================
   DASHBOARD STEM: CODICE - LA VITA È DIGITALE
   Stile Moderno High-Tech, Glassmorphism, Dark UI per Laboratorio Scolastico
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-primary: #07090e;
  --bg-secondary: #0d121f;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(26, 36, 56, 0.85);
  --bg-elevated: #161f33;
  --bg-glass: rgba(13, 18, 31, 0.7);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(6, 182, 212, 0.5);
  --border-glow: rgba(59, 130, 246, 0.3);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-accent: #38bdf8;

  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-indigo: #6366f1;
  --accent-purple: #a855f7;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  /* Categorie Colors */
  --cat-agentic: #818cf8;
  --cat-robotica: #34d399;
  --cat-cyber: #f87171;
  --cat-etica: #fbbf24;
  --cat-quantum: #c084fc;
  --cat-fintech: #38bdf8;
  --cat-salute: #f472b6;
  --cat-geopolitica: #fb923c;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.5), 0 2px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 25px -5px rgba(56, 189, 248, 0.25);
  --transition-fast: 0.18s ease;
  --transition-smooth: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(14, 165, 233, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(168, 85, 247, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.03) 0%, transparent 60%);
  background-attachment: fixed;
}

/* Scrollbar personalizzata */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==========================================================================
   HEADER / NAVBAR
   ========================================================================== */
.top-navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.85rem 1.5rem;
}

.nav-container {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
}

.brand-icon svg {
  width: 24px;
  height: 24px;
  color: #fff;
}

.brand-text h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #ffffff, #93c5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-text h1 .badge-rai {
  font-size: 0.65rem;
  font-weight: 800;
  background: #003399;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  -webkit-text-fill-color: white;
  letter-spacing: 0.05em;
}

.brand-text p {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: var(--transition-fast);
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-focus);
  color: var(--text-accent);
}

.nav-btn.active {
  background: rgba(14, 165, 233, 0.15);
  border-color: var(--accent-cyan);
  color: #fff;
}

.badge-counter {
  background: var(--accent-cyan);
  color: #04101f;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 0.2rem;
}

/* ==========================================================================
   HERO / BANNER DIDATTICO
   ========================================================================== */
.hero-section {
  max-width: 1600px;
  margin: 1.5rem auto 1rem;
  padding: 0 1.5rem;
}

.hero-banner {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(30, 41, 59, 0.7));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 2rem 2.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.hero-banner::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.15), transparent 70%);
  pointer-events: none;
}

.hero-content {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 2rem;
  align-items: center;
  position: relative;
  z-index: 1;
}

.hero-title-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.1);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(6, 182, 212, 0.2);
  margin-bottom: 0.8rem;
}

.hero-text h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 0.75rem;
  letter-spacing: -0.03em;
}

.hero-text h2 span {
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-text p {
  color: var(--text-secondary);
  font-size: 0.96rem;
  max-width: 650px;
  line-height: 1.6;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.stat-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  backdrop-filter: blur(10px);
  transition: var(--transition-fast);
}

.stat-box:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.stat-info .stat-num {
  font-family: 'Outfit', sans-serif;
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.stat-info .stat-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

/* ==========================================================================
   MAIN LAYOUT / DASHBOARD CONTAINER
   ========================================================================== */
.dashboard-container {
  max-width: 1600px;
  margin: 1rem auto 3rem;
  padding: 0 1.5rem;
}

/* Search & Filter Toolbar */
.toolbar-section {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.4rem;
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow-card);
}

.search-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
  align-items: center;
}

.search-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrap svg {
  position: absolute;
  left: 1.1rem;
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0.9rem 1.1rem 0.9rem 2.9rem;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition-smooth);
}

.search-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.2);
  background: rgba(0, 0, 0, 0.6);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.clear-search-btn {
  position: absolute;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: none;
}
.clear-search-btn:hover {
  color: #fff;
}

.sort-select-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.custom-select {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 0.85rem 1.2rem;
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: var(--transition-fast);
}

.custom-select:focus,
.custom-select:hover {
  border-color: var(--border-focus);
}

.view-mode-toggle {
  display: flex;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 3px;
}

.view-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.view-btn.active {
  background: var(--bg-elevated);
  color: var(--text-accent);
}

/* Source / Program Filter Bar */
.source-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
  align-items: center;
}

.source-filter-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-cyan);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-right: 0.25rem;
  user-select: none;
}

.source-chip {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: var(--transition-fast);
  user-select: none;
}

.source-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.source-chip.active {
  background: rgba(6, 182, 212, 0.16);
  border-color: var(--accent-cyan);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.25);
}

.source-chip .source-chip-count {
  font-size: 0.72rem;
  opacity: 0.8;
  background: rgba(0, 0, 0, 0.3);
  padding: 1px 5px;
  border-radius: 4px;
}

.source-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(6, 182, 212, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.25);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}

/* Category Filters Chips */
.category-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.cat-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-md);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition-fast);
  user-select: none;
}

.cat-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.cat-chip.active {
  background: rgba(14, 165, 233, 0.15);
  border-color: var(--accent-cyan);
  color: #fff;
  font-weight: 600;
}

.cat-chip .chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.cat-chip .chip-count {
  font-size: 0.72rem;
  opacity: 0.75;
  background: rgba(0, 0, 0, 0.3);
  padding: 1px 5px;
  border-radius: 4px;
}

/* Sub-Filters Row (Years, Duration, Guest Type) */
.sub-filters-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-right: 0.3rem;
}

.pill-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.pill-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.pill-btn.active {
  background: var(--text-primary);
  color: var(--bg-primary);
  font-weight: 600;
  border-color: var(--text-primary);
}

.reset-filters-btn {
  background: transparent;
  border: none;
  color: var(--accent-rose);
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}
.reset-filters-btn:hover {
  background: rgba(244, 63, 94, 0.1);
}

/* Results Feedback Bar */
.results-info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding: 0 0.5rem;
}

.results-count {
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.results-count strong {
  color: var(--text-primary);
  font-size: 1.05rem;
}

.active-filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.active-tag-badge {
  font-size: 0.75rem;
  background: rgba(14, 165, 233, 0.15);
  border: 1px solid rgba(14, 165, 233, 0.3);
  color: var(--accent-cyan);
  padding: 2px 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.active-tag-badge button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-weight: bold;
}

/* ==========================================================================
   CARDS GRID (VIEW 1)
   ========================================================================== */
.videos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1.5rem;
}

.video-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-card);
  transition: var(--transition-smooth);
  position: relative;
}

.video-card:hover {
  transform: translateY(-4px);
  background: var(--bg-card-hover);
  border-color: rgba(56, 189, 248, 0.3);
  box-shadow: 0 12px 30px -5px rgba(0, 0, 0, 0.6), 0 0 20px -2px rgba(14, 165, 233, 0.15);
}

/* Card Media Header */
.card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
  cursor: pointer;
}

.card-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.video-card:hover .card-thumb {
  transform: scale(1.05);
}

.play-overlay-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 52px;
  height: 52px;
  background: rgba(14, 165, 233, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  opacity: 0;
  transition: var(--transition-smooth);
  box-shadow: 0 0 20px rgba(14, 165, 233, 0.6);
}

.video-card:hover .play-overlay-btn {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.play-overlay-btn svg {
  width: 24px;
  height: 24px;
  margin-left: 3px;
}

.duration-badge {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.category-tag-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.bookmark-card-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.75);
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.bookmark-card-btn:hover,
.bookmark-card-btn.saved {
  color: #fbbf24;
  background: rgba(0, 0, 0, 0.9);
  border-color: #fbbf24;
}

/* Card Body */
.card-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.broadcast-date {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.school-level-badge {
  font-size: 0.7rem;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
  padding: 1px 6px;
  border-radius: 4px;
}

.card-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-primary);
  margin-bottom: 0.85rem;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.card-title:hover {
  color: var(--text-accent);
}

/* Guest Box */
.guest-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.9rem;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.guest-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e293b, #334155);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-accent);
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
  border: 1px solid var(--border-subtle);
}

.guest-details {
  flex: 1;
  min-width: 0;
}

.guest-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guest-role {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
  margin-top: 1px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Importance Callout */
.importance-box {
  background: rgba(6, 182, 212, 0.06);
  border-left: 3px solid var(--accent-cyan);
  padding: 0.65rem 0.8rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 0.9rem;
}

.importance-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.2rem;
}

.importance-text {
  font-size: 0.8rem;
  color: #cbd5e1;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Summary preview */
.summary-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 1rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* STEM Tags */
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: auto;
  margin-bottom: 1rem;
}

.tag-badge {
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.tag-badge:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.3);
  color: var(--text-accent);
}

/* Card Actions */
.card-actions {
  display: flex;
  gap: 0.6rem;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.btn-primary-card {
  flex: 1;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.9), rgba(59, 130, 246, 0.9));
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.65rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: var(--transition-fast);
}

.btn-primary-card:hover {
  background: linear-gradient(135deg, #0ea5e9, #3b82f6);
  box-shadow: 0 4px 15px rgba(14, 165, 233, 0.4);
}

.btn-yt-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: #ef4444;
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  text-decoration: none;
}

.btn-yt-card:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
}

/* ==========================================================================
   TABLE VIEW (VIEW 2)
   ========================================================================== */
.table-view-container {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.stem-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.stem-table th {
  background: rgba(0, 0, 0, 0.4);
  padding: 1rem 1.25rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.stem-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}

.stem-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.table-title-cell {
  max-width: 320px;
}
.table-title-cell strong {
  color: var(--text-primary);
  display: block;
  font-weight: 600;
  cursor: pointer;
}
.table-title-cell strong:hover {
  color: var(--text-accent);
}
.table-title-cell small {
  color: var(--text-muted);
  font-size: 0.76rem;
}

/* ==========================================================================
   ANALYTICS & STATS VIEW (VIEW 3)
   ========================================================================== */
.analytics-view {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.analytics-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}

.analytics-card h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.bar-chart-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.82rem;
}

.bar-chart-label {
  width: 180px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-chart-track {
  flex: 1;
  height: 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
  overflow: hidden;
}

.bar-chart-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.8s ease;
}

.bar-chart-val {
  width: 35px;
  text-align: right;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-primary);
}

/* ==========================================================================
   MODAL / SCHEDA DETTAGLIO VIDEO (NATIVE DIALOG)
   ========================================================================== */
dialog.video-modal {
  background: #0d1322;
  color: var(--text-primary);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-xl);
  padding: 0;
  max-width: 1000px;
  width: 92vw;
  max-height: 92vh;
  margin: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.85), 0 0 40px rgba(14, 165, 233, 0.2);
  outline: none;
  overflow: hidden;
}

dialog.video-modal::backdrop {
  background: rgba(4, 7, 14, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.modal-header {
  padding: 1.25rem 1.75rem;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.close-modal-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.close-modal-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border-color: #ef4444;
}

.modal-body {
  padding: 1.75rem;
  overflow-y: auto;
  max-height: calc(92vh - 80px);
}

/* Responsive YouTube Embed Container */
.video-player-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
}

.video-player-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.modal-title-row {
  margin-bottom: 1.25rem;
}

.modal-category-badge {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.modal-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.3;
  color: #fff;
  margin-bottom: 0.5rem;
}

.modal-meta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Modal Sections */
.modal-grid-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin: 1.5rem 0;
}

.modal-panel {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.panel-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-accent);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.modal-importance {
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.25);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin: 1.5rem 0;
}

.modal-importance h4 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-cyan);
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.modal-importance p {
  color: #e2e8f0;
  font-size: 0.95rem;
  line-height: 1.6;
}

.modal-spark {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(168, 85, 247, 0.1));
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.modal-spark h4 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #c084fc;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.modal-spark p {
  color: #f1f5f9;
  font-size: 0.95rem;
  line-height: 1.6;
  font-style: italic;
}

.modal-summary-box {
  margin-bottom: 1.5rem;
}

.modal-summary-box h4 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.modal-summary-box p {
  color: #cbd5e1;
  font-size: 0.95rem;
  line-height: 1.7;
}

.modal-footer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
}

/* ==========================================================================
   PLAYLIST / LEZIONE DRAWER
   ========================================================================== */
.playlist-drawer {
  position: fixed;
  right: -420px;
  top: 0;
  width: 400px;
  height: 100vh;
  background: #0b101c;
  border-left: 1px solid var(--border-subtle);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.7);
  z-index: 100;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.playlist-drawer.open {
  right: 0;
}

.playlist-header {
  padding: 1.25rem 1.5rem;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.playlist-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.playlist-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.playlist-item-thumb {
  width: 70px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 4px;
}

.playlist-item-info {
  flex: 1;
  min-width: 0;
}

.playlist-item-title {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
}

.playlist-item-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.playlist-footer {
  padding: 1.25rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: 0.5rem;
}

/* ==========================================================================
   PAGINAZIONE O LOAD MORE
   ========================================================================== */
.pagination-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 2.5rem;
}

.page-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  min-width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.page-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-focus);
}

.page-btn.active {
  background: var(--accent-cyan);
  color: #04101f;
  border-color: var(--accent-cyan);
}

.page-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  background: var(--bg-card);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-xl);
  grid-column: 1 / -1;
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.6;
}

.empty-state h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--text-muted);
  max-width: 450px;
  margin: 0 auto 1.5rem;
  font-size: 0.9rem;
}

/* ==========================================================================
   ELEMENTI RICCHI: EMOZIONI, PAURE, AUTOREVOLEZZA E TESI
   ========================================================================== */
.card-emotional-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.25);
  color: #f43f5e;
  margin-bottom: 0.6rem;
}

.card-thesis-box {
  background: rgba(255, 255, 255, 0.025);
  border-left: 2px solid var(--accent-indigo);
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
  color: #e0e7ff;
  font-style: italic;
  line-height: 1.4;
  margin-bottom: 0.75rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Sezioni Dettaglio Modal */
.modal-emotional-box {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.08), rgba(245, 158, 11, 0.08));
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin: 1.25rem 0;
  position: relative;
  overflow: hidden;
}

.modal-emotional-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(to bottom, #ef4444, #f59e0b);
}

.modal-emotional-box h4 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #fb7185;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.5rem;
}

.modal-emotional-box p {
  color: #ffe4e6;
  font-size: 0.95rem;
  line-height: 1.6;
}

.modal-authority-box {
  background: rgba(16, 185, 129, 0.06);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.modal-authority-box h4 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #34d399;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.5rem;
}

.modal-authority-box p {
  color: #d1fae5;
  font-size: 0.93rem;
  line-height: 1.6;
}

.modal-thesis-box {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.modal-thesis-box h4 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #818cf8;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.5rem;
}

.modal-thesis-box p {
  color: #e0e7ff;
  font-size: 0.98rem;
  font-weight: 500;
  line-height: 1.6;
}

/* Modal Aggiornamento Catalogo */
dialog.update-modal {
  background: #0d1322;
  color: var(--text-primary);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-xl);
  padding: 0;
  max-width: 650px;
  width: 90vw;
  margin: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.9);
  outline: none;
}

dialog.update-modal::backdrop {
  background: rgba(4, 7, 14, 0.85);
  backdrop-filter: blur(12px);
}

.update-modal-body {
  padding: 1.75rem;
}

.update-modal-body pre {
  background: #050811;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  color: #38bdf8;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  margin: 0.75rem 0 1.25rem;
  overflow-x: auto;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .hero-content {
    grid-template-columns: 1fr;
  }
  .analytics-view {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .hero-banner {
    padding: 1.5rem;
  }
  .hero-text h2 {
    font-size: 1.7rem;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .search-row {
    flex-direction: column;
    align-items: stretch;
  }
  .videos-grid {
    grid-template-columns: 1fr;
  }
  .modal-grid-details {
    grid-template-columns: 1fr;
  }
  .playlist-drawer {
    width: 100vw;
    right: -100vw;
  }
}

/* Print Style per Scheda Didattica da stampare */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .top-navbar, .toolbar-section, .hero-section, .card-actions, .pagination-wrap, .close-modal-btn, .modal-footer-actions {
    display: none !important;
  }
  dialog.video-modal {
    position: static !important;
    border: none !important;
    box-shadow: none !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .modal-importance, .modal-spark, .modal-panel, .modal-emotional-box, .modal-authority-box, .modal-thesis-box {
    border: 1px solid #ccc !important;
    background: #f9f9f9 !important;
    color: #000 !important;
  }
}
