/* ═══════════════════════════════════════════════════════════════════════════
   responsive.css — Mobile & Tablet adaptive layout
   Aesthetic: Dark Industrial — compressed for smaller screens
   Breakpoints: tablet ≤ 1024px  |  mobile ≤ 640px
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────────────
   TABLET  ≤ 1024px — icon-rail sidebar
   ───────────────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root {
    --sidebar-w: 64px;
  }

  /* Sidebar: collapse to icon rail */
  .sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    overflow: visible;
  }

  .sidebar-logo {
    justify-content: center;
    padding: 20px 0;
  }

  .logo-text {
    display: none;
  }

  .sidebar-nav {
    padding: 12px 8px;
  }

  .nav-item {
    justify-content: center;
    padding: 11px;
    gap: 0;
    overflow: visible;
  }

  .nav-item span {
    display: none;
  }

  .nav-item .nav-icon {
    width: 20px;
    height: 20px;
  }

  /* Tooltip on hover */
  .nav-item {
    position: relative;
  }

  .nav-item::after {
    content: attr(data-label);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--surface-3);
    border: 1px solid var(--border-hover);
    color: var(--text);
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-family: var(--font-body);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition);
    z-index: 200;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  }

  .nav-item:hover::after {
    opacity: 1;
  }

  /* Sidebar footer: icon only */
  .sidebar-footer {
    padding: 12px 0;
    align-items: center;
    justify-content: center;
    gap: 6px;
  }

  .sidebar-footer .status-text,
  .sidebar-footer .version-tag {
    display: none;
  }

  /* Page */
  .page-header {
    padding: 20px 24px 16px;
  }
  .page-body {
    padding: 20px 24px 32px;
  }

  /* Grid: tighter */
  .video-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
  }
}

/* ─────────────────────────────────────────────────────────────────────────
   MOBILE  ≤ 640px — full transformation
   ───────────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* Allow page scroll */
  html,
  body {
    overflow: auto;
    height: auto;
  }

  .app-shell {
    flex-direction: column;
    height: auto;
    min-height: 100dvh;
  }

  /* Hide desktop sidebar entirely */
  .sidebar {
    display: none;
  }

  /* Main content scrolls naturally */
  .main-content {
    height: auto;
    overflow: visible;
    padding-bottom: 72px; /* room for bottom nav */
  }

  .page {
    min-height: auto;
  }

  /* ── Page header ────────────────────────────────────────────────────────── */
  .page-header {
    padding: 12px 16px 10px;
    position: sticky;
    top: 0;
    z-index: 50;
  }

  .page-title {
    font-size: 19px;
    gap: 8px;
  }

  .page-title-accent {
    font-size: 11px;
  }
  .page-subtitle {
    font-size: 10px;
  }

  /* ── Page body ──────────────────────────────────────────────────────────── */
  .page-body {
    padding: 12px 14px 24px;
  }

  /* ── Input card ─────────────────────────────────────────────────────────── */
  .input-card {
    padding: 14px;
  }

  .url-row {
    margin-bottom: 12px;
  }

  .input-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .control-group.flex-grow {
    min-width: unset;
  }

  .slider-row {
    gap: 8px;
  }

  /* Scrape / cancel buttons: full width */
  .btn-group {
    width: 100%;
    gap: 8px;
  }

  .btn-group .btn-primary,
  .btn-group .btn-secondary {
    flex: 1;
    justify-content: center;
    padding: 10px 14px;
  }

  /* ── Library controls ───────────────────────────────────────────────────── */
  .library-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 12px;
  }

  .lib-stats {
    font-size: 11px;
  }

  /* Filters: horizontal scroll */
  .lib-filters {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 3px;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* subtle fade hint on right */
    -webkit-mask-image: linear-gradient(to right, black 90%, transparent 100%);
    mask-image: linear-gradient(to right, black 90%, transparent 100%);
  }

  .lib-filters::-webkit-scrollbar {
    display: none;
  }

  .lib-filters .search-input {
    min-width: 140px;
    width: 140px;
    flex-shrink: 0;
  }

  .lib-filters .select-field {
    flex-shrink: 0;
  }
  .lib-filters .btn-outline {
    flex-shrink: 0;
  }

  /* ── Quick select row ───────────────────────────────────────────────────── */
  .lib-quick-select {
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
  }

  /* ── Selection bar: floating above bottom nav ───────────────────────────── */
  #lib-selection-bar.visible {
    position: fixed;
    bottom: 60px;
    left: 0;
    right: 0;
    z-index: 150;
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: 1px solid var(--accent-dim);
    border-bottom: none;
    padding: 10px 16px;
    background: rgba(13, 18, 32, 0.97);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    flex-wrap: wrap;
    gap: 8px;
  }

  #lib-sel-count {
    width: 100%;
    font-size: 11px;
  }

  /* ── Video grid: 2 columns ──────────────────────────────────────────────── */
  .video-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 9px;
  }

  /* ── Video card: compact ────────────────────────────────────────────────── */
  .video-card-body {
    padding: 8px 9px 10px;
  }

  .video-card-title {
    font-size: 11px;
    margin-bottom: 6px;
  }

  .video-card-meta {
    gap: 5px;
  }

  .video-meta-item {
    font-size: 9px;
    gap: 3px;
  }

  .video-card-duration {
    font-size: 9px;
    padding: 1px 5px;
  }

  /* ── Scrape progress ────────────────────────────────────────────────────── */
  .scrape-progress {
    margin-bottom: 10px;
  }

  /* ── Download queue ─────────────────────────────────────────────────────── */
  .queue-item {
    padding: 10px 12px;
  }

  .queue-item-title {
    font-size: 11px;
  }

  .queue-item-status {
    font-size: 9px;
  }

  .queue-item-meta {
    gap: 10px;
    font-size: 9px;
  }

  /* ── Section header (queue) ─────────────────────────────────────────────── */
  .section-header {
    font-size: 9px;
  }

  /* ── Download save path controls ─────────────────────────────────────────── */
  #lib-dl-controls .path-row {
    flex-direction: row;
  }

  /* ── Download filter modal → bottom sheet ────────────────────────────────── */
  #lib-dl-modal {
    align-items: flex-end;
  }

  .lib-modal-card {
    width: 100%;
    max-width: 100%;
    border-radius: 18px 18px 0 0;
    padding: 20px 18px 36px;
    /* Slide up animation */
    animation: slideUp 0.28s cubic-bezier(0.32, 0.72, 0, 1) both;
  }

  @keyframes slideUp {
    from {
      transform: translateY(100%);
      opacity: 0.5;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  .lib-modal-actions {
    gap: 8px;
  }

  .lib-modal-actions .btn-outline,
  .lib-modal-actions .btn-primary {
    flex: 1;
    justify-content: center;
  }

  /* ── Empty state ────────────────────────────────────────────────────────── */
  .empty-state p {
    font-size: 13px;
  }
}

/* ─────────────────────────────────────────────────────────────────────────
   MOBILE BOTTOM NAVIGATION BAR
   ───────────────────────────────────────────────────────────────────────── */
.mobile-nav {
  display: none;
}

@media (max-width: 640px) {
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    z-index: 200;
    background: rgba(13, 18, 32, 0.97);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    align-items: stretch;
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    position: relative;
    padding: 8px 4px 6px;
    transition: color var(--transition);
    -webkit-tap-highlight-color: transparent;
  }

  /* Accent line at top of active item */
  .mobile-nav-item::before {
    content: "";
    position: absolute;
    top: 0;
    left: 24%;
    right: 24%;
    height: 2px;
    background: var(--accent);
    border-radius: 0 0 3px 3px;
    box-shadow: 0 0 8px var(--accent-glow);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .mobile-nav-item.active {
    color: var(--accent);
  }

  .mobile-nav-item.active::before {
    transform: scaleX(1);
  }

  .mobile-nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke-width: 1.8;
    transition: transform 0.18s ease;
  }

  .mobile-nav-item.active svg {
    filter: drop-shadow(0 0 4px var(--accent-glow));
  }
}

/* ─────────────────────────────────────────────────────────────────────────
   VERY SMALL  ≤ 380px — single-column grid fallback
   ───────────────────────────────────────────────────────────────────────── */
@media (max-width: 380px) {
  .video-grid {
    grid-template-columns: 1fr;
  }

  .page-body {
    padding: 10px 12px 20px;
  }
}
