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

:root {
  --bg-dark: #060608;
  --bg-panel: rgba(13, 13, 18, 0.8);
  --bg-panel-solid: #0d0d12;
  --accent-neon: #a855f7;
  --accent-neon-glow: rgba(168, 85, 247, 0.4);
  --accent-blue: #3b82f6;
  --accent-blue-glow: rgba(59, 130, 246, 0.4);
  --accent-green: #10b981;
  --accent-danger: #ef4444;
  --border-light: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(168, 85, 247, 0.15);
  --text-bright: #f3f4f6;
  --text-main: #d1d5db;
  --text-muted: #6b7280;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-family: 'Outfit', system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* ==========================================================================
   VIDEO GRID LAYOUT (Square Corners)
   ========================================================================== */
.video-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 12px;
  padding: 12px;
  width: 100vw;
  height: 100vh;
  padding-bottom: 64px; /* Space for the 52px tall slim bottom bar (52px bar + 12px margin) */
  background: radial-gradient(circle at center, #120e20 0%, var(--bg-dark) 100%);
  transition: var(--transition-smooth);
}

#cell-0 { grid-column: 2 / 5; grid-row: 2 / 4; }
#cell-1 { grid-column: 1; grid-row: 1; }
#cell-2 { grid-column: 2; grid-row: 1; }
#cell-3 { grid-column: 3; grid-row: 1; }
#cell-4 { grid-column: 4; grid-row: 1; }
#cell-5 { grid-column: 5; grid-row: 1; }
#cell-6 { grid-column: 1; grid-row: 2; }
#cell-7 { grid-column: 5; grid-row: 2; }
#cell-8 { grid-column: 1; grid-row: 3; }
#cell-9 { grid-column: 5; grid-row: 3; }

.video-cell {
  position: relative;
  background-color: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-light);
  border-radius: 0; /* Pure Square Corners */
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  transition: var(--transition-smooth);
}

.video-cell:hover {
  border-color: var(--border-glow);
  box-shadow: 0 8px 30px rgba(168, 85, 247, 0.1);
}

/* Video Cell Header (Fades in on Hover, Square Corners) */
.video-cell-header {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 10px 16px;
  background: linear-gradient(to bottom, rgba(10, 10, 14, 0.9) 0%, rgba(10, 10, 14, 0.6) 60%, rgba(0,0,0,0) 100%);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  opacity: 0;
  transform: translateY(-5px);
  pointer-events: none;
  transition: var(--transition-smooth);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.video-cell:hover .video-cell-header {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.video-title {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-bright);
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.video-title::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 0; /* Square indicator */
  background-color: var(--accent-neon);
  box-shadow: 0 0 8px var(--accent-neon);
}

.cell-controls {
  display: flex;
  gap: 8px;
}

.cell-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 0; /* Pure Square Corners */
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-bright);
  transition: var(--transition-smooth);
}

.cell-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.cell-btn:hover {
  background: var(--accent-neon);
  border-color: var(--accent-neon);
  box-shadow: 0 0 10px var(--accent-neon-glow);
  transform: translateY(-1px);
}

.cell-btn:active {
  transform: translateY(1px);
}

/* Video Iframe Container */
.video-iframe-container {
  width: 100%;
  height: 100%;
  flex-grow: 1;
  background-color: #000;
  position: relative;
}

.video-iframe-container iframe {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
}

/* Video Cell Placeholders (Square Corners) */
.cell-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, rgba(18, 18, 24, 0.95) 0%, rgba(6, 6, 8, 0.98) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  z-index: 5;
  transition: var(--transition-smooth);
}

.placeholder-content {
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.placeholder-icon {
  width: 56px;
  height: 56px;
  background: rgba(168, 85, 247, 0.1);
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-radius: 0; /* Square icon wrapper */
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: var(--accent-neon);
  box-shadow: inset 0 0 12px rgba(168, 85, 247, 0.05);
}

.placeholder-icon svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.placeholder-content h3 {
  color: var(--text-bright);
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 8px;
}

.placeholder-content p {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.4;
  margin-bottom: 20px;
}

.add-url-shortcut-btn {
  background: transparent;
  border: 1px dashed var(--accent-neon);
  color: var(--accent-neon);
  padding: 8px 16px;
  border-radius: 0; /* Square corners */
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.add-url-shortcut-btn:hover {
  background: var(--accent-neon);
  color: var(--text-bright);
  border-color: var(--accent-neon);
  box-shadow: 0 0 15px var(--accent-neon-glow);
}

/* Fullscreen expanded state */
.video-cell.expanded {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 10000;
  border-radius: 0;
  border: none;
  padding: 0;
  margin: 0;
}

.video-cell.expanded .video-cell-header {
  border-radius: 0;
}

/* ==========================================================================
   SLIM FULL-WIDTH MASTER CONTROL BAR
   ========================================================================== */
.master-control-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100vw;
  height: 52px; /* Slim in height */
  background: var(--bg-panel);
  backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--border-light);
  border-left: none;
  border-right: none;
  border-bottom: none;
  border-radius: 0; /* Perfectly Square bottom bar */
  padding: 0 24px;
  z-index: 100;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: space-between; /* Spreads brand to left and buttons to right */
  transition: var(--transition-smooth);
}

.master-control-bar:hover {
  border-color: var(--border-glow);
}

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

.brand-logo {
  color: var(--accent-neon);
  display: flex;
  align-items: center;
}

.brand-logo svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  filter: drop-shadow(0 0 6px var(--accent-neon-glow));
}

.brand-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-bright);
  letter-spacing: 0.5px;
  line-height: 1.1;
}

.brand-text-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}

.brand-maintainer {
  font-size: 0.58rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.1px;
  line-height: 1;
}

.brand-maintainer a {
  color: var(--accent-neon);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease, text-shadow 0.2s ease;
}

.brand-maintainer a:hover {
  color: #b56ff9;
  text-decoration: underline;
  text-shadow: 0 0 4px var(--accent-neon-glow);
}

.active-indicator {
  background: rgba(168, 85, 247, 0.12);
  border: 1px solid rgba(168, 85, 247, 0.2);
  color: var(--accent-neon);
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 0; /* Square badge */
  font-weight: 500;
  margin-left: 4px;
  white-space: nowrap;
  letter-spacing: 0.25px;
}

.bar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
}

.bar-divider {
  width: 1px;
  height: 18px;
  background-color: rgba(255, 255, 255, 0.1);
  margin: 0 4px;
}

.bar-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.02);
  border-radius: 0; /* Perfectly Square corners */
  height: 32px; /* Slimmer buttons to match slim height */
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text-main);
  font-family: var(--font-family);
  font-weight: 500;
  font-size: 0.8rem;
  transition: var(--transition-smooth);
}

.bar-btn svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.bar-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-bright);
  transform: translateY(-1px);
}

.bar-btn:active {
  transform: translateY(1px);
}

.bar-btn.btn-primary {
  background: var(--accent-neon);
  border-color: var(--accent-neon);
  color: var(--text-bright);
  box-shadow: 0 4px 10px var(--accent-neon-glow);
}

.bar-btn.btn-primary:hover {
  background: #b56ff9;
  box-shadow: 0 6px 12px rgba(168, 85, 247, 0.5);
}

.bar-btn.btn-settings {
  background: rgba(168, 85, 247, 0.1);
  border-color: rgba(168, 85, 247, 0.2);
  color: var(--accent-neon);
}

.bar-btn.btn-settings:hover {
  background: var(--accent-neon);
  color: var(--text-bright);
  border-color: var(--accent-neon);
  box-shadow: 0 0 12px var(--accent-neon-glow);
}

/* Record Button Styles (Glows red and pulses when active) */

.bar-btn.btn-record.recording {
  background: rgba(239, 68, 68, 0.25) !important;
  border-color: rgba(239, 68, 68, 0.6) !important;
  color: #ff3333 !important;
  animation: pulse-red 1.5s infinite alternate;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.6);
}

@keyframes pulse-red {
  0% {
    box-shadow: 0 0 5px rgba(239, 68, 68, 0.4);
  }
  100% {
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.8);
  }
}

/* ==========================================================================
   SLIDE-OUT SETTINGS DRAWER & OVERLAY (Square Corners)
   ========================================================================= */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-smooth);
}

.drawer-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.settings-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 440px;
  height: 100vh;
  background: var(--bg-panel-solid);
  border-left: 1px solid var(--border-light);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.8);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.settings-drawer.active {
  transform: translateX(0);
}

.drawer-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.drawer-title-group h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 4px;
  letter-spacing: 0.25px;
}

.drawer-title-group p {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.drawer-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 0; /* Square close button */
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.drawer-close-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.drawer-close-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-bright);
}

.drawer-body {
  flex-grow: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.drawer-body::-webkit-scrollbar {
  width: 6px;
}

.drawer-body::-webkit-scrollbar-track {
  background: transparent;
}

.drawer-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 0; /* Square scrollbar */
}

.drawer-body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   DRAGGABLE SORT LIST STYLES (Square Corners)
   ========================================================================== */
.url-list-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.url-item {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-light);
  border-radius: 0; /* Square Corners */
  padding: 8px 12px;
  gap: 10px;
  user-select: none;
  transition: var(--transition-smooth);
}

.url-item.grid-active {
  border-left: 3px solid var(--accent-neon);
  background: rgba(168, 85, 247, 0.03);
}

.url-item.grid-queued {
  border-left: 3px solid var(--accent-blue);
  background: rgba(59, 130, 246, 0.03);
}

/* Dragging visual states */
.url-item.dragging {
  opacity: 0.35;
  transform: scale(0.97);
  border: 2px dashed var(--accent-neon);
  background: rgba(168, 85, 247, 0.05);
}

.url-item.drag-over {
  border-top: 2px solid var(--accent-neon);
  box-shadow: 0 -4px 10px rgba(168, 85, 247, 0.15);
}

.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 0; /* Square */
  transition: var(--transition-smooth);
}

.drag-handle:hover {
  color: var(--text-bright);
  background: rgba(255, 255, 255, 0.05);
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.item-index {
  font-weight: 600;
  font-size: 0.8rem;
  width: 22px;
  height: 22px;
  border-radius: 0; /* Square Index Badge */
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  flex-shrink: 0;
}

.url-item.grid-active .item-index {
  background: var(--accent-neon);
  color: var(--text-bright);
  box-shadow: 0 0 6px var(--accent-neon-glow);
}

.url-item.grid-queued .item-index {
  background: var(--accent-blue);
  color: var(--text-bright);
  box-shadow: 0 0 6px var(--accent-blue-glow);
}

.item-input-wrapper {
  flex-grow: 1;
  position: relative;
}

.item-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 0; /* Square corners */
  padding: 8px 12px;
  color: var(--text-bright);
  font-family: var(--font-family);
  font-size: 0.85rem;
  transition: var(--transition-smooth);
}

.item-input:focus {
  border-color: var(--accent-neon);
  background: rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.2);
  outline: none;
}

.item-input::placeholder {
  color: rgba(255, 255, 255, 0.2);
}

.btn-clear {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 0; /* Square clear button */
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.btn-clear svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.btn-clear:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--accent-danger);
}

/* ==========================================================================
   DRAWER FOOTER & SAVING STATES (Square Corners)
   ========================================================================== */
.drawer-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border-light);
  background: rgba(10, 10, 14, 0.4);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auto-save-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.save-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(168, 85, 247, 0.2);
  border-top-color: var(--accent-neon);
  border-radius: 50%; /* Keep loader circular to rotate properly */
  animation: spin 1s linear infinite;
  display: none;
}

.save-spinner.saving {
  display: block;
}

.save-spinner.saved-checkmark {
  border-color: var(--accent-green);
  background: var(--accent-green);
  border-radius: 0; /* Change success check box to square! */
  animation: none;
  display: block;
  position: relative;
}

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

.footer-shortcuts {
  display: flex;
  gap: 10px;
}

.footer-btn {
  flex-grow: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 0; /* Square button */
  padding: 10px;
  font-family: var(--font-family);
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.footer-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-bright);
}

.footer-btn.btn-danger {
  color: rgba(239, 68, 68, 0.85);
}

.footer-btn.btn-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--accent-danger);
  border-color: rgba(239, 68, 68, 0.2);
}

/* ==========================================================================
   RESPONSIVE DESIGN & MEDIA QUERIES
   ========================================================================== */

/* Always show cell headers on touch screens for accessibility */
@media (max-width: 1024px) {
  .video-cell-header {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    background: rgba(10, 10, 14, 0.8);
  }
}

/* Medium Screens (Laptops & Landscape Tablets) */
@media (max-width: 1200px) {
  .video-grid {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(5, auto);
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
    padding-bottom: 80px;
  }

  .video-cell {
    aspect-ratio: 16 / 9;
  }

  #cell-0 { grid-column: 1 / 4; grid-row: 4 / 6; }
  #cell-1 { grid-column: 1; grid-row: 1; }
  #cell-2 { grid-column: 2; grid-row: 1; }
  #cell-3 { grid-column: 3; grid-row: 1; }
  #cell-4 { grid-column: 1; grid-row: 2; }
  #cell-5 { grid-column: 2; grid-row: 2; }
  #cell-6 { grid-column: 3; grid-row: 2; }
  #cell-7 { grid-column: 1; grid-row: 3; }
  #cell-8 { grid-column: 2; grid-row: 3; }
  #cell-9 { grid-column: 3; grid-row: 3; }
}

/* Small Screens (Portrait Tablets & Large Phones) */
@media (max-width: 768px) {
  .video-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: auto;
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
    gap: 8px;
    padding: 8px;
    padding-bottom: 80px;
  }

  .video-cell {
    aspect-ratio: 16 / 9;
  }

  #cell-0 { grid-column: 1 / 3; grid-row: 1 / 3; }
  #cell-1 { grid-column: 1; grid-row: 3; }
  #cell-2 { grid-column: 2; grid-row: 3; }
  #cell-3 { grid-column: 1; grid-row: 4; }
  #cell-4 { grid-column: 2; grid-row: 4; }
  #cell-5 { grid-column: 1; grid-row: 5; }
  #cell-6 { grid-column: 2; grid-row: 5; }
  #cell-7 { grid-column: 1; grid-row: 6; }
  #cell-8 { grid-column: 2; grid-row: 6; }
  #cell-9 { grid-column: 1 / 3; grid-row: 7; }

  /* Collapse master control bar to save screen space */
  .master-control-bar {
    padding: 0 12px;
    height: 48px;
  }

  .brand-name, 
  .active-indicator,
  .bar-divider {
    display: none !important;
  }

  .bar-controls {
    width: 100%;
    justify-content: space-around;
    gap: 4px;
  }

  .bar-btn {
    height: 36px;
    padding: 0;
    width: 40px;
    justify-content: center;
  }

  .bar-btn span {
    display: none !important;
  }

  .bar-btn svg {
    width: 18px;
    height: 18px;
  }
}

/* Ultra Small Screens (Phones) */
@media (max-width: 480px) {
  .video-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    padding: 6px;
    gap: 6px;
    padding-bottom: 80px;
  }

  .video-cell {
    aspect-ratio: 16 / 9;
  }

  #cell-0, #cell-1, #cell-2, #cell-3, #cell-4, #cell-5, #cell-6, #cell-7, #cell-8, #cell-9 {
    grid-column: 1 !important;
    grid-row: auto !important;
  }

  /* Make settings drawer full width for tiny screens */
  .settings-drawer {
    width: 100%;
  }
}
