/* 
  YVR — Machined Monolithic Extrusions
  Physical metaphors: Brushed metal, sharp locks, tactile buttons, deep voids.
*/

:root {
  /* DARK MODE (Gunmetal & Tungsten) */
  --bg-void: #0a0b0d; /* deep anechoic chamber */
  --surface-base: #141518; /* massive chassis backing */
  --surface-extrusion: #1e1f24; /* raised plates */
  --surface-hardware: #282930; /* tactile toggles */
  
  --edge-highlight: rgba(255, 255, 255, 0.08);
  --edge-shadow: rgba(0, 0, 0, 0.9);
  
  --text-active: #ffffff;
  --text-idle: #7a7d8a;
  --text-console: #4acc85;
  
  --accent-mechanical: #ff5500; /* Industrial hazard orange */
  --accent-dim: rgba(255, 85, 0, 0.15);
  
  --status-active: #00e676; /* LED green */
  --status-dim: rgba(0, 230, 118, 0.15);

  --shadow-deep: inset 1px 1px 0px var(--edge-highlight), inset -1px -1px 0px var(--edge-shadow), 6px 6px 15px rgba(0,0,0,0.8);
  --shadow-pressed: inset 2px 2px 5px var(--edge-shadow), inset -1px -1px 0px var(--edge-highlight);
}

.theme-light {
  /* LIGHT MODE (Brushed Aluminum & Steel) */
  --bg-void: #caced5; 
  --surface-base: #e6e8eb; 
  --surface-extrusion: #f4f5f7; 
  --surface-hardware: #ffffff; 
  
  --edge-highlight: rgba(255, 255, 255, 0.9);
  --edge-shadow: rgba(140, 145, 155, 0.5);
  
  --text-active: #0d0f12;
  --text-idle: #676a73;
  --text-console: #008a44;
  
  --accent-mechanical: #d83a00;
  --accent-dim: rgba(216, 58, 0, 0.1);

  --status-active: #00b050;
  --status-dim: rgba(0, 176, 80, 0.15);

  --shadow-deep: inset 1px 1px 0px var(--edge-highlight), inset -1px -1px 0px var(--edge-shadow), 4px 4px 10px rgba(120,125,135,0.4);
  --shadow-pressed: inset 2px 2px 4px var(--edge-shadow), inset -1px -1px 0px var(--edge-highlight);
}

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

body {
  background-color: var(--bg-void);
  color: var(--text-idle);
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  line-height: 1.5;
  transition: background-color 0.4s ease, color 0.4s ease;
  overflow-x: hidden;
  /* Tablet first constraint handling */
  display: flex;
  justify-content: center;
  padding: 1rem;
}

/* Typography Utilities */
.console-font {
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-console);
}

/* Main Chassis Layout */
.machined-chassis {
  background: var(--surface-base);
  width: 100%;
  max-width: 1440px; 
  min-height: 95vh;
  border: 1px solid var(--edge-shadow);
  box-shadow: inset 1px 1px 0px var(--edge-highlight), 10px 10px 30px rgba(0,0,0,0.6);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
}

/* Header Plate */
.chassis-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  background: var(--surface-extrusion);
  border-bottom: 2px solid var(--edge-shadow);
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  position: relative;
  z-index: 10;
}

.logo-lockup { display: flex; align-items: center; gap: 1.5rem; }
.logo-block {
  background: var(--accent-mechanical);
  color: #fff;
  padding: 0.5rem 1rem;
  font-family: 'Chakra Petch', sans-serif;
  font-weight: 700;
  font-size: 1.8rem;
  letter-spacing: 0.1em;
  border-radius: 2px;
  box-shadow: inset -2px -2px 0px rgba(0,0,0,0.3), inset 2px 2px 0px rgba(255,255,255,0.4);
}

.brand-metadata { display: flex; flex-direction: column; }
.brand-metadata .system-code { font-weight: 700; color: var(--text-active); font-family: 'Chakra Petch', sans-serif; letter-spacing: 0.15em; }
.brand-metadata .subtitle { font-size: 0.75rem; opacity: 0.6; }

.sys-controls { display: flex; align-items: center; gap: 1.5rem; }

/* Status */
.hardware-indicator {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-size: 0.8rem; color: var(--text-idle); text-transform: uppercase;
  background: var(--bg-void); padding: 0.5rem 1rem;
  border: 1px solid var(--edge-shadow); box-shadow: inset 1px 1px 3px rgba(0,0,0,0.5);
}
.hardware-indicator.active { color: var(--status-active); }
.hardware-indicator.active::before {
  content: ''; display: block; width: 8px; height: 8px; background: var(--status-active); border-radius: 50%; box-shadow: 0 0 8px var(--status-active);
}

/* Buttons */
.btn {
  font-family: 'Chakra Petch', sans-serif; font-weight: 700; text-transform: uppercase;
  cursor: pointer; border: none; outline: none; transition: all 0.1s linear; user-select: none;
}
.hardware-btn {
  background: var(--surface-hardware); color: var(--text-active); padding: 0.6rem 1.2rem;
  border: 1px solid var(--edge-shadow); box-shadow: var(--shadow-deep); border-radius: 3px;
  letter-spacing: 0.05em; display: inline-flex; align-items: center; justify-content: center;
}
.hardware-btn:hover { background: var(--surface-extrusion); }
.hardware-btn:active { box-shadow: var(--shadow-pressed); transform: translateY(2px); }
.hardware-btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; background: var(--bg-void); color: var(--text-idle); transform: none; }

.btn-primary {
  background: var(--surface-hardware); border: 1px solid var(--edge-shadow); color: var(--accent-mechanical);
  box-shadow: var(--shadow-deep); padding: 0.5rem 1rem; font-family: 'Chakra Petch', sans-serif; font-weight: 700; text-transform: uppercase; border-radius: 2px;
}
.btn-primary:active { box-shadow: var(--shadow-pressed); transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.4; background: var(--surface-base); box-shadow: inset 1px 1px 3px rgba(0,0,0,0.3); color: var(--text-idle); }

.icon-btn { padding: 0.7rem; width: 44px; height: 44px; }
.toggle-shape { width: 16px; height: 16px; border: 2px solid currentColor; border-radius: 2px; transition: transform 0.3s ease; }
.theme-light .toggle-shape { background: currentColor; transform: rotate(45deg); }

/* Tabs */
.mechanism-track {
  display: flex; background: var(--bg-void); padding: 1rem 2rem 0; gap: 0.5rem; border-bottom: 3px solid var(--surface-hardware);
}
.hardware-tab {
  background: var(--surface-base); color: var(--text-idle); padding: 1rem 1.5rem;
  border: 1px solid var(--edge-shadow); border-bottom: none;
  font-family: 'Chakra Petch', sans-serif; font-weight: 700; font-size: 1rem; text-transform: uppercase;
  position: relative; box-shadow: inset 0px -10px 10px rgba(0,0,0,0.2); border-radius: 4px 4px 0 0;
}
.hardware-tab:hover { background: var(--surface-extrusion); color: var(--text-active); }
.hardware-tab.active {
  background: var(--surface-hardware); color: var(--accent-mechanical);
  box-shadow: inset 1px 1px 0px var(--edge-highlight);
  border-left: 1px solid var(--edge-highlight); border-right: 1px solid var(--edge-shadow);
}
.active-indicator { position: absolute; top: 0; left: 0; width: 100%; height: 3px; background: transparent; }
.hardware-tab.active .active-indicator { background: var(--accent-mechanical); box-shadow: 0 2px 10px var(--accent-dim); }

/* Viewport */
.viewport-void {
  flex: 1; background: var(--bg-void); padding: 2rem; position: relative; overflow-y: auto;
  background-image: linear-gradient(to bottom, rgba(255,255,255,0.01) 50%, transparent 50%); background-size: 100% 4px;
}
.tab-content { display: none; animation: mechanicalSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
.tab-content.active { display: block; }

@keyframes mechanicalSlideIn { 0% { transform: translateY(20px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }

/* Plugin Bars / Filters */
.plugin-bar {
  margin-bottom: 1.5rem;
}
.multi-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.5rem;
}
.hardware-input {
  width: 100%; background: var(--surface-base); color: var(--text-active); border: 1px solid var(--edge-shadow);
  padding: 0.8rem 1rem; font-family: 'JetBrains Mono', monospace; font-size: 0.9rem;
  box-shadow: inset 2px 2px 5px var(--edge-shadow), inset -1px -1px 0px var(--edge-highlight); outline: none; transition: border-color 0.2s; border-radius: 2px;
}
.hardware-input:focus { border-color: var(--accent-mechanical); }
select.hardware-input { appearance: none; cursor: pointer; }

/* Player Control */
.player-container {
  background: var(--surface-extrusion); border: 1px solid var(--edge-shadow); box-shadow: var(--shadow-deep);
  margin-bottom: 2rem; padding: 1rem; animation: mechanicalSlideIn 0.4s ease-out;
}
.player-container.hidden { display: none; }
.player-bezel { background: #000; padding: 2px; border: 2px solid var(--surface-hardware); box-shadow: inset 0 0 20px rgba(0,0,0,1); }
.player-header-bar { display: flex; justify-content: space-between; align-items: center; background: var(--surface-base); padding: 0.5rem 1rem; border-bottom: 1px solid var(--edge-shadow); }
.screen-aperture { width: 100%; background: #000; position: relative; padding-top: 56.25%; }
.screen-aperture video { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: contain; }
.screen-aperture iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.player-controls-right { display: flex; gap: 0.5rem; align-items: center; }
.subs-btn { font-size: 0.75rem; padding: 0.4rem 0.6rem; letter-spacing: 0.05em; }
.subs-btn.active { color: var(--accent-mechanical); border-color: var(--accent-mechanical); box-shadow: 0 0 6px var(--accent-dim); }

/* Default Grid (for dubbed) */
.hardware-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1.5rem;
}

/* Card General */
.video-card {
  background: var(--surface-extrusion); border: 1px solid var(--edge-shadow); box-shadow: var(--shadow-deep);
  border-radius: 2px; display: flex; flex-direction: column; position: relative; overflow: hidden; transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.video-card:hover { transform: translateY(-2px); box-shadow: inset 1px 1px 0px var(--edge-highlight), inset -1px -1px 0px var(--edge-shadow), 8px 8px 20px rgba(0,0,0,0.7); }
.theme-light .video-card:hover { box-shadow: inset 1px 1px 0px var(--edge-highlight), inset -1px -1px 0px var(--edge-shadow), 6px 6px 15px rgba(120,125,135,0.6); }

.card-thumb { position: relative; border-bottom: 2px solid var(--surface-base); background: #000; padding: 4px; }
.card-thumb img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; opacity: 0.8; filter: contrast(1.1) saturate(0.9) grayscale(0.2); transition: all 0.3s ease; }
.video-card:hover .card-thumb img { opacity: 1; filter: contrast(1) saturate(1) grayscale(0); }

/* In-line Badges */
.card-badge {
  font-family: 'JetBrains Mono', monospace; font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  padding: 0.3rem 0.6rem; background: var(--bg-void); border: 1px solid var(--edge-shadow); box-shadow: inset 1px 1px 0px rgba(255,255,255,0.2);
}
.badge-pending { color: var(--text-idle); }
.badge-processing { color: var(--accent-mechanical); background: var(--accent-dim); border-color: var(--accent-mechanical); }
.badge-completed { color: var(--status-active); background: var(--status-dim); border-color: var(--status-active); }
.badge-failed { color: #ff3333; }

.card-body { padding: 1.25rem; display: flex; flex-direction: column; flex: 1; }
.card-title { color: var(--text-active); font-family: 'Chakra Petch', sans-serif; font-size: 1.1rem; font-weight: 600; line-height: 1.4; margin-bottom: 1rem; text-shadow: 1px 1px 0px rgba(0,0,0,0.5); display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.theme-light .card-title { text-shadow: none; }
.card-meta { margin-top: auto; display: flex; justify-content: space-between; align-items: center; font-size: 0.8rem; color: var(--text-idle); text-transform: uppercase; border-top: 1px dotted var(--edge-shadow); padding-top: 0.75rem; }
.voice-badge { background: var(--surface-base); padding: 0.2rem 0.5rem; border: 1px solid var(--edge-shadow); border-radius: 2px; color: var(--accent-mechanical); }

.card-actions {
  padding: 1rem; background: var(--surface-base); border-top: 1px solid var(--edge-shadow);
  display: flex; justify-content: space-between; align-items: center;
}

/* List Mode (for sub-feed & playlists) */
.list-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); gap: 0.75rem; }
@media (max-width: 600px) { .list-grid { grid-template-columns: 1fr; } }
.list-card { flex-direction: row; height: 90px; cursor: pointer; }
.list-card .card-thumb { width: 156px; flex-shrink: 0; border-bottom: none; border-right: 2px solid var(--surface-base); }
.list-card .card-body { padding: 0.75rem 1rem; justify-content: center; }
.list-card .card-title { font-size: 0.95rem; margin-bottom: 0.25rem; -webkit-line-clamp: 1; line-clamp: 1; }
.list-card .card-meta { border-top: none; padding-top: 0; font-size: 0.75rem; }

/* Loadings */
.loading { color: var(--text-console); margin: 2rem 0; display: inline-block; padding: 1rem; background: rgba(0,0,0,0.5); border: 1px solid var(--text-console); box-shadow: inset 0 0 10px rgba(74, 204, 133, 0.2); }
.loading-state { margin-bottom: 2rem; font-size: 0.9rem; }

/* Sub Groups */
.date-group { margin-bottom: 3rem; animation: mechanicalSlideIn 0.4s ease-out; }
.date-group h3 {
  font-family: 'Chakra Petch', sans-serif; font-size: 1.2rem; color: var(--text-active); text-transform: uppercase; letter-spacing: 0.1em;
  border-bottom: 2px solid var(--surface-hardware); padding-bottom: 0.5rem; margin-bottom: 1.5rem; display: inline-block; text-shadow: 1px 1px 0px rgba(0,0,0,0.8);
}
.theme-light .date-group h3 { text-shadow: none; }

/* Dubbed header */
.dubbed-header { display: flex; justify-content: space-between; align-items: flex-start; }
.channels-gear { font-size: 0.7rem; padding: 0.4rem 0.8rem; letter-spacing: 0.1em; }

/* Channels Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 100;
  background: rgba(0, 0, 0, 0.7); display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.15s ease;
}
.modal-overlay.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-panel {
  background: var(--surface-base); border: 1px solid var(--edge-shadow);
  box-shadow: var(--shadow-deep); width: 90%; max-width: 480px;
  padding: 1.5rem; animation: mechanicalSlideIn 0.3s ease;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.5rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--edge-shadow);
}
.channels-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; max-height: 300px; overflow-y: auto; }
.channel-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface-extrusion); border: 1px solid var(--edge-shadow);
  padding: 0.6rem 1rem; gap: 0.75rem;
}
.channel-handle { color: var(--text-active); font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 0.95rem; flex: 1; }
.channel-engine { color: var(--text-idle); font-size: 0.75rem; text-transform: uppercase; }
.channel-delete {
  background: none; border: 1px solid var(--edge-shadow); color: #ff3333;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1rem; transition: all 0.1s;
}
.channel-delete:hover { background: rgba(255, 51, 51, 0.15); border-color: #ff3333; }

.channel-add-row { display: flex; gap: 0.5rem; }
.channel-add-row .hardware-input { flex: 1; }
.channel-add-btn { font-size: 1.2rem; padding: 0.5rem 1rem; color: var(--status-active); }
