/* ============================================
   PLAYLISTY — Layout Styles
   ============================================ */

/* ── App Shell ── */
#app {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar (Bottom Island) ── */
.nav-wrap {
  position: fixed;
  bottom: var(--space-8);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-sticky);

  border: 1px solid var(--nav-border);
  width: fit-content;
  margin: 0 auto;
  border-radius: 500px;
  background: var(--nav-bg);
  box-shadow: var(--nav-shadow);
  transition: all var(--duration-slow) var(--ease-default);
}

.nav-wrap:after {
  content: "";
  display: block;
  position: absolute;
  inset: -5px;
  background: var(--nav-after-bg);
  border-radius: 500px;
  z-index: -1;
}

.nav {
  width: fit-content;
  anchor-name: --nav;
  margin: 6.7px;
  display: flex;
  flex-direction: row;
  align-items: center;
}

.nav-item {
  z-index: 10;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 16px 24px;
  border-radius: 500px;
  color: var(--nav-text);
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  transition: all 0.3s ease;
  cursor: pointer;
  user-select: none;
  outline: none;
}

.nav-item:before {
  content: "";
  display: block;
  position: absolute;
  inset: 0;
  opacity: 0.2;
}

.nav-item.active {
  anchor-name: --active;
  color: var(--accent-secondary);
}

.nav-item.active .nav-icon {
  color: var(--text-inverse);
}

.nav-item:hover:before {
  anchor-name: --nav;
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  transition: color var(--duration-fast) var(--ease-default);
}

.bubble {
  background: var(--bg-elevated);
  top: anchor(top);
  right: anchor(right);
  bottom: anchor(bottom);
  left: anchor(left);
  position: absolute;
  transition: all 0.2s;
  border-radius: 500px;
  pointer-events: none;
}

.bubble.active-bubble {
  position-anchor: --active;
  z-index: 2;
  background: var(--accent-primary);
  box-shadow: inset 0 2px 7px rgba(255, 255, 255, 0.4);
}

.bubble.hover-bubble {
  z-index: 1;
  background: var(--nav-hover-bg);
  box-shadow: var(--nav-hover-shadow);
  position-anchor: --nav;
}

/* ── Main Content ── */
.main-content {
  flex: 1;
  margin-left: 0;
  margin-bottom: 80px; /* space for the island */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.floating-controls {
  position: fixed;
  top: var(--space-4);
  right: var(--space-6);
  z-index: var(--z-sticky);
  display: flex;
  gap: var(--space-2);
}

.page-content {
  flex: 1;
  padding: var(--space-6);
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
}

/* ── Page Sections ── */
.section {
  margin-bottom: var(--space-8);
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  gap: var(--space-4);
}
.section-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

/* ── Grid Layouts ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.three-col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}

/* ── Folder Tree (Drive sidebar) ── */
.folder-tree-panel {
  width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-primary);
  padding: var(--space-4);
  overflow-y: auto;
  display: none;
  flex-shrink: 0;
}
.folder-tree-panel.visible {
  display: block;
}

.results-layout {
  display: flex;
  min-height: calc(100vh - var(--header-height));
}
.results-layout .page-content {
  flex: 1;
  min-width: 0;
}

/* ── Mobile Toggle ── */
.mobile-menu-btn {
  display: none;
}

/* ── Responsive: Tablet ── */
@media (max-width: 1024px) {
  .nav-wrap {
    width: auto;
    max-width: calc(100vw - 32px);
  }
  .nav {
    width: 100%;
    justify-content: center;
  }
  .nav-item .nav-text {
    display: none;
  }
  .nav-item {
    padding: 14px 20px;
  }
  .main-content {
    margin-bottom: 100px;
  }
  .mobile-menu-btn {
    display: none;
  }
  .two-col {
    grid-template-columns: 1fr;
  }
  .three-col {
    grid-template-columns: 1fr;
  }
  .folder-tree-panel {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    z-index: var(--z-sticky);
    box-shadow: var(--shadow-xl);
  }
}

/* ── Responsive: Mobile ── */
@media (max-width: 640px) {
  /* ── Page Content: consistent padding on every page ── */
  .page-content {
    padding: var(--space-4) var(--space-4) 0;
  }

  /* ── Stats Grid: 2-column to prevent "zooming" feel ── */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
  }

  .main-header {
    padding: var(--space-3) var(--space-4);
  }

  .card-stat .stat-value {
    font-size: var(--text-lg);
  }

  .card-stat {
    padding: var(--space-4) !important;
  }

  /* ── Nav Island: fixed consistent sizing ── */
  .nav-wrap {
    width: calc(100vw - 32px);
    max-width: 420px;
    bottom: var(--space-4);
  }

  .nav {
    width: 100%;
    justify-content: center !important;
    overflow-x: hidden;
    margin: 5px;
  }

  .nav-item {
    flex: 1;
    padding: 12px 0;
    font-size: 12px;
    white-space: nowrap;
    text-align: center;
    justify-content: center;
  }

  /* Hide the divider in nav on mobile */
  .nav-divider {
    display: none !important;
  }

  /* ── Consistent bottom clearance for island ── */
  .main-content {
    margin-bottom: 90px;
  }

  /* ── Section/Card padding normalization ── */
  .section {
    padding: 0 !important;
  }

  .card {
    padding: var(--space-4) !important;
    border-radius: 16px !important;
  }

  /* ── Section header wrapping ── */
  .section-header {
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  /* ── Results Page Header ── */
  .results-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: var(--space-4) !important;
  }
  .results-header-actions {
    width: 100%;
    display: flex;
    gap: var(--space-2);
  }
  .results-header-actions .btn {
    flex: 1;
  }

  /* ── Input Bar ── */
  .hero-input-container {
    padding: var(--space-1) !important;
  }
  .hero-btn {
    padding: 0 var(--space-4) !important;
    height: 48px !important;
    font-size: var(--text-sm) !important;
  }
  .hero-input {
    height: 48px !important;
    font-size: var(--text-base) !important;
    text-overflow: ellipsis;
  }

  /* ── Source Tabs ── */
  .source-tabs-container {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: var(--space-2) !important;
  }
  .supported-text {
    font-size: 11px;
  }
  #source-tabs {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    width: 100%;
    padding-bottom: 2px;
  }
  #source-tabs::-webkit-scrollbar {
    display: none;
  }
  #source-tabs .tab {
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 12px;
    padding: 4px 8px !important;
  }

  /* ── Video List ── */
  .video-item {
    flex-wrap: wrap;
    gap: var(--space-2) !important;
  }
  .video-item > div {
    min-width: 0;
  }

  /* ── Toast: above the island, centered ── */
  #toast-container {
    bottom: 90px;
    right: var(--space-4);
    left: var(--space-4);
    align-items: center;
  }
  .toast {
    max-width: 100%;
    width: 100%;
  }

  /* ── Floating controls ── */
  .floating-controls {
    right: var(--space-4);
    top: var(--space-3);
  }

  /* ── Modal: full-width on mobile ── */
  #modal-overlay {
    padding: var(--space-3);
    align-items: flex-end;
  }
  .modal {
    max-width: 100% !important;
    border-radius: 20px 20px 12px 12px !important;
    max-height: 85vh;
  }
}

/* ── Responsive: Small phones ── */
@media (max-width: 380px) {
  .nav-item {
    padding: 10px 0;
    font-size: 11px;
  }

  .nav {
    margin: 4px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-2);
  }

  .card-stat .stat-value {
    font-size: var(--text-md);
  }

  .page-content {
    padding: var(--space-3) var(--space-3) 0;
  }
}

/* ── Print Styles ── */
@media print {
  .nav-wrap,
  .main-header,
  .btn,
  .tabs,
  #toast-container,
  #modal-overlay {
    display: none !important;
  }
  .main-content {
    margin-left: 0;
  }
  .page-content {
    padding: 0;
    max-width: 100%;
  }
  body {
    background: white;
    color: black;
  }
  .card, .card-stat {
    border: 1px solid #ddd;
    break-inside: avoid;
  }
  .table th, .table td {
    border: 1px solid #ddd;
  }
}
