/* ─────────────────────────────────────────────────────────────────────────────
   MBBB Design System — exact tokens from globals.css + tailwind.config.ts
   ───────────────────────────────────────────────────────────────────────────── */

/* ── Light mode (default) ────────────────────────────────────────────────── */
:root {
  --background:            hsl(0 0% 100%);
  --foreground:            hsl(0 0% 0%);
  --card:                  hsl(0 0% 100%);
  --card-foreground:       hsl(0 0% 0%);
  --popover:               hsl(0 0% 100%);
  --popover-foreground:    hsl(0 0% 0%);
  --primary:               hsl(0 0% 0%);
  --primary-foreground:    hsl(0 0% 100%);
  --secondary:             hsl(0 0% 96%);
  --secondary-foreground:  hsl(0 0% 9%);
  --muted:                 hsl(0 0% 96%);
  --muted-foreground:      hsl(0 0% 45%);
  --accent:                hsl(0 0% 96%);
  --accent-foreground:     hsl(0 0% 9%);
  --destructive:           hsl(0 84.2% 60.2%);
  --destructive-foreground:hsl(0 0% 98%);
  --border:                hsl(0 0% 89.8%);
  --input:                 hsl(0 0% 89.8%);
  --ring:                  hsl(0 0% 0%);
  --radius:                0.5rem;

  --header-bg:      hsl(0 0% 100% / 0.95);
  --header-blur-bg: hsl(0 0% 100% / 0.6);
}

/* ── Dark mode ───────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --background:            hsl(0 0% 0%);
    --foreground:            hsl(0 0% 100%);
    --card:                  hsl(0 0% 0%);
    --card-foreground:       hsl(0 0% 100%);
    --popover:               hsl(0 0% 0%);
    --popover-foreground:    hsl(0 0% 100%);
    --primary:               hsl(0 0% 100%);
    --primary-foreground:    hsl(0 0% 0%);
    --secondary:             hsl(0 0% 14.9%);
    --secondary-foreground:  hsl(0 0% 98%);
    --muted:                 hsl(0 0% 14.9%);
    --muted-foreground:      hsl(0 0% 63.9%);
    --accent:                hsl(0 0% 14.9%);
    --accent-foreground:     hsl(0 0% 98%);
    --destructive:           hsl(0 62.8% 50.6%);
    --destructive-foreground:hsl(0 0% 98%);
    --border:                hsl(0 0% 14.9%);
    --input:                 hsl(0 0% 14.9%);
    --ring:                  hsl(0 0% 100%);

    --header-bg:      hsl(0 0% 0% / 0.95);
    --header-blur-bg: hsl(0 0% 0% / 0.6);
  }
}

/* ─── Reset ──────────────────────────────────────────────────────────────── */
html { scroll-behavior: smooth; }

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border-color: var(--border);
}

/* Plus Jakarta Sans — same font as MBBB */
body {
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  background: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}

a, button, [role="button"] {
  -webkit-tap-highlight-color: transparent;
}

/* ─── App shell ──────────────────────────────────────────────────────────── */
.app-shell {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 0 24px;
  box-sizing: border-box;
}

/* Thin MBBB-style scrollbar */
::-webkit-scrollbar       { width: 4px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: var(--border); border-radius: 99px; }

/* ─── Header — frosted glass (MBBB sticky header style) ──────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: slide-in-from-top 0.3s ease-out;
}

@supports (backdrop-filter: blur(1px)) {
  .app-header {
    background: var(--header-blur-bg);
  }
}

.app-header h1 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--foreground);
}

.app-header .header-sub {
  font-size: 11px;
  color: var(--muted-foreground);
  font-weight: 400;
}

/* ─── Content area ────────────────────────────────────────────────────────── */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ─── Panel ───────────────────────────────────────────────────────────────── */
.panel {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: fade-in 0.4s ease-out;
}

.panel:last-child {
  border-bottom: none;
}

.panel-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ─── Label ───────────────────────────────────────────────────────────────── */
label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

/* ─── Input ───────────────────────────────────────────────────────────────── */
input {
  width: 100%;
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px);
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  background: var(--background);
  color: var(--foreground);
  outline: none;
  transition: border-color 0.15s ease-out, box-shadow 0.15s ease-out;
}

input:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 2px hsl(0 0% 50% / 0.12);
}

/* ─── Inline row ──────────────────────────────────────────────────────────── */
.inline {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
}

/* ─── Primary button ──────────────────────────────────────────────────────── */
#extract-btn {
  width: 100%;
  height: 38px;
  border: none;
  background: var(--primary);
  color: var(--primary-foreground);
  border-radius: calc(var(--radius) - 2px);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: -0.01em;
  transition: opacity 0.2s ease-out, transform 0.15s ease-out, box-shadow 0.2s ease-out;
}

#extract-btn:hover:not(:disabled) {
  opacity: 0.88;
  box-shadow: 0 4px 16px hsl(0 0% 0% / 0.15);
}

#extract-btn:active:not(:disabled) {
  transform: scale(0.985);
  opacity: 1;
}

#extract-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ─── Ghost button ────────────────────────────────────────────────────────── */
button.ghost {
  height: 38px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--foreground);
  border-radius: calc(var(--radius) - 2px);
  padding: 0 14px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s ease-out, border-color 0.2s ease-out;
}

button.ghost:hover {
  background: var(--secondary);
}

/* ─── Status bar ──────────────────────────────────────────────────────────── */
.status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--border);
  background: var(--secondary);
  color: var(--muted-foreground);
  transition: background 0.25s ease-out, color 0.25s ease-out, border-color 0.25s ease-out;
  min-height: 36px;
  animation: fade-in 0.3s ease-out;
}

.status::before {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.status.status-info::before {
  content: '●';
  font-size: 8px;
  color: var(--muted-foreground);
}

/* Running — spinner */
.status.status-running {
  color: hsl(213 85% 35%);
  background: hsl(213 100% 96%);
  border-color: hsl(213 85% 82%);
}
@media (prefers-color-scheme: dark) {
  .status.status-running {
    color: hsl(213 85% 75%);
    background: hsl(213 60% 12%);
    border-color: hsl(213 50% 25%);
  }
}
.status.status-running::before {
  content: '';
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: spin 0.7s linear infinite;
}

/* Success */
.status.status-success {
  color: hsl(142 72% 22%);
  background: hsl(142 76% 95%);
  border-color: hsl(142 72% 74%);
}
@media (prefers-color-scheme: dark) {
  .status.status-success {
    color: hsl(142 72% 70%);
    background: hsl(142 50% 8%);
    border-color: hsl(142 50% 20%);
  }
}
.status.status-success::before { content: '✓'; color: inherit; }

/* Error */
.status.status-error {
  color: hsl(0 72% 35%);
  background: hsl(0 100% 97%);
  border-color: hsl(0 72% 82%);
}
@media (prefers-color-scheme: dark) {
  .status.status-error {
    color: hsl(0 72% 70%);
    background: hsl(0 50% 8%);
    border-color: hsl(0 50% 22%);
  }
}
.status.status-error::before { content: '✕'; color: inherit; }

/* Warning */
.status.status-warning {
  color: hsl(38 92% 28%);
  background: hsl(48 100% 95%);
  border-color: hsl(38 92% 76%);
}
@media (prefers-color-scheme: dark) {
  .status.status-warning {
    color: hsl(38 92% 72%);
    background: hsl(38 60% 8%);
    border-color: hsl(38 50% 22%);
  }
}
.status.status-warning::before { content: '⚠'; font-size: 12px; color: inherit; }

/* ─── Results section ─────────────────────────────────────────────────────── */
.results-panel {
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.summary {
  font-size: 11px;
  color: var(--muted-foreground);
  font-weight: 500;
}

/* ─── File card — MBBB movie-card style ──────────────────────────────────── */
.file-card {
  position: relative;
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--card);
  overflow: hidden;
  transition: border-color 0.3s ease-out, box-shadow 0.3s ease-out, transform 0.3s ease-out;
  animation: scale-in 0.3s ease-out;
  cursor: default;
  border: 1px solid var(--border);
}

.file-card:hover {
  border-color: var(--primary);
  box-shadow: 0 8px 32px hsl(0 0% 0% / 0.18), 0 2px 8px hsl(0 0% 0% / 0.1);
  transform: scale(1.008);
}

/* MBBB gradient accent on card bottom */
.file-card::after {
  content: '';
  position: absolute;
  inset: auto 0 0 0;
  height: 3px;
  background: linear-gradient(to right, var(--primary), transparent);
  opacity: 0;
  transition: opacity 0.3s ease-out;
}

.file-card:hover::after { opacity: 1; }

.file-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.4;
  word-break: break-word;
  margin-bottom: 3px;
  color: var(--card-foreground);
}

.file-meta {
  font-size: 11px;
  color: var(--muted-foreground);
  margin-bottom: 10px;
  font-weight: 500;
}

/* ─── Server list ─────────────────────────────────────────────────────────── */
.server-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.server-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
  animation: fade-in 0.35s ease-out;
}

/* Server link — MBBB secondary button style */
.server-link {
  display: block;
  font-size: 11px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: calc(var(--radius) - 2px);
  background: var(--secondary);
  color: var(--secondary-foreground);
  border: 1px solid var(--border);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background 0.2s ease-out, border-color 0.2s ease-out, color 0.2s ease-out;
}

.server-link:hover {
  background: var(--accent);
  border-color: var(--primary);
  color: var(--accent-foreground);
}

/* ─── Copy button ─────────────────────────────────────────────────────────── */
.copy-btn {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--foreground);
  border-radius: calc(var(--radius) - 2px);
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  height: 30px;
  transition: background 0.2s ease-out, border-color 0.2s ease-out, transform 0.15s ease-out;
}

.copy-btn:hover {
  background: var(--secondary);
  border-color: var(--ring);
}

.copy-btn:active { transform: scale(0.96); }

/* ─── Bookmarklet ─────────────────────────────────────────────────────────── */
.bookmarklet {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px dashed var(--border);
  border-radius: calc(var(--radius) - 2px);
  color: var(--muted-foreground);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.bookmarklet:hover {
  border-color: var(--primary);
  color: var(--foreground);
  background: var(--secondary);
}

/* ─── Animations ──────────────────────────────────────────────────────────── */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes scale-in {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes slide-in-from-top {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

/* ─── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .panel, .results-panel { padding: 12px 14px; }
  .app-header { padding: 10px 14px; }

  /* Stack inline rows on mobile */
  .inline { grid-template-columns: 1fr; }
  .inline button { width: 100%; }

  /* Bigger touch targets */
  #extract-btn { height: 44px; font-size: 14px; }
  button.ghost { height: 40px; }
  input { padding: 10px 12px; font-size: 14px; }

  /* Full-width server links */
  .server-list li { grid-template-columns: 1fr; gap: 4px; }
  .copy-btn { width: 100%; height: 36px; }
  .server-link { white-space: normal; word-break: break-all; }

  /* Bookmarklet full width on mobile */
  .bookmarklet { width: 100%; justify-content: center; }
}

/* ─── Aria2 button ─────────────────────────────────────────────────────────── */
.aria-btn {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--foreground);
  border-radius: calc(var(--radius) - 2px);
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  height: 30px;
  transition: background 0.2s ease-out, border-color 0.2s ease-out, transform 0.15s ease-out;
}
.aria-btn:hover { background: var(--secondary); border-color: var(--ring); }
.aria-btn:active { transform: scale(0.96); }
.aria-btn.sent { background: #166534; border-color: #16a34a; color: #bbf7d0; }
.aria-btn.failed { background: #7f1d1d; border-color: #dc2626; color: #fecaca; }
.aria-btn:disabled { opacity: 0.5; cursor: not-allowed; }
