/* ============================================================
   SoundDrop — Main Stylesheet
   2026-style: CSS custom properties, dark/light, responsive
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;

  --transition-fast: 150ms ease;
  --transition-med:  250ms ease;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,.16);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.24);
}

/* ---------- Dark theme (default) ---------- */
[data-theme="dark"] {
  --bg:          #0e0f11;
  --bg-card:     #16181d;
  --bg-input:    #1c1f26;
  --bg-hover:    #1f2229;
  --border:      rgba(255,255,255,.07);
  --border-focus:rgba(99,179,237,.6);

  --text:        #e8eaf0;
  --text-muted:  #6b7280;
  --text-subtle: #374151;

  --accent:      #4f8ef7;
  --accent-hover:#6fa3fa;
  --accent-glow: rgba(79,142,247,.25);

  --success:     #34d399;
  --success-bg:  rgba(52,211,153,.12);
  --warning:     #fbbf24;
  --error:       #f87171;
  --error-bg:    rgba(248,113,113,.12);

  --progress-bg: #1c1f26;
  --progress-fill: linear-gradient(90deg, #4f8ef7, #818cf8);
  --progress-glow: rgba(79,142,247,.4);
}

/* ---------- Light theme ---------- */
[data-theme="light"] {
  --bg:          #f4f5f7;
  --bg-card:     #ffffff;
  --bg-input:    #f9fafb;
  --bg-hover:    #f3f4f6;
  --border:      rgba(0,0,0,.08);
  --border-focus:rgba(79,142,247,.5);

  --text:        #111827;
  --text-muted:  #6b7280;
  --text-subtle: #d1d5db;

  --accent:      #2563eb;
  --accent-hover:#1d4ed8;
  --accent-glow: rgba(37,99,235,.2);

  --success:     #059669;
  --success-bg:  rgba(5,150,105,.1);
  --warning:     #d97706;
  --error:       #dc2626;
  --error-bg:    rgba(220,38,38,.1);

  --progress-bg: #e5e7eb;
  --progress-fill: linear-gradient(90deg, #2563eb, #7c3aed);
  --progress-glow: rgba(37,99,235,.3);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  transition: background var(--transition-med), color var(--transition-med);
}

img, svg { display: block; }
button { cursor: pointer; font: inherit; border: none; background: none; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

/* ---------- Layout ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header__inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header__icon { font-size: 22px; line-height: 1; }

.header__title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.main {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 80px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.card__title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 18px;
  color: var(--text);
}

/* ---------- Form fields ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field--sm { flex: 1; min-width: 140px; }

.field__label {
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: .02em;
  text-transform: uppercase;
}

.field__row {
  display: flex;
  gap: 10px;
}

.field__input,
.field__select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: .93rem;
  padding: 10px 14px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.field__input:focus,
.field__select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.field__textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: .93rem;
  font-family: var(--font-mono);
  padding: 10px 14px;
  resize: vertical;
  min-height: 70px;
  max-height: 220px;
  line-height: 1.6;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.field__textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.field__textarea::placeholder { color: var(--text-muted); }

.field__row-end {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.field__hint {
  font-size: .75rem;
  color: var(--text-muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
}

.url-counter {
  font-size: .78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.field__input::placeholder { color: var(--text-muted); }

.field__input:invalid:not(:placeholder-shown) {
  border-color: var(--error);
}

.field__select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 34px;
}

.field__error {
  font-size: .8rem;
  color: var(--error);
  min-height: 1.2em;
}

.options-row {
  display: flex;
  gap: 14px;
  margin-top: 14px;
  flex-wrap: wrap;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: .9rem;
  font-weight: 600;
  transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  white-space: nowrap;
  flex-shrink: 0;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.btn--primary:active { transform: scale(.97); }

.btn--primary:disabled {
  opacity: .5;
  pointer-events: none;
}

.btn--success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(52,211,153,.2);
}

.btn--success:hover { filter: brightness(1.1); }

.btn--danger {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid rgba(248,113,113,.2);
}

.btn--danger:hover { filter: brightness(1.2); }

.btn--sm {
  padding: 6px 12px;
  font-size: .82rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* ---------- Status bar ---------- */
.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .8rem;
  color: var(--text-muted);
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  width: fit-content;
}

.status-bar__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
  animation: pulse 2s infinite;
}

.status-bar--error .status-bar__dot {
  background: var(--error);
  box-shadow: 0 0 6px var(--error);
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

/* ---------- Jobs section ---------- */
.jobs-section {}

.jobs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.jobs-header__title {
  font-size: 1rem;
  font-weight: 600;
}

.jobs-header__filters {
  display: flex;
  gap: 6px;
}

.filter-btn {
  padding: 5px 13px;
  border-radius: var(--radius-full);
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: all var(--transition-fast);
}

.filter-btn:hover { border-color: var(--accent); color: var(--accent); }

.filter-btn--active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.jobs-header__controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.jobs-header__sort {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sort-label {
  font-size: .75rem;
  color: var(--text-muted);
}

.sort-btn {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: .75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.sort-btn:hover { border-color: var(--accent); color: var(--accent); }

.sort-btn--active {
  background: var(--accent-muted, rgba(99,102,241,.15));
  color: var(--accent);
  border-color: var(--accent);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 16px;
}

.pagination__info {
  font-size: .82rem;
  color: var(--text-muted);
  min-width: 50px;
  text-align: center;
}

.job-card__duration {
  font-size: .75rem;
  color: var(--text-muted);
  margin-left: 8px;
  white-space: nowrap;
}

/* ---------- Job list ---------- */
.jobs-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.jobs-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: .9rem;
}

.jobs-empty__icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  display: block;
  opacity: .5;
}

/* ---------- Job card ---------- */
.job-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  animation: slideIn var(--transition-med) both;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.job-card:hover {
  border-color: rgba(255,255,255,.12);
  box-shadow: var(--shadow-md);
}

.job-card[data-status="finished"] { border-left: 3px solid var(--success); }
.job-card[data-status="error"]    { border-left: 3px solid var(--error); }
.job-card[data-status="downloading"] { border-left: 3px solid var(--accent); }
.job-card[data-status="pending"]  { border-left: 3px solid var(--text-muted); }

.job-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.job-card__meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.job-card__title {
  font-size: .93rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

.job-card__url {
  font-size: .75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 380px;
}

.job-card__badges {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: center;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.badge--admin {
  background: rgba(251,191,36,.15);
  color: var(--warning);
  font-size: .68rem;
}

.badge--format {
  background: rgba(99,102,241,.15);
  color: #818cf8;
}

.job-card__owner {
  font-size: .72rem;
  color: var(--accent);
  font-style: italic;
}

.badge--status[data-status="pending"]     { background: rgba(107,114,128,.15); color: var(--text-muted); }
.badge--status[data-status="downloading"] { background: var(--accent-glow);    color: var(--accent); }
.badge--status[data-status="finished"]    { background: var(--success-bg);     color: var(--success); }
.badge--status[data-status="error"]       { background: var(--error-bg);       color: var(--error); }

/* ---------- Progress bar ---------- */
.job-card__progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--progress-bg);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  background: var(--progress-fill);
  border-radius: var(--radius-full);
  transition: width 400ms ease;
  box-shadow: 0 0 8px var(--progress-glow);
}

.progress-bar__pct {
  font-size: .75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  width: 38px;
  text-align: right;
}

/* ---------- Job footer ---------- */
.job-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.job-card__time {
  font-size: .74rem;
  color: var(--text-muted);
}

.job-card__actions { display: flex; align-items: center; gap: 10px; }

.job-error-msg {
  font-size: .78rem;
  color: var(--error);
  font-style: italic;
}

/* ---------- Icons ---------- */
.icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ---------- Downloading animation ---------- */
.job-card[data-status="downloading"] .progress-bar__fill {
  background-size: 200% 100%;
  animation: shimmer 1.5s linear infinite;
  background-image: linear-gradient(90deg, #4f8ef7 0%, #818cf8 50%, #4f8ef7 100%);
  background-size: 200% 100%;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- Play button ---------- */
.btn--play {
  background: rgba(79,142,247,.12);
  color: var(--accent);
  border: 1px solid rgba(79,142,247,.2);
}

.btn--play:hover { filter: brightness(1.15); }

.btn--play.is-playing {
  background: var(--accent);
  color: #fff;
}

/* ---------- Persistent player ---------- */
.player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 -4px 24px rgba(0,0,0,.2);
  animation: slideUp var(--transition-med) both;
}

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

.player__inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.player__btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.player__btn:hover {
  transform: scale(1.08);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.player__btn:active { transform: scale(.95); }

.player__info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.player__title {
  font-size: .82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player__seek-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player__time {
  font-size: .7rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  width: 36px;
  flex-shrink: 0;
}

.player__time:last-child { text-align: right; }

.player__seek,
.player__volume {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--progress-bg);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
}

.player__seek { flex: 1; }

.player__seek::-webkit-slider-thumb,
.player__volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-card);
  box-shadow: 0 0 4px rgba(0,0,0,.3);
  cursor: pointer;
}

.player__seek::-moz-range-thumb,
.player__volume::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-card);
  box-shadow: 0 0 4px rgba(0,0,0,.3);
  cursor: pointer;
}

.player__volume-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.player__volume { width: 70px; }

.player__close {
  flex-shrink: 0;
  color: var(--text-muted);
}

.icon--lg { width: 20px; height: 20px; }

/* Add bottom padding to main when player is visible */
body:has(.player:not([hidden])) .main {
  padding-bottom: 120px;
}

/* ---------- Auth pages ---------- */
.auth-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
}

.auth-brand__icon { font-size: 28px; line-height: 1; }

.auth-brand__title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.auth-card__heading {
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  color: var(--text-muted);
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-card__footer {
  text-align: center;
  font-size: .85rem;
  color: var(--text-muted);
}

.auth-link {
  color: var(--accent);
  font-weight: 600;
  transition: color var(--transition-fast);
}

.auth-link:hover { color: var(--accent-hover); }

.btn--full {
  width: 100%;
  justify-content: center;
  padding: 12px 18px;
}

/* ---------- Header actions ---------- */
.header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header__user {
  font-size: .8rem;
  color: var(--text-muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Responsive ---------- */
@media (max-width: 540px) {
  .main { padding: 20px 14px 60px; }
  .card { padding: 18px 16px; }
  .field__row { flex-direction: column; }
  .btn--primary { width: 100%; justify-content: center; }
  .jobs-header { flex-direction: column; align-items: flex-start; }
  .job-card__title { max-width: 200px; }
  .job-card__url   { max-width: 200px; }
  .options-row { flex-direction: column; }
  .header__user { display: none; }
  .auth-card { padding: 20px 16px; }
  .player__volume-wrap { display: none; }
  .player__inner { padding: 8px 14px; gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
