/* ==========================================================================
   PlayStation Design System (Dark & Light Mode)
   Inspired by Official PlayStation Design Language
   Tokens: Primary #0070d1, Commerce #d53b00, Canvas #000000 / #ffffff
   Radii: 4px (inputs), 8px (cards), 9999px (pills & CTAs)
   Typography: Display Weight 300 (Light), Buttons Weight 700 (Bold)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

:root,
[data-theme="dark"] {
  /* PlayStation Dark Canvas */
  --canvas-bg: #000000;
  --surface-elevated: #121314;
  --surface-card: #181818;
  --surface-hover: #222224;
  --surface-soft: #1e1e20;
  --hairline: rgba(229, 229, 229, 0.15);
  --hairline-subtle: rgba(255, 255, 255, 0.08);

  /* Typography Colors */
  --text-primary: #ffffff;
  --text-body: rgba(255, 255, 255, 0.75);
  --text-muted: rgba(229, 229, 229, 0.55);
  --text-dim: rgba(229, 229, 229, 0.35);

  /* Inputs */
  --input-bg: #121314;
  --input-border: rgba(229, 229, 229, 0.25);
  --input-text: #ffffff;

  /* Filter Pills */
  --pill-bg: rgba(255, 255, 255, 0.08);
  --pill-text: rgba(255, 255, 255, 0.75);
  --pill-active-bg: #ffffff;
  --pill-active-text: #000000;

  /* Navbar */
  --nav-bg: rgba(0, 0, 0, 0.92);
  --nav-border: rgba(229, 229, 229, 0.12);

  /* Badges */
  --badge-live-bg: rgba(213, 59, 0, 0.15);
  --badge-live-text: #ff5216;
  --badge-live-border: rgba(213, 59, 0, 0.4);

  /* Brand Accents */
  --ps-blue: #0070d1;
  --ps-blue-pressed: #0064b7;
  --ps-blue-active: #004d8d;
  --ps-commerce: #d53b00;
  --ps-commerce-pressed: #aa2f00;
  --ps-gold-start: #ffce21;
  --ps-gold-mid: #f5a623;
  --ps-gold-end: #ee8e00;

  --success: #10b981;
  --warning: #f5a623;
  --danger: #c81b3a;

  --shadow-lift: 0 4px 14px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] {
  /* PlayStation Light Canvas */
  --canvas-bg: #ffffff;
  --surface-elevated: #f3f3f3;
  --surface-card: #f5f7fa;
  --surface-hover: #eaedf2;
  --surface-soft: #f8fafc;
  --hairline: #e2e8f0;
  --hairline-subtle: rgba(0, 0, 0, 0.06);

  /* Typography Colors */
  --text-primary: #000000;
  --text-body: rgba(0, 0, 0, 0.68);
  --text-muted: #6b6b6b;
  --text-dim: #94a3b8;

  /* Inputs */
  --input-bg: #ffffff;
  --input-border: #cbd5e1;
  --input-text: #000000;

  /* Filter Pills */
  --pill-bg: rgba(0, 0, 0, 0.05);
  --pill-text: rgba(0, 0, 0, 0.7);
  --pill-active-bg: #000000;
  --pill-active-text: #ffffff;

  /* Navbar */
  --nav-bg: rgba(255, 255, 255, 0.95);
  --nav-border: #e2e8f0;

  /* Badges */
  --badge-live-bg: rgba(213, 59, 0, 0.1);
  --badge-live-text: #d53b00;
  --badge-live-border: rgba(213, 59, 0, 0.3);

  /* Brand Accents */
  --ps-blue: #0070d1;
  --ps-blue-pressed: #0064b7;
  --ps-blue-active: #004d8d;
  --ps-commerce: #d53b00;
  --ps-commerce-pressed: #aa2f00;
  --ps-gold-start: #ffce21;
  --ps-gold-mid: #f5a623;
  --ps-gold-end: #ee8e00;

  --success: #059669;
  --warning: #d97706;
  --danger: #c81b3a;

  --shadow-lift: 0 4px 14px rgba(0, 0, 0, 0.08);
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--canvas-bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* PlayStation Header Navigation */
.navbar {
  height: 64px;
  border-bottom: 1px solid var(--nav-border);
  background: var(--nav-bg);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  transition: all 0.25s ease;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

/* PlayStation Symbol Mark */
.ps-logo-mark {
  width: 38px;
  height: 38px;
  background: var(--ps-blue);
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 112, 209, 0.4);
  flex-shrink: 0;
}

.ps-logo-mark svg {
  width: 22px;
  height: 22px;
  fill: #ffffff;
}

.brand-text h2 {
  font-size: 1.15rem;
  font-weight: 300; /* Signature PlayStation 300 Light display */
  letter-spacing: -0.1px;
  color: var(--text-primary);
  line-height: 1.15;
}

.brand-text span {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

/* Navbar Stat Pills */
.nav-stats {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.stat-pill {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  padding: 0.32rem 0.75rem;
  border-radius: 9999px; /* Rounded full */
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text-muted);
  white-space: nowrap;
  transition: all 0.2s ease;
}

.stat-pill strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Top Right User & Theme Cluster */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

/* PlayStation Theme Switcher Button */
.theme-toggle-btn {
  width: 36px;
  height: 36px;
  border-radius: 9999px;
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
  background: var(--surface-hover);
  border-color: var(--ps-blue);
}

.theme-toggle-btn svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 9999px;
  background: var(--ps-blue);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: 0 2px 6px rgba(0, 112, 209, 0.3);
}

/* Main Container */
.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
}

/* PlayStation Filter Pill Navigation (Tabs) */
.tabs-nav {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 2.25rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--hairline);
}

.tab-btn {
  background: var(--pill-bg);
  color: var(--pill-text);
  border: 1px solid transparent;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  padding: 0.55rem 1.25rem;
  border-radius: 9999px; /* PlayStation Filter Pill Spec */
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--ps-blue);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 112, 209, 0.35);
}

.tab-count {
  background: rgba(0, 0, 0, 0.2);
  color: inherit;
  padding: 0.1rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 700;
}

[data-theme="light"] .tab-btn:not(.active) .tab-count {
  background: rgba(0, 0, 0, 0.08);
}

/* PlayStation Product Card */
.card {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: 8px; /* Signature PlayStation 8px radius */
  padding: 1.75rem;
  margin-bottom: 1.75rem;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.card-title {
  font-size: 1.45rem;
  font-weight: 300; /* Signature Display Weight 300 */
  letter-spacing: -0.1px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* PlayStation Buttons Hierarchy */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700; /* Signature Button Weight 700 */
  letter-spacing: 0.45px;
  padding: 0.65rem 1.6rem;
  border-radius: 9999px; /* Signature fully-rounded pill */
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  white-space: nowrap;
}

/* button-primary: PlayStation Blue #0070d1 */
.btn-primary {
  background-color: var(--ps-blue);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--ps-blue-pressed);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 112, 209, 0.4);
}

.btn-primary:active {
  background-color: var(--ps-blue-active);
  transform: translateY(0);
}

/* button-commerce: PlayStation Commerce Orange #d53b00 */
.btn-commerce {
  background-color: var(--ps-commerce);
  color: #ffffff;
}

.btn-commerce:hover {
  background-color: var(--ps-commerce-pressed);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(213, 59, 0, 0.4);
}

/* button-secondary: Clean outline pill */
.btn-secondary {
  background-color: transparent;
  border-color: var(--hairline);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: var(--surface-hover);
  border-color: var(--text-muted);
}

/* Danger Action */
.btn-danger {
  background-color: rgba(200, 27, 58, 0.12);
  border-color: rgba(200, 27, 58, 0.35);
  color: #ff4d6d;
}

[data-theme="light"] .btn-danger {
  color: #c81b3a;
}

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

.btn-sm {
  padding: 0.4rem 1rem;
  font-size: 0.78rem;
  letter-spacing: 0.3px;
}

/* Forms & Inputs (4px rounded per PS spec) */
.form-group {
  margin-bottom: 1.35rem;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.45rem;
  letter-spacing: 0.1px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 4px; /* PlayStation Spec: 4px radius */
  color: var(--input-text);
  font-family: inherit;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--ps-blue);
  box-shadow: 0 0 0 2px rgba(0, 112, 209, 0.25);
}

.input-icon-wrapper {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
}

.form-input.has-icon {
  padding-left: 2.75rem;
}

/* PlayStation Game Tile / Video Card */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.video-card {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: 8px; /* 8px signature */
  overflow: hidden;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
}

.video-card:hover {
  transform: translateY(-3px);
  border-color: var(--ps-blue);
  box-shadow: var(--shadow-lift);
}

.video-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #121314;
  position: relative;
  display: block;
}

.video-duration {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.85);
  color: #ffffff;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.video-info {
  padding: 1.15rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.video-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.45rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
}

.video-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1.15rem;
}

.video-meta span {
  background: var(--surface-hover);
  border: 1px solid var(--hairline-subtle);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 500;
}

/* Upload Dropzone */
.upload-dropzone {
  border: 2px dashed var(--hairline);
  border-radius: 8px;
  padding: 2.75rem 1.5rem;
  text-align: center;
  background: var(--surface-card);
  cursor: pointer;
  transition: all 0.25s ease;
}

.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: var(--ps-blue);
  background: var(--surface-hover);
}

.upload-icon {
  width: 44px;
  height: 44px;
  color: var(--ps-blue);
  margin-bottom: 0.85rem;
}

/* Progress Bars */
.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: var(--hairline);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--ps-blue);
  transition: width 0.2s ease;
}

/* Bulk Upload Queue Item */
.queue-item {
  background: var(--surface-elevated);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  transition: all 0.2s ease;
}

.queue-item.uploading {
  border-left: 3px solid var(--ps-blue);
}

.queue-item.completed {
  border-left: 3px solid var(--success);
}

.queue-item.error {
  border-left: 3px solid var(--danger);
}

.queue-item.queued {
  border-left: 3px solid var(--text-dim);
}

.queue-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  margin-bottom: 0.45rem;
}

.queue-item-name {
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 65%;
}

/* Badges & Live Status */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.badge-live {
  background: var(--badge-live-bg);
  color: var(--badge-live-text);
  border: 1px solid var(--badge-live-border);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: var(--ps-commerce);
  border-radius: 9999px;
  box-shadow: 0 0 0 0 rgba(213, 59, 0, 0.7);
  animation: pulse-ps 1.6s infinite;
}

@keyframes pulse-ps {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(213, 59, 0, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(213, 59, 0, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(213, 59, 0, 0); }
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
}

.badge-warning {
  background: rgba(245, 166, 35, 0.15);
  color: var(--warning);
}

.badge-info {
  background: rgba(0, 112, 209, 0.15);
  color: var(--ps-blue);
}

.badge-secondary {
  background: var(--surface-hover);
  color: var(--text-muted);
}

/* Active Stream Cards */
.stream-session-card {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-left: 4px solid var(--ps-commerce);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-lift);
}

.target-stream-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.15rem;
  background: var(--surface-elevated);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  margin-top: 0.75rem;
  flex-wrap: wrap;
  gap: 0.85rem;
}

.stream-stats {
  display: flex;
  gap: 1.35rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.stream-stats strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Tables */
.table-responsive {
  overflow-x: auto;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.custom-table th {
  padding: 0.95rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--hairline);
}

.custom-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--hairline);
  font-size: 0.88rem;
  color: var(--text-primary);
}

.custom-table tr:hover td {
  background: var(--surface-hover);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.5rem;
}

.modal-content {
  background: var(--canvas-bg);
  border: 1px solid var(--hairline);
  border-radius: 8px; /* 8px modal radius */
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
  color: var(--text-primary);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 1rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s ease;
}

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

/* Terminal Console View */
.terminal-window {
  background: #000000;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 1rem;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.8rem;
  color: #4ade80;
  height: 280px;
  overflow-y: auto;
  line-height: 1.6;
}

/* Alert Boxes */
.alert {
  padding: 0.85rem 1.15rem;
  border-radius: 6px;
  font-size: 0.85rem;
}

.alert-danger {
  background: rgba(200, 27, 58, 0.15);
  border: 1px solid rgba(200, 27, 58, 0.35);
  color: #ff5277;
}

.alert-success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: var(--success);
}

/* Toast */
#toastContainer {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  color: var(--text-primary);
  padding: 0.85rem 1.25rem;
  border-radius: 9999px;
  font-size: 0.88rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.3s ease;
}

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

@media (max-width: 900px) {
  .navbar {
    padding: 0 1rem;
  }
  .container {
    padding: 1.5rem 1rem;
  }
  .nav-stats {
    display: none;
  }
}
