/* ═══════════════════════════════════════════
   Dub Cheap — Client Interface
   Design système : minimaliste, moderne, épuré
   ═══════════════════════════════════════════ */

/* ── Variables ─────────────────────────────── */
:root {
  --bg:           #f9f9f9;
  --surface:      #ffffff;
  --border:       #e5e7eb;
  --border-light: #f0f0f0;

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

  --primary:      #111827;
  --primary-hover:#374151;

  --success:      #16a34a;
  --success-bg:   #f0fdf4;
  --error:        #dc2626;
  --error-bg:     #fef2f2;
  --warning:      #d97706;
  --warning-bg:   #fffbeb;
  --info:         #2563eb;
  --info-bg:      #eff6ff;

  --radius:       10px;
  --radius-sm:    6px;
  --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg:    0 10px 25px rgba(0,0,0,.10);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ─────────────────────────────────── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}
.logo-icon { font-size: 1.4rem; }

.navbar-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-link {
  color: var(--text-muted);
  font-size: .9rem;
  font-weight: 500;
  padding: .3rem .5rem;
  border-radius: var(--radius-sm);
  transition: color .15s, background .15s;
}
.nav-link:hover, .nav-link.active {
  color: var(--text);
  background: var(--bg);
  text-decoration: none;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding-left: 1rem;
  border-left: 1px solid var(--border);
}

.user-badge {
  width: 30px; height: 30px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700;
}

.user-name { font-size: .85rem; font-weight: 500; }

.btn-logout {
  font-size: .8rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .2rem .6rem;
}
.btn-logout:hover { color: var(--error); border-color: var(--error); text-decoration: none; }

/* ── Main content ───────────────────────────── */
.main-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.main-content.centered {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  max-width: 100%;
  padding: 2rem;
}

/* ── Flash messages ─────────────────────────── */
.flash-container { margin-bottom: 1.5rem; }
.flash {
  padding: .8rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  margin-bottom: .5rem;
}
.flash-success { background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0; }
.flash-error   { background: var(--error-bg);   color: var(--error);   border: 1px solid #fecaca; }
.flash-info    { background: var(--info-bg);     color: var(--info);    border: 1px solid #bfdbfe; }

/* ── Auth card ──────────────────────────────── */
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.auth-header { text-align: center; margin-bottom: 2rem; }
.auth-logo   { font-size: 2.5rem; margin-bottom: .5rem; }
.auth-title  { font-size: 1.6rem; font-weight: 700; }
.auth-title strong { color: var(--primary); }
.auth-subtitle { color: var(--text-muted); font-size: .9rem; margin-top: .25rem; }

.auth-form   { display: flex; flex-direction: column; gap: 1rem; }
.auth-footer { text-align: center; margin-top: 1.5rem; font-size: .9rem; color: var(--text-muted); }

/* ── Buttons ────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }

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

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover { background: var(--bg); }

.btn-full  { width: 100%; }
.btn-lg    { padding: .75rem 2rem; font-size: 1rem; }
.btn-sm    { padding: .35rem .75rem; font-size: .82rem; }

/* ── Forms ──────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group label { font-size: .85rem; font-weight: 600; color: var(--text); }
.form-hint  { font-size: .78rem; color: var(--text-muted); }
.required   { color: var(--error); }

input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: .6rem .9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(17,24,39,.08);
}

/* ── Cards ──────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.mt-4 { margin-top: 1.5rem; }

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h3 { font-size: 1rem; font-weight: 700; }

.card-body { padding: 1.25rem; }
.card-body.p-0 { padding: 0; }

/* ── Page header ─────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-header h2 { font-size: 1.4rem; font-weight: 700; }
.text-muted { color: var(--text-muted); font-size: .9rem; }
.back-link {
  font-size: .85rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: .25rem;
}

/* ── Dashboard jobs grid ─────────────────────── */
.jobs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.job-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: .75rem;
  transition: box-shadow .15s;
}
.job-card:hover { box-shadow: var(--shadow-lg); }

.job-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .5rem;
}
.job-title { font-weight: 600; font-size: .95rem; line-height: 1.3; }
.job-meta  { display: flex; gap: .75rem; flex-wrap: wrap; font-size: .8rem; color: var(--text-muted); }
.job-date  { font-size: .8rem; }

.job-actions {
  display: flex;
  gap: .5rem;
  margin-top: .25rem;
}

/* ── Status badges ───────────────────────────── */
.status-badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-queued     { background: var(--warning-bg); color: var(--warning); }
.status-processing { background: var(--info-bg);    color: var(--info); }
.status-done       { background: var(--success-bg); color: var(--success); }
.status-error      { background: var(--error-bg);   color: var(--error); }

.status-badge-lg {
  display: inline-block;
  padding: .6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

/* ── Empty state ─────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.2rem; color: var(--text); margin-bottom: .5rem; }
.empty-state p  { margin-bottom: 1.5rem; }

/* ── Form layout (new dub) ───────────────────── */
.form-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 768px) {
  .form-layout { grid-template-columns: 1fr; }
}

.form-col { display: flex; flex-direction: column; gap: 1.5rem; }

.form-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: .75rem;
  align-items: end;
}
.form-arrow {
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: var(--text-muted);
  padding-bottom: .6rem;
}

.submit-row {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* ── Provider cards ──────────────────────────── */
.provider-cards { display: flex; flex-direction: column; gap: .75rem; }

.provider-card {
  display: block;
  cursor: pointer;
}
.provider-card input[type="radio"] { display: none; }

.provider-content {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .9rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .15s, background .15s;
}
.provider-card input:checked + .provider-content {
  border-color: var(--primary);
  background: #f8f9fa;
}
.provider-content:hover { border-color: #9ca3af; }

.provider-icon  { font-size: 1.5rem; }
.provider-name  { font-weight: 700; font-size: .9rem; }
.provider-desc  { font-size: .8rem; color: var(--text-muted); }
.provider-badge {
  margin-left: auto;
  background: #fef3c7;
  color: #92400e;
  font-size: .72rem;
  font-weight: 700;
  padding: .2rem .5rem;
  border-radius: 20px;
}

/* ── Radio group ─────────────────────────────── */
.radio-group { display: flex; flex-direction: column; gap: .5rem; }
.radio-label {
  display: flex; align-items: center; gap: .5rem;
  cursor: pointer; font-size: .9rem;
}
.radio-label input[type="radio"] { width: 16px; height: 16px; }
.radio-label small { color: var(--text-muted); font-size: .8rem; }

/* ── Toggle switch ───────────────────────────── */
.toggle-label {
  display: flex;
  align-items: center;
  gap: .75rem;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
}
.toggle-label input { display: none; }
.toggle {
  width: 40px; height: 22px;
  background: var(--border);
  border-radius: 20px;
  position: relative;
  transition: background .2s;
}
.toggle::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: transform .2s;
}
.toggle-label input:checked + .toggle { background: var(--primary); }
.toggle-label input:checked + .toggle::after { transform: translateX(18px); }

/* ── Job detail ──────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 640px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.detail-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .4rem .75rem;
  font-size: .9rem;
}
.detail-list dt { color: var(--text-muted); font-weight: 500; white-space: nowrap; }
.detail-list dd { color: var(--text); }

/* ── Log box ─────────────────────────────────── */
.log-box {
  background: #0f172a;
  color: #94a3b8;
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: .8rem;
  line-height: 1.6;
  padding: 1rem;
  border-radius: var(--radius-sm);
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.live-badge {
  font-size: .75rem;
  color: var(--error);
  font-weight: 700;
  animation: blink 1.2s ease-in-out infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* ── Progress bar ────────────────────────────── */
.progress-bar-wrap {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.progress-bar-animated {
  height: 100%;
  background: var(--primary);
  width: 40%;
  border-radius: 2px;
  animation: progress-slide 1.5s ease-in-out infinite;
}
@keyframes progress-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ── Admin ───────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 640px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-number { font-size: 2rem; font-weight: 800; }
.stat-label  { font-size: .8rem; color: var(--text-muted); margin-top: .2rem; }

.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th {
  text-align: left;
  padding: .75rem 1rem;
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.table td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg); }

.role-badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
.role-admin { background: #fef3c7; color: #92400e; }
.role-user  { background: var(--info-bg); color: var(--info); }

code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: .1rem .3rem;
  font-size: .82rem;
  font-family: monospace;
}

/* ── Utilitaires ─────────────────────────────── */
.mb-4 { margin-bottom: 1.5rem; }

/* ── Status hero ─────────────────────────────── */
.status-hero {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.5rem;
}
.status-hero-icon {
  font-size: 2.5rem;
  width: 64px; height: 64px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-hero-icon.status-queued     { background: var(--warning-bg); }
.status-hero-icon.status-processing { background: var(--info-bg); }
.status-hero-icon.status-done       { background: var(--success-bg); }
.status-hero-icon.status-error      { background: var(--error-bg); }

.status-hero-label {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: .25rem;
}
.status-hero-sub { font-size: .9rem; }

/* ── Étapes de progression ───────────────────── */
.p-steps { padding: 1rem 1.25rem; }

.step-row {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  position: relative;
  padding-bottom: 1.25rem;
}
.step-row:last-child { padding-bottom: 0; }

.step-icon-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.step-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  transition: all .3s;
}

.step-connector {
  width: 2px;
  flex: 1;
  min-height: 24px;
  background: var(--border);
  margin: 4px 0;
}

/* États des étapes */
.step-done .step-icon {
  background: var(--success-bg);
  border-color: var(--success);
  color: var(--success);
}
.step-done .step-connector { background: var(--success); }

.step-active .step-icon {
  background: var(--info-bg);
  border-color: var(--info);
  color: var(--info);
  box-shadow: 0 0 0 4px rgba(37,99,235,.12);
}

.step-pending .step-icon {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text-muted);
  font-size: .85rem;
}

.step-content { flex: 1; padding-top: .5rem; }
.step-label   { font-weight: 600; font-size: .92rem; }
.step-desc    { font-size: .82rem; margin-top: .1rem; }

/* Spinner pour l'étape active */
.step-spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--info);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin-top: .6rem;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Bannière de téléchargement ──────────────── */
.download-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  background: var(--success-bg);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  flex-wrap: wrap;
}
.download-banner-text {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.download-banner-icon { font-size: 2rem; }

/* ── Séparateur OU (upload local / YouTube) ─── */
.form-separator {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: .75rem 0;
  color: var(--text-muted);
  font-size: .85rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.form-separator::before,
.form-separator::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Input file ──────────────────────────────── */
input[type="file"] {
  display: block;
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: .9rem;
  cursor: pointer;
}
input[type="file"]:hover {
  border-color: var(--primary);
}
