/* ==========================================================================
   WebPlayer - Ferrite.js Custom IPTV & Stream Interface
   ========================================================================== */

:root {
  --bg-base: #0a0c10;
  --bg-surface: #12151c;
  --bg-card: #181d26;
  --bg-hover: #222733;
  --bg-active: #2b3345;
  --border-color: #242a38;
  --border-light: #323a4d;

  --text-main: #f0f3f8;
  --text-muted: #8e99ac;
  --text-dim: #5c6577;

  --accent-primary: #3b82f6;
  --accent-hover: #2563eb;
  --accent-active: #1d4ed8;
  --accent-glow: rgba(59, 130, 246, 0.35);

  --status-live: #ef4444;
  --status-live-glow: rgba(239, 68, 68, 0.4);
  --status-online: #10b981;
  --status-warn: #f59e0b;

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

  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

body {
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* --------------------------------------------------------------------------
   Top Navbar
   -------------------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  z-index: 20;
  height: 60px;
  flex-shrink: 0;
}

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

.brand-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
  color: #fff;
  cursor: pointer;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.brand-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-primary);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.env-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 3px 8px;
  border-radius: 12px;
  background: rgba(16, 185, 129, 0.1);
  color: var(--status-online);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.env-status-badge.isolated-no {
  background: rgba(239, 68, 68, 0.1);
  color: var(--status-live);
  border-color: rgba(239, 68, 68, 0.25);
}

.env-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}

.topbar-center {
  flex: 1;
  max-width: 480px;
  display: flex;
  align-items: center;
  position: relative;
}

.search-wrapper {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 36px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 36px 0 36px;
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  transition: all 0.2s ease;
}

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

.search-clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: none;
}

.search-clear-btn.visible {
  display: block;
}

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

/* Standard Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  user-select: none;
}

.btn-primary {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}
.btn-primary:hover {
  background: var(--accent-hover);
}
.btn-primary:active {
  background: var(--accent-active);
}

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

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}
.btn-icon:hover {
  background: var(--bg-hover);
}

/* --------------------------------------------------------------------------
   App Layout (Sidebar + Video Stage)
   -------------------------------------------------------------------------- */
.app-container {
  display: flex;
  flex: 1;
  height: calc(100vh - 60px);
  overflow: hidden;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: 380px;
  min-width: 320px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), width 0.25s ease;
  z-index: 10;
}

.sidebar.collapsed {
  transform: translateX(-100%);
  width: 0;
  min-width: 0;
  border-right: none;
}

/* Sidebar Header */
.sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.playlist-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.playlist-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.playlist-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-count-tag {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  white-space: nowrap;
}

/* Category Filter Tabs */
.categories-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.categories-bar::-webkit-scrollbar {
  height: 4px;
}
.categories-bar::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.category-tab {
  padding: 5px 10px;
  border-radius: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}
.category-tab:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}
.category-tab.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

/* Channel List */
.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.channel-item:hover {
  background: var(--bg-card);
  border-color: var(--border-color);
}
.channel-item.active {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
  box-shadow: inset 3px 0 0 var(--accent-primary);
}

.channel-num {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  width: 24px;
  text-align: right;
  flex-shrink: 0;
}

.channel-logo-wrap {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.channel-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.channel-logo-placeholder {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
}

.channel-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.channel-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.channel-item.active .channel-title {
  color: #fff;
  font-weight: 600;
}

.channel-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.channel-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}
.channel-badge.format-live {
  background: rgba(239, 68, 68, 0.15);
  color: var(--status-live);
}
.channel-badge.format-vod {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-primary);
}

.channel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.fav-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s ease;
}
.fav-btn:hover {
  color: #fbbf24;
}
.fav-btn.is-fav {
  color: #fbbf24;
}

/* Playing Equalizer Animation */
.playing-eq {
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
  width: 14px;
}
.channel-item.active .playing-eq {
  display: flex;
}
.eq-bar {
  width: 3px;
  background: var(--accent-primary);
  border-radius: 1px;
  animation: eq-anim 0.8s ease-in-out infinite alternate;
}
.eq-bar:nth-child(1) { height: 40%; animation-delay: 0.1s; }
.eq-bar:nth-child(2) { height: 100%; animation-delay: 0.3s; }
.eq-bar:nth-child(3) { height: 60%; animation-delay: 0.2s; }

@keyframes eq-anim {
  0% { height: 20%; }
  100% { height: 100%; }
}

/* Empty or Error State in List */
.list-empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* Sidebar Footer / Keyboard hints */
.sidebar-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border-color);
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
}
.kbd-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
kbd {
  font-family: var(--font-mono);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
}

/* --------------------------------------------------------------------------
   Stage / Main Player Area
   -------------------------------------------------------------------------- */
.stage-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #000;
  position: relative;
  overflow: hidden;
  justify-content: center;
  align-items: center;
}

/* Fullscreen targets the stage only (video + its controls) — never the sidebar/topbar. */
.stage-area:fullscreen,
.stage-area:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
}
.stage-area:fullscreen .sidebar-toggle-btn,
.stage-area:-webkit-full-screen .sidebar-toggle-btn {
  display: none;
}
/* Fallback path: if documentElement goes fullscreen, hide the app chrome so only the player shows. */
html:fullscreen .topbar,
html:fullscreen .sidebar,
html:fullscreen .sidebar-toggle-btn,
html:-webkit-full-screen .topbar,
html:-webkit-full-screen .sidebar,
html:-webkit-full-screen .sidebar-toggle-btn {
  display: none !important;
}
html:fullscreen .app-container,
html:-webkit-full-screen .app-container {
  height: 100vh;
}
/* Browser-native fullscreen (F11 / ⌃⌘F) — same player-only chrome hiding. */
body.browser-fullscreen .topbar,
body.browser-fullscreen .sidebar,
body.browser-fullscreen .sidebar-toggle-btn {
  display: none !important;
}
body.browser-fullscreen .app-container {
  height: 100vh;
}

/* Toggle Sidebar Floating Trigger */
.sidebar-toggle-btn {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 15;
  background: rgba(18, 21, 28, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  color: #fff;
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}
.sidebar-toggle-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

/* Canvas Screen Container */
.player-screen-wrap {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#ferrite-canvas {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

/* OSD (On-Screen Display banner) */
.player-osd {
  position: absolute;
  top: 24px;
  left: 24px;
  z-index: 12;
  background: rgba(10, 12, 16, 0.88);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}
.player-osd.visible {
  opacity: 1;
  transform: translateY(0);
}

.osd-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  object-fit: contain;
}

.osd-details {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.osd-channel-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}
.osd-channel-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

/* Status / Loader / Error Overlays */
.player-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.player-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.overlay-message {
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  text-align: center;
  max-width: 400px;
}

.overlay-sub {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* Floating Diagnostics HUD */
.diagnostics-hud {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 14;
  background: rgba(14, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #d1d5db;
  min-width: 240px;
  display: none;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}
.diagnostics-hud.visible {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hud-title {
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--accent-primary);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 4px;
  margin-bottom: 2px;
  display: flex;
  justify-content: space-between;
}
.hud-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}
.hud-label {
  color: var(--text-muted);
}
.hud-value {
  font-weight: 600;
  color: #fff;
  text-align: right;
}
.hud-badge-hw {
  color: var(--status-online);
}
.hud-badge-sw {
  color: #f59e0b;
}

/* --------------------------------------------------------------------------
   Custom Video Controls Bar
   -------------------------------------------------------------------------- */
.controls-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 13;
  display: flex;
  flex-direction: column;
  background: linear-gradient(to top, rgba(10, 12, 16, 0.95) 0%, rgba(10, 12, 16, 0.6) 60%, rgba(10, 12, 16, 0) 100%);
  padding: 20px 24px 16px 24px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.controls-bar.visible,
.stage-area:hover .controls-bar {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Fullscreen idle: hide the cursor and every overlay until the pointer/keyboard wakes them.
   Higher specificity than the :hover/.visible rules above so they can't keep the UI shown. */
.stage-area.is-fullscreen.ui-idle {
  cursor: none;
}
.stage-area.is-fullscreen.ui-idle .controls-bar {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}
.stage-area.is-fullscreen.ui-idle .player-osd {
  opacity: 0;
  transform: translateY(-8px);
}
.stage-area.is-fullscreen.ui-idle .diagnostics-hud {
  opacity: 0;
  pointer-events: none;
}

/* Scrubber / Progress bar */
.scrub-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.scrub-slider {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  transition: height 0.15s ease;
}
.scrub-slider:hover {
  height: 6px;
}
.scrub-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
  transition: transform 0.1s ease;
}
.scrub-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.time-display {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Main Controls Row */
.controls-main-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.controls-left,
.controls-center,
.controls-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ctrl-btn {
  background: transparent;
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}
.ctrl-btn:active {
  transform: scale(0.95);
}
.ctrl-btn.play-btn {
  width: 42px;
  height: 42px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
}
.ctrl-btn.play-btn:hover {
  background: var(--accent-primary);
  transform: scale(1.05);
}

/* Live Badge */
.live-indicator-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(239, 68, 68, 0.2);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  border: 1px solid rgba(239, 68, 68, 0.4);
}
.live-dot-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--status-live);
  box-shadow: 0 0 6px var(--status-live);
  animation: pulse-live 1.5s infinite;
}
@keyframes pulse-live {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
  100% { opacity: 1; transform: scale(1); }
}

/* Volume Slider */
.volume-control-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.volume-slider {
  width: 72px;
  height: 4px;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}

/* Tuning Selectors (Dyna / Deint) */
.ctrl-select {
  height: 28px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  padding: 0 8px;
  color: #fff;
  font-size: 11px;
  font-family: var(--font-sans);
  cursor: pointer;
  outline: none;
}
.ctrl-select option {
  background: #181d26;
  color: #fff;
}

.tier-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.2);
  color: var(--accent-primary);
  border: 1px solid rgba(59, 130, 246, 0.3);
}
.tier-badge.tier-software {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.3);
}

/* --------------------------------------------------------------------------
   Modals
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  width: 520px;
  max-width: 92vw;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-backdrop.visible .modal-dialog {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}
.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}
.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}
.modal-close-btn:hover {
  color: #fff;
}

/* Modal Tab Navigation */
.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
}
.modal-tab {
  flex: 1;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}
.modal-tab:hover {
  color: var(--text-main);
}
.modal-tab.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
  background: var(--bg-surface);
}

.modal-body {
  padding: 20px;
}
.tab-pane {
  display: none;
  flex-direction: column;
  gap: 16px;
}
.tab-pane.active {
  display: flex;
}

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-md);
  padding: 32px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  background: var(--bg-card);
  transition: all 0.2s ease;
}
.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent-primary);
  background: rgba(59, 130, 246, 0.08);
}
.dropzone-icon {
  width: 44px;
  height: 44px;
  color: var(--accent-primary);
}
.dropzone-text {
  font-weight: 600;
  color: var(--text-main);
}
.dropzone-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.input-field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.input-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.text-input {
  width: 100%;
  height: 38px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  color: #fff;
  font-size: 13px;
  outline: none;
}
.text-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.textarea-input {
  width: 100%;
  height: 120px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
  resize: vertical;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg-surface);
}

/* Sample playlist cards */
.sample-playlists-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sample-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
}
.sample-card:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
}
.sample-card-title {
  font-weight: 600;
  color: #fff;
}
.sample-card-desc {
  font-size: 11px;
  color: var(--text-muted);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 110;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 10px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slide-toast 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slide-toast {
  from { transform: translateX(30px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.8);
  }
  .topbar-center {
    display: none;
  }
  .controls-main-row {
    flex-wrap: wrap;
  }
}

/* --------------------------------------------------------------------------
   Login Screen (Xtream credentials)
   -------------------------------------------------------------------------- */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(59, 130, 246, 0.18), transparent), var(--bg-base);
}
.login-screen[hidden] {
  display: none;
}
.login-card {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  padding: 32px 30px 26px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 16px;
}
.login-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}
.login-sub {
  margin: 4px 0 14px;
  font-size: 13px;
  color: var(--text-muted);
}
.login-card .input-label {
  margin-top: 10px;
}
.login-error {
  min-height: 18px;
  margin-top: 12px;
  font-size: 12px;
  color: #ef4444;
}
.login-submit {
  margin-top: 6px;
  width: 100%;
  justify-content: center;
}
.login-hint {
  margin-top: 12px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-muted);
}

/* Topbar user chip */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 999px;
}
.user-chip-icon {
  display: inline-flex;
  color: var(--accent-primary);
}
.user-name {
  font-size: 12px;
  font-weight: 600;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-chip .btn {
  padding: 4px 10px;
  font-size: 12px;
}

