/* ===================================================================
   CineVault - Movie & TV Show Collection Organizer Styles
   =================================================================== */

:root {
  --bg-darkest: #090d16;
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-hover: #2d3b55;
  
  --border-color: #2e3c54;
  --border-subtle: #1e293b;
  --border-focus: #38bdf8;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --primary-glow: rgba(56, 189, 248, 0.25);
  
  --accent-gold: #f59e0b;
  --accent-danger: #ef4444;
  --accent-danger-hover: #dc2626;
  --accent-success: #10b981;
  --accent-tv: #14b8a6;

  /* Format Badges */
  --format-4k-bg: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
  --format-4k-text: #050505;
  --format-bluray-bg: linear-gradient(135deg, #38bdf8 0%, #1d4ed8 100%);
  --format-bluray-text: #ffffff;
  --format-dvd-bg: linear-gradient(135deg, #f87171 0%, #b91c1c 100%);
  --format-dvd-text: #ffffff;
  --format-digital-bg: linear-gradient(135deg, #c084fc 0%, #6366f1 100%);
  --format-digital-text: #ffffff;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6);
  --shadow-poster: 0 14px 28px rgba(0, 0, 0, 0.5), 0 10px 10px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-darkest);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ===================================================================
   Header & Nav
   =================================================================== */

.app-header {
  background-color: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

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

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #0284c7 0%, #6366f1 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.4);
}

.brand-icon svg {
  width: 22px;
  height: 22px;
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #f8fafc, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
  margin-top: -3px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Stats Ribbon */
.stats-ribbon {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(30, 41, 59, 0.6);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.stat-divider {
  width: 1px;
  height: 18px;
  background: var(--border-color);
  margin: 0 4px;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.stat-num {
  font-weight: 700;
  color: var(--text-main);
}

.stat-lbl {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.stat-badge {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.03em;
}

.badge-4k {
  background: var(--format-4k-bg);
  color: var(--format-4k-text);
}

.badge-bluray {
  background: var(--format-bluray-bg);
  color: var(--format-bluray-text);
}

.badge-dvd {
  background: var(--format-dvd-bg);
  color: var(--format-dvd-text);
}

.badge-digital {
  background: var(--format-digital-bg);
  color: var(--format-digital-text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ===================================================================
   Buttons & Inputs
   =================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  text-decoration: none;
  line-height: 1;
}

.btn-primary {
  background: #0284c7;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}

.btn-primary:hover {
  background: #0369a1;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.6);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-secondary);
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
}

.btn-outline {
  background: transparent;
  border-color: var(--primary);
  color: var(--primary);
}

.btn-outline:hover {
  background: rgba(56, 189, 248, 0.1);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.btn-danger:hover {
  background: var(--accent-danger);
  color: #ffffff;
  border-color: var(--accent-danger);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--bg-secondary);
  color: var(--text-main);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 0.75rem;
}

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-md);
}

/* Dropdown Menu */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  padding: 6px;
  display: none;
  z-index: 100;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--primary);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 6px 0;
}

/* ===================================================================
   Split Master-Detail Layout
   =================================================================== */

.app-layout {
  display: flex;
  flex: 1;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  overflow: hidden;
  height: calc(100vh - 65px);
}

/* Left Panel: Master Collection List */
.master-panel {
  width: 470px;
  min-width: 340px;
  background: var(--bg-primary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(15, 23, 42, 0.6);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.15s ease;
}

.search-box:focus-within .search-icon {
  color: var(--primary);
}

.search-box input {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 9px 50px 9px 36px;
  color: var(--text-main);
  font-size: 0.875rem;
  outline: none;
  transition: all 0.15s ease;
}

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

.search-box input:focus {
  border-color: var(--primary);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-kbd-hint {
  position: absolute;
  right: 12px;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 1px 6px;
  pointer-events: none;
  line-height: 1.4;
  transition: opacity 0.15s ease;
}

.search-box.has-query .search-kbd-hint {
  display: none;
}

.btn-clear-search {
  position: absolute;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-clear-search:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

/* Match Highlight */
mark.search-highlight {
  background: rgba(245, 158, 11, 0.28);
  color: #fef08a;
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 600;
}

/* Media Type Switcher (All / Movies / TV Shows) */
.media-type-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-darkest);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.media-type-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  text-align: center;
}

.media-type-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.media-type-tab.active {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2) 0%, rgba(99, 102, 241, 0.2) 100%);
  color: #ffffff;
  border: 1px solid rgba(56, 189, 248, 0.35);
  box-shadow: var(--shadow-sm);
}

.media-type-tab span {
  font-size: 0.72rem;
  opacity: 0.85;
}

/* Format Filter Tabs */
.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-darkest);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  overflow-x: auto;
}

.filter-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.73rem;
  font-weight: 600;
  padding: 5px 7px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  text-align: center;
}

.filter-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.filter-tab.active {
  background: var(--bg-secondary);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.filter-tab span {
  font-size: 0.68rem;
  opacity: 0.8;
}

/* Toolbar */
.list-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-dim);
  padding-top: 2px;
  gap: 8px;
}

.list-toolbar-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.search-active-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  color: #c7d2fe;
}

.search-active-label {
  color: var(--text-dim);
}

.search-active-pill strong {
  color: #e0e7ff;
  font-weight: 600;
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-clear-pill {
  background: transparent;
  border: none;
  color: #a5b4fc;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0 2px;
  display: inline-flex;
  align-items: center;
}

.btn-clear-pill:hover {
  color: #ffffff;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-select-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.filter-select-group select {
  background: var(--bg-secondary);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  font-size: 0.75rem;
  outline: none;
  cursor: pointer;
}

.filter-select-group select:focus {
  border-color: var(--border-focus);
}

.sort-selector {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sort-selector select {
  background: var(--bg-secondary);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 0.75rem;
  outline: none;
  cursor: pointer;
}

.sort-selector select:focus {
  border-color: var(--border-focus);
}

/* List Items Container */
.movie-list-container {
  flex: 1;
  overflow-y: auto;
  position: relative;
}

.movie-list {
  list-style: none;
  padding: 8px;
}

/* Movie/TV Item Row */
.movie-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  margin-bottom: 4px;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  user-select: none;
}

.movie-item:hover {
  background: var(--bg-secondary);
  border-color: rgba(255, 255, 255, 0.05);
}

.movie-item.selected {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.1);
}

.movie-item-thumb {
  width: 42px;
  height: 60px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--bg-tertiary);
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.movie-item-thumb-placeholder {
  width: 42px;
  height: 60px;
  border-radius: 4px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dim);
  flex-shrink: 0;
}

.movie-item-content {
  flex: 1;
  min-width: 0;
}

.movie-item-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.movie-item-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.movie-item-type-badge {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(20, 184, 166, 0.18);
  border: 1px solid rgba(20, 184, 166, 0.4);
  color: #5eead4;
  flex-shrink: 0;
  letter-spacing: 0.03em;
}

.movie-item-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.movie-item.selected .movie-item-title {
  color: var(--primary);
}

/* Multi-format badges row in item */
.movie-item-badges {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
  flex-wrap: nowrap;
}

.movie-item-format {
  font-size: 0.62rem;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 4px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.movie-item-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.movie-item-year {
  color: var(--text-dim);
}

.movie-item-seasons {
  color: #5eead4;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.movie-item-genre {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.movie-item-stars {
  margin-left: auto;
  color: var(--accent-gold);
  font-size: 0.7rem;
}

.movie-item-watched-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.movie-item-watched-tag.watched {
  color: #34d399;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.movie-item-watched-tag.unwatched {
  color: var(--text-dim);
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

/* Empty list state */
.empty-list-state {
  padding: 48px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-icon {
  font-size: 3rem;
  opacity: 0.6;
}

.empty-list-state h3 {
  font-size: 1.1rem;
  color: var(--text-main);
}

.empty-list-state p {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 260px;
}

/* ===================================================================
   Right Panel: Item Details View
   =================================================================== */

.detail-panel {
  flex: 1;
  background: var(--bg-darkest);
  overflow-y: auto;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Placeholder when no item is selected */
.detail-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 100%;
  padding: 40px 24px;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto;
}

.placeholder-graphic {
  color: var(--text-dim);
  margin-bottom: 20px;
  opacity: 0.5;
}

.detail-placeholder h2 {
  font-size: 1.4rem;
  color: var(--text-main);
  margin-bottom: 8px;
}

.detail-placeholder p {
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 24px;
}

/* Detail Content View */
.detail-content {
  position: relative;
  min-height: 100%;
  padding-bottom: 40px;
}

.detail-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 280px;
  background-size: cover;
  background-position: center 20%;
  opacity: 0.12;
  filter: blur(24px);
  pointer-events: none;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 50%, rgba(0,0,0,0) 100%);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 50%, rgba(0,0,0,0) 100%);
}

.detail-inner {
  position: relative;
  max-width: 960px;
  margin: 0 auto;
  padding: 24px;
}

/* Detail Top Action Bar */
.detail-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.action-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-watched-active {
  background: rgba(16, 185, 129, 0.15) !important;
  border-color: rgba(16, 185, 129, 0.4) !important;
  color: #34d399 !important;
}

.action-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Detail Card & Grid */
.detail-card {
  display: flex;
  gap: 36px;
  align-items: flex-start;
}

@media (max-width: 900px) {
  .app-layout {
    flex-direction: column;
    height: auto;
  }
  .master-panel {
    width: 100%;
    height: 520px;
  }
  .detail-card {
    flex-direction: column;
    align-items: center;
  }
}

/* Poster Styling */
.detail-poster-container {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.poster-wrapper {
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-poster);
  background: var(--bg-secondary);
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
}

.detail-poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.detail-poster:hover {
  transform: scale(1.02);
}

/* Fallback Poster Card */
.poster-fallback-card {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  padding: 24px;
  text-align: center;
  gap: 12px;
}

.fallback-format {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

.fallback-initials {
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--text-dim);
  letter-spacing: -0.05em;
}

.fallback-label {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Poster Badges Row under Poster */
.poster-badge-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
}

.detail-format-tag {
  font-size: 0.8rem;
  font-weight: 800;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: var(--shadow-sm);
}

/* Info Column */
.detail-info-container {
  flex: 1;
  min-width: 0;
}

.detail-title-group {
  margin-bottom: 20px;
}

.detail-title {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text-main);
  margin-bottom: 8px;
}

.detail-meta-pills {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.meta-pill {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 3px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.meta-type {
  color: #e2e8f0;
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.3);
}

.meta-type.is-tv {
  color: #5eead4;
  background: rgba(20, 184, 166, 0.15);
  border-color: rgba(20, 184, 166, 0.4);
}

.meta-watched {
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.meta-watched.is-watched {
  color: #34d399;
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.4);
}

.meta-watched.is-unwatched {
  color: var(--text-dim);
  background: rgba(148, 163, 184, 0.08);
  border-color: rgba(148, 163, 184, 0.25);
}

.meta-seasons {
  color: #5eead4;
  background: rgba(20, 184, 166, 0.1);
  border-color: rgba(20, 184, 166, 0.3);
}

.meta-rating {
  color: var(--accent-gold);
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.08);
}

/* Specs Grid */
.detail-specs-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
}

@media (max-width: 600px) {
  .detail-specs-grid {
    grid-template-columns: 1fr;
  }
}

.spec-formats-span {
  grid-column: 1 / -1;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.spec-formats-container {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.spec-format-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  box-shadow: var(--shadow-sm);
}

.spec-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.spec-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 700;
}

.spec-value {
  font-size: 0.95rem;
  color: var(--text-main);
  font-weight: 500;
}

/* Notes Section */
.detail-notes-section h3 {
  font-size: 0.95rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.detail-notes-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  font-size: 0.92rem;
  color: var(--text-main);
  line-height: 1.6;
  white-space: pre-wrap;
}

/* ===================================================================
   Modal Dialogs & Form Cards
   =================================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
  animation: fadeIn 0.15s ease-out;
}

#metadataModal {
  z-index: 1100;
}

#apiKeysModal {
  z-index: 1200;
}

#loginModal,
#changePasswordModal {
  z-index: 1300;
}

.modal-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-sm {
  max-width: 440px;
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

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

.modal-form {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-body {
  padding: 20px 24px;
  font-size: 0.95rem;
  color: var(--text-main);
}

.modal-subtext {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 8px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: rgba(15, 23, 42, 0.5);
}

/* Form Controls */
.form-row {
  display: flex;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.req {
  color: var(--accent-danger);
}

input[type="text"],
input[type="number"],
input[type="url"],
select,
textarea {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s ease;
  font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

textarea {
  resize: vertical;
  min-height: 72px;
}

/* Media Type Radio Selector (Movie vs TV Show) */
.media-type-radio-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.media-type-radio-card {
  cursor: pointer;
  position: relative;
}

.media-type-radio-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.media-radio-content {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
  opacity: 0.7;
}

.media-type-radio-card:hover .media-radio-content {
  opacity: 0.9;
  border-color: var(--text-dim);
}

.media-type-radio-card input:checked + .media-radio-content {
  opacity: 1;
  border-color: var(--primary);
  background: rgba(56, 189, 248, 0.12);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.media-radio-icon {
  font-size: 1.5rem;
}

.media-radio-text {
  display: flex;
  flex-direction: column;
}

.media-radio-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
}

.media-radio-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Multi-select Format Checkbox Cards */
.format-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.format-instruction {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.format-checkbox-group {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

@media (max-width: 540px) {
  .format-checkbox-group {
    grid-template-columns: repeat(2, 1fr);
  }
}

.format-check-card {
  cursor: pointer;
  position: relative;
}

.format-check-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.check-card-content {
  border: 2px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 10px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all 0.15s ease;
  opacity: 0.45;
  filter: grayscale(40%);
  position: relative;
}

.check-icon {
  font-size: 0.7rem;
  font-weight: 900;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.15s ease;
  transform: scale(0.6);
}

.format-check-card input:checked + .check-card-content {
  opacity: 1;
  filter: grayscale(0%);
  box-shadow: 0 0 0 2px #ffffff, var(--shadow-md);
  transform: translateY(-2px);
}

.format-check-card input:checked + .check-card-content .check-icon {
  opacity: 1;
  transform: scale(1);
}

.check-title {
  font-size: 0.8rem;
  font-weight: 800;
}

.check-sub {
  font-size: 0.65rem;
  opacity: 0.85;
}

/* Poster Input Area */
.poster-input-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.poster-input-tabs {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
}

.upload-or-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.file-input-control {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.modal-poster-preview {
  position: relative;
  width: 90px;
  height: 125px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
  margin-top: 10px;
  box-shadow: var(--shadow-sm);
}

.modal-poster-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.btn-clear-preview {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.75);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

/* Checkbox Custom */
.checkbox-group {
  margin-top: 4px;
}

.custom-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-main);
  user-select: none;
}

.custom-checkbox input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.checkmark {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.custom-checkbox input:checked ~ .checkmark {
  background: var(--primary);
  border-color: var(--primary);
}

.custom-checkbox input:checked ~ .checkmark:after {
  content: "✔";
  color: #fff;
  font-size: 11px;
}

/* ===================================================================
   Toast Notifications
   =================================================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  color: var(--text-main);
  font-size: 0.875rem;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.2s ease-out;
}

.toast.toast-success {
  border-left: 4px solid var(--accent-success);
}

.toast.toast-danger {
  border-left: 4px solid var(--accent-danger);
}

.toast.toast-info {
  border-left: 4px solid var(--primary);
}

/* Utilities */
.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===================================================================
   Online Metadata Search Modal & Cards
   =================================================================== */

.modal-lg {
  max-width: 780px;
  width: 94vw;
}

.meta-results-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}

.meta-result-card {
  display: flex;
  gap: 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.meta-result-card:hover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.08);
}

.meta-result-card.selected {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.14);
  box-shadow: 0 0 0 1px var(--primary);
}

.meta-result-thumb {
  width: 60px;
  height: 90px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: #0f172a;
}

.meta-result-placeholder {
  width: 60px;
  height: 90px;
  border-radius: var(--radius-sm);
  background: #1e293b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--text-dim);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.meta-result-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta-result-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-result-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

.meta-result-year {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.meta-badges-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.meta-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
}

.meta-badge-type {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.meta-badge-source {
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
}

.meta-result-details {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.meta-result-overview {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 2px;
}

/* Spinner */
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.meta-val {
  color: #93c5fd;
  font-weight: normal;
  word-break: break-word;
}

/* Header Batch Running Pill */
.header-batch-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: #a5b4fc;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
  animation: pillPulse 2.5s infinite;
}

.header-batch-pill:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: #818cf8;
  color: #ffffff;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: #38bdf8;
  border-radius: 50%;
  box-shadow: 0 0 8px #38bdf8;
  animation: dotGlow 1.2s infinite alternate;
}

@keyframes dotGlow {
  from { opacity: 0.4; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1.15); }
}

@keyframes pillPulse {
  0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(99, 102, 241, 0); }
  100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

/* Custom Radio */
.custom-radio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.custom-radio input {
  display: none;
}

.custom-radio .checkmark {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.custom-radio input:checked + .checkmark {
  border-color: var(--primary);
  background: var(--primary);
}

.custom-radio input:checked + .checkmark::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  background: #ffffff;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* ===================================================================
   Authentication & Read-Only / Admin Mode Controls
   =================================================================== */

.auth-bar {
  display: flex;
  align-items: center;
}

.auth-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 4px 3px 10px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.auth-pill-viewonly {
  border-color: rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.6);
}

.auth-pill-admin {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.08);
}

.auth-mode-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

.auth-mode-label.admin {
  color: #10b981;
}

.btn-auth-signin {
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius-full);
}

.btn-auth-signout {
  padding: 4px 8px;
  font-size: 0.75rem;
  color: var(--text-dim);
  border-radius: var(--radius-full);
}

.btn-auth-signout:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

/* Detail Panel Read-Only Notice */
.readonly-action-notice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px 10px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-color);
}

.readonly-pill-badge {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
}

.admin-detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Auth Modal Styles */
.auth-icon-badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.auth-icon-badge.key-badge {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.3);
  color: #f59e0b;
}

.auth-info-banner {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: #c7d2fe;
  font-size: 0.82rem;
  line-height: 1.45;
}

.default-pwd-badge {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: monospace;
  font-size: 0.84rem;
  color: #ffffff;
  font-weight: 700;
}

.auth-error-alert {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fca5a5;
  font-size: 0.82rem;
  font-weight: 500;
}

.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.password-input-wrapper input {
  width: 100%;
  padding-right: 40px !important;
}

.btn-toggle-pwd {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  font-size: 1rem;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.btn-toggle-pwd:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

