/* ClipVault — Mobile Layer
 *
 * Wird via <link rel="stylesheet" href="styles/mobile.css"
 * media="(max-width: 720px)"> geladen. Damit ist sicher Trennung
 * zwischen Desktop und Mobile gewährleistet:
 * - Browser lädt Datei zwar in jedem Fall, wendet die Regeln aber NUR
 *   bei Viewport ≤720px an.
 * - Keine Mischung mit Desktop-Styles → klare Verantwortung.
 *
 * Ergänzung zu vendor/responsive.css (Basics) und
 * styles/common.css (a11y/Tokens, viewport-unabhängig).
 *
 * Behobene Mobile-Probleme aus dem Audit:
 *  P1 Tabellen: Sticky Header + Compact-Layout
 *  P1 Now-Playing-Bar: safe-area-inset
 *  P2 Breite Cards: width: 100%
 *  P2 Sidebar: Drawer-Pattern
 *  P3 Button-Reihen: column-stack
 *  P3 User-Dropdown: oben statt unten öffnen
 *  P3 Period-Picker: full-width
 *  P3 Radio-Group: full-width
 *  P4 Stats-Grid: 1 Spalte
 *  P4 Format-/Musik-Cards: column-stack
 */

/* ── Generic Cards: füll Viewport-Breite ────────────────────────────────── */
.card {
  width: 100% !important;
  max-width: 100% !important;
  padding: 32px 24px !important;
  border-radius: 12px !important;
}

/* Hintergrund-Glow auf Mobile abschalten (Performance/Visual Noise) */
body::before,
body::after { display: none !important; }

/* ── User-Menu-Dropdown: oben öffnen, scrollbar ─────────────────────────── */
.user-menu-dropdown {
  position: absolute !important;
  right: 0 !important;
  top: auto !important;
  bottom: calc(100% + 6px) !important;
  max-height: 60vh;
  overflow-y: auto;
  min-width: 220px !important;
}

/* ── Tabellen: Sticky Header beim horizontalen Scroll ───────────────────── */
table thead {
  position: sticky;
  top: 0;
  background: var(--surface, #16161a);
  z-index: 5;
}
table thead th {
  background: var(--surface, #16161a);
}

/* ── Listen-Tabellen → Card-Layout (kein horizontaler Scroll) ───────────── */
/* Überschreibt vendor/responsive.css `display: block; overflow-x: auto` */
.page table {
  display: block !important;
  overflow-x: visible !important;
  border-collapse: separate;
}
.page table thead {
  display: none !important;
}
.page table tbody {
  display: block;
}
.page table tr {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--border, #2a2a30);
  border-radius: 10px;
  background: var(--surface, #16161a);
}
.page table td {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  border-bottom: none !important;
  padding: 2px 0 !important;
  white-space: normal !important;
  font-size: 12px;
  color: var(--muted, #8a8a95);
  gap: 8px;
}
.page table td:first-child {
  font-weight: 600;
  font-size: 14px;
  flex-direction: column;
  align-items: flex-start;
  padding-bottom: 8px !important;
  border-bottom: 1px solid var(--border, #2a2a30) !important;
  margin-bottom: 4px;
}
.page table tr:hover td {
  background: transparent !important;
}
/* Actions: volle Breite, gleichmäßig verteilt */
.page table td .actions-cell,
.page table td:last-child > div {
  width: 100%;
  justify-content: flex-start !important;
  flex-wrap: wrap;
  gap: 8px;
}
.page table td .actions-cell .btn,
.page table td:last-child .btn {
  flex: 1 1 auto;
  justify-content: center;
  min-height: 40px;
}
/* Play-Button bleibt rund + kompakt */
.page table td .actions-cell .play-btn {
  flex: 0 0 auto;
}

/* ── Button-Reihen: column-stack ────────────────────────────────────────── */
.btn-row,
.action-row,
.actions,
.modal-actions,
.accept-row,
.result-actions {
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 8px !important;
}
.btn-row .btn,
.action-row .btn,
.actions .btn,
.modal-actions .btn,
.accept-row .btn,
.result-actions .btn {
  width: 100%;
  justify-content: center;
}

/* ── Period-Picker: volle Breite ────────────────────────────────────────── */
.period-picker {
  display: flex !important;
  width: 100% !important;
  min-width: 100% !important;
  justify-content: space-between !important;
}

/* ── Radio-Groups: ein Item pro Zeile ───────────────────────────────────── */
.radio-row {
  flex-direction: column !important;
  gap: 10px !important;
}
.radio-row label {
  min-width: 100% !important;
}

/* ── Stats-Grid: 1 Spalte ───────────────────────────────────────────────── */
.stats-grid {
  grid-template-columns: 1fr !important;
}

/* ── Format-/Musik-Cards: column statt row ──────────────────────────────── */
.musik-card,
.format-card {
  flex-direction: column !important;
  gap: 12px !important;
  padding: 16px !important;
}

/* ── Pages: kompaktere Pads ─────────────────────────────────────────────── */
.page {
  padding: 20px 14px 80px !important;
}
.page-title {
  font-size: 22px !important;
}

/* ── Now-Playing-Bar (musik.html): safe-area-inset ──────────────────────── */
.now-playing,
.now-playing-bar,
.player-bar,
[class*="now-playing"] {
  padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
}
/* Body-Padding, damit Content nicht hinter Bar verschwindet */
body:has(.now-playing-bar.visible),
body:has(.now-playing.visible),
body:has(.player-bar) {
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
}

/* ── Sidebar (app.html): Drawer-Pattern ─────────────────────────────────── */
.sidebar {
  position: fixed !important;
  top: 56px;
  left: 0;
  bottom: 0;
  width: 84vw !important;
  max-width: 320px;
  z-index: 200;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  background: var(--surface, #16161a);
  border-right: 1px solid var(--border, #2a2a30);
  overflow-y: auto;
}
.sidebar.mobile-open {
  transform: translateX(0);
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 56px 0 0 0;
  background: rgba(0,0,0,0.6);
  z-index: 199;
}
.sidebar-backdrop.show {
  display: block;
}

/* ── Drop-Zone (upload.html): kompakter ─────────────────────────────────── */
.drop-zone,
.dropzone,
.ac-dropzone {
  padding: 32px 16px !important;
}

/* ── Modals: full-screen sheet auf sehr schmalen Geräten ────────────────── */
@media (max-width: 480px) {
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 100vh;
    border-radius: 0 !important;
    padding: 20px 16px !important;
  }
  .modal-overlay,
  .modal-backdrop {
    padding: 0 !important;
  }
}

/* ── Filter-Tabs: aktiver Zustand deutlicher (wegen Mobile-Sichtbarkeit) ── */
.es-filter-tab.active,
.tab.active {
  background: var(--accent-dim, rgba(232,244,74,0.12)) !important;
}

/* ── Form-Inputs: explicit volle Breite + Stack ─────────────────────────── */
.billing-name-row,
.billing-zip-row,
.upload-fields-row,
.form-row,
.form-grid {
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
}

/* ── Musik-Tabelle: kompakte Einzeiler ──────────────────────────────────── */
/* Überschreibt das generische Card-Layout. Auf Mobile zeigt jede Track-Zeile
   nur Dateiname + Download-Button. Größe/Datum/Play/Löschen sind versteckt. */
#track-container table tr {
  display: flex !important;
  flex-direction: row !important;
  grid-template-columns: none !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 10px 12px !important;
  margin-bottom: 6px !important;
}
#track-container table td {
  display: none !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
}
#track-container table td:first-child {
  display: flex !important;
  flex: 1 1 auto !important;
  min-width: 0 !important;
  flex-direction: column !important;
  align-items: flex-start !important;
}
#track-container table td:last-child {
  display: flex !important;
  flex: 0 0 auto !important;
}
/* Nur Dateiname zeigen, Track-Titel verstecken */
#track-container table .track-title {
  display: none !important;
}
#track-container table .track-filename {
  font-size: 13px !important;
  color: var(--text, #f0efe8) !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  margin-top: 0 !important;
}
/* Actions: Play + Download als Icon sichtbar */
#track-container table .actions-cell {
  width: auto !important;
  flex-wrap: nowrap !important;
  justify-content: flex-end !important;
  gap: 6px !important;
}
#track-container table .actions-cell button[onclick*="deleteTrack"] {
  display: none !important;
}
#track-container table .actions-cell .play-btn {
  display: flex !important;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  min-height: 36px !important;
  flex: 0 0 auto !important;
}
/* Download-Button als Icon-only: Text verstecken, ⬇-Glyph einsetzen */
#track-container table .actions-cell .btn:not(.play-btn) {
  flex: 0 0 auto !important;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  min-height: 36px !important;
  padding: 0 !important;
  font-size: 0 !important;
  border-radius: 50% !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}
#track-container table .actions-cell .btn:not(.play-btn)::before {
  content: '↓';
  font-size: 16px;
  line-height: 1;
  font-family: 'DM Mono', monospace;
}
#track-container table .actions-cell .btn.dl-btn-downloaded::before {
  content: '✓';
  color: var(--success, #4af49e);
}

/* ── Scroll-Performance ─────────────────────────────────────────────────── */
.main-nav,
table,
.tabs {
  -webkit-overflow-scrolling: touch;
}
