/* ============================================
   PADELBOT – Design System
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── CSS Variables ─────────────────────────── */
:root {
  --bg-primary:      #0b1120;
  --bg-card:         #111827;
  --bg-card-hover:   #1a2540;
  --bg-card-border:  #1e2d45;
  --bg-input:        #0f1a2e;
  --bg-console:      #0d1117;

  --accent:          #22c55e;
  --accent-dim:      #16a34a;
  --accent-glow:     rgba(34, 197, 94, 0.18);
  --accent-glow-lg:  rgba(34, 197, 94, 0.30);

  --blue:            #3b82f6;
  --blue-dim:        #2563eb;
  --orange:          #f59e0b;
  --red:             #ef4444;
  --red-dim:         #dc2626;
  --purple:          #a855f7;

  --text-primary:    #f1f5f9;
  --text-secondary:  #94a3b8;
  --text-muted:      #475569;
  --text-console:    #4ade80;

  --radius-sm:       8px;
  --radius-md:       12px;
  --radius-lg:       16px;
  --radius-xl:       24px;

  --shadow-card:     0 4px 24px rgba(0, 0, 0, 0.45);
  --shadow-glow:     0 0 24px var(--accent-glow);
  --shadow-glow-lg:  0 0 40px var(--accent-glow-lg);

  --transition:      all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.38s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dim); }

/* ── Navbar ───────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 64px;
  background: rgba(11, 17, 32, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--bg-card-border);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-icon { font-size: 1.4rem; }

.navbar-actions { display: flex; align-items: center; gap: 12px; }

/* ── Buttons ──────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #000;
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--accent-dim);
  color: #000;
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--bg-card-border);
}
.btn-secondary:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
}
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}
.btn-ghost:hover { background: var(--bg-card); color: var(--text-primary); border-color: var(--bg-card-border); }

.btn-icon { padding: 9px; }

.btn:disabled, .btn.loading {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

.btn.loading::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0,0,0,0.3);
  border-top-color: #000;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ── Cards ────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: var(--transition);
  overflow: hidden;
}

.card:hover { border-color: rgba(34, 197, 94, 0.2); }

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--bg-card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body { padding: 1.5rem; }

/* ── Badges ───────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-success  { background: rgba(34,197,94,.15);  color: #22c55e; }
.badge-pending  { background: rgba(59,130,246,.15);  color: #60a5fa; }
.badge-running  { background: rgba(245,158,11,.15);  color: #fbbf24; }
.badge-failed   { background: rgba(239,68,68,.15);   color: #f87171; }
.badge-cancelled{ background: rgba(100,116,139,.15); color: #94a3b8; }
.badge-done     { background: rgba(34,197,94,.15);   color: #22c55e; }

.badge-running::before { animation: pulse 1.4s ease infinite; }

/* ── Forms & Inputs ───────────────────────── */
.form-group {
  position: relative;
  margin-bottom: 1.25rem;
}

.form-group .input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
  pointer-events: none;
}

.form-control {
  width: 100%;
  padding: 13px 16px;
  background: var(--bg-input);
  border: 1.5px solid var(--bg-card-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  transition: var(--transition);
  outline: none;
}

.form-control.has-icon { padding-left: 42px; }

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

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

.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* Password toggle */
.input-wrapper { position: relative; }
.input-wrapper .form-control { padding-right: 44px; }
.input-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 1rem;
  transition: var(--transition);
}
.input-toggle:hover { color: var(--text-secondary); }

/* Toggle switch */
.toggle-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1.5px solid var(--bg-card-border);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  cursor: pointer;
  transition: var(--transition);
}
.toggle-group:hover { border-color: var(--accent-glow); }

.toggle-label { font-size: 0.9rem; font-weight: 500; }
.toggle-desc  { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-card-border);
  border-radius: 24px;
  transition: var(--transition);
  cursor: pointer;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: var(--transition);
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: #000;
}

/* ── Time Pills ───────────────────────────── */
.time-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
@media (max-width: 480px) { .time-grid { grid-template-columns: repeat(3, 1fr); } }

.time-pill {
  padding: 10px 4px;
  border: 1.5px solid var(--bg-card-border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}
.time-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}
.time-pill.selected {
  border-color: var(--accent);
  background: var(--accent);
  color: #000;
  font-weight: 700;
}

/* ── Court Cards ──────────────────────────── */
.courts-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-top: 3rem;
}
@media (max-width: 900px)  { .courts-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px)  { .courts-grid { grid-template-columns: 1fr 1fr; gap: 12px; } }

.court-card {
  background: var(--bg-card);
  border: 1.5px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1rem 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease, opacity 0.3s ease;
  user-select: none;
  will-change: transform;
}
.court-card:hover {
  transform: translateY(-8px) scale(1.03);
  box-shadow: var(--shadow-glow-lg);
  border-color: var(--accent);
}
.court-card.selected {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow-lg);
  transform: translateY(-4px);
}
.court-card.dimmed {
  opacity: 0.3;
  transform: scale(0.96);
  pointer-events: none;
}

.court-svg-wrapper {
  width: 100%;
  max-width: 140px;
  margin: 0 auto 1rem;
  display: block;
}

.court-number {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}
.court-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}
.court-timing {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(34,197,94,0.2);
}

/* ── Wizard ───────────────────────────────── */
#wizard-section {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 1rem 4rem;
}

/* Stepper */
.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 2.5rem;
  flex-wrap: nowrap;
  overflow: hidden;
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
}

.step-bubble {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--bg-card-border);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: var(--transition-slow);
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.step-item.active   .step-bubble { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 12px var(--accent-glow); }
.step-item.done     .step-bubble { border-color: var(--accent); background: var(--accent); color: #000; }
.step-item.done     .step-bubble::after { content: '✓'; }

.step-label {
  font-size: 0.62rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60px;
  text-align: center;
}
.step-item.active .step-label { color: var(--accent); }
.step-item.done   .step-label { color: var(--text-secondary); }

.step-connector {
  flex: 1;
  height: 2px;
  background: var(--bg-card-border);
  margin-bottom: 20px;
  transition: var(--transition-slow);
  min-width: 8px;
}
.step-connector.done { background: var(--accent); }

/* Wizard steps */
.wizard-step {
  display: none;
  animation: slideUp 0.35s ease-out;
}
.wizard-step.active { display: block; }

.wizard-step-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.4rem;
}
.wizard-step-sub {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1.75rem;
}

.wizard-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.75rem;
  gap: 12px;
}
.wizard-nav .btn { flex: 1; justify-content: center; padding: 13px; }

/* Selected summary chips */
.summary-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--accent-glow);
  border: 1px solid rgba(34,197,94,0.25);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 1rem;
}

/* Confirmation card */
.confirm-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.confirm-card-header {
  background: linear-gradient(135deg, rgba(34,197,94,0.12), rgba(34,197,94,0.04));
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--bg-card-border);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.confirm-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 1.5rem;
  border-bottom: 1px solid var(--bg-card-border);
  font-size: 0.9rem;
}
.confirm-row:last-child { border-bottom: none; }
.confirm-key { color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.confirm-val { font-weight: 600; }

/* ── Dashboard ────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2rem 2rem 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.jobs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
  padding: 0 2rem 3rem;
}
@media (max-width: 640px) { .jobs-grid { grid-template-columns: 1fr; padding: 0 1rem 2rem; } }

.job-card {
  background: var(--bg-card);
  border: 1.5px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: var(--transition);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.job-card:hover {
  border-color: rgba(34,197,94,0.2);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.job-card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--bg-card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.job-card-id {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.job-card-body {
  padding: 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.job-info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
}
.job-info-icon { font-size: 1rem; width: 20px; text-align: center; }
.job-info-label { color: var(--text-muted); font-size: 0.75rem; min-width: 60px; }
.job-info-value { font-weight: 500; }

.job-card-footer {
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--bg-card-border);
  display: flex;
  justify-content: flex-end;
}

.job-card.flash {
  animation: cardFlash 0.4s ease;
}

/* ── Job Detail ───────────────────────────── */
.detail-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.5rem;
  padding: 1.5rem 2rem 3rem;
  align-items: start;
}
@media (max-width: 900px) {
  .detail-layout { grid-template-columns: 1fr; padding: 1rem 1rem 2rem; }
}

.detail-header {
  padding: 1.5rem 2rem 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.detail-back {
  color: var(--text-muted);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: var(--transition);
}
.detail-back:hover { color: var(--text-primary); }

.detail-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.detail-badges { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.info-card { margin-bottom: 1.25rem; }

.info-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg-card-border);
  font-size: 0.875rem;
}
.info-row:last-child { border-bottom: none; }
.info-icon { font-size: 1rem; width: 22px; text-align: center; color: var(--text-muted); flex-shrink: 0; margin-top: 1px; }
.info-label { color: var(--text-muted); font-size: 0.75rem; margin-bottom: 2px; }
.info-value { font-weight: 500; }

.action-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 1.5rem;
}

/* Console */
.console-panel {
  background: var(--bg-card);
  border: 1.5px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.console-header {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--bg-card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.console-dots { display: flex; gap: 6px; }
.console-dots span {
  width: 12px; height: 12px; border-radius: 50%;
}
.console-dots span:nth-child(1) { background: #ff5f57; }
.console-dots span:nth-child(2) { background: #febc2e; }
.console-dots span:nth-child(3) { background: #28c840; }

.console-title {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  flex: 1;
  text-align: center;
}

.console-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  color: var(--text-muted);
}
.pulse-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.4s ease infinite;
}

.console-body {
  background: var(--bg-console);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  line-height: 1.7;
  color: var(--text-console);
  padding: 1rem 1.25rem;
  min-height: 320px;
  max-height: 420px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.console-body::-webkit-scrollbar { width: 4px; }
.console-body::-webkit-scrollbar-track { background: transparent; }
.console-body::-webkit-scrollbar-thumb { background: var(--bg-card-border); border-radius: 4px; }

.console-empty {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 3rem 0;
}

.result-panel {
  margin-top: 1.25rem;
  background: var(--bg-card);
  border: 1.5px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.result-panel-header {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--bg-card-border);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}
.result-body {
  padding: 1rem 1.25rem;
  font-size: 0.875rem;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Landing ──────────────────────────────── */
.landing-section {
  text-align: center;
  padding: 4rem 2rem 2rem;
}

.landing-title {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.15;
  margin-bottom: 0.75rem;
}

.landing-title span {
  background: linear-gradient(135deg, var(--accent), #86efac);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.landing-sub {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 400px;
  margin: 0 auto;
}

/* ── Empty State ──────────────────────────── */
.empty-state {
  grid-column: 1/-1;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text-secondary); }

/* ── Refresh indicator ────────────────────── */
.refresh-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ── Animations ───────────────────────────── */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

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

@keyframes cardFlash {
  0%   { background: var(--bg-card); }
  40%  { background: rgba(34,197,94,0.07); }
  100% { background: var(--bg-card); }
}

/* ── Utilities ────────────────────────────── */
.text-muted    { color: var(--text-muted); }
.text-accent   { color: var(--accent); }
.text-sm       { font-size: 0.875rem; }
.text-xs       { font-size: 0.75rem; }
.font-mono     { font-family: 'JetBrains Mono', monospace; }
.mt-1          { margin-top: 0.5rem; }
.mt-2          { margin-top: 1rem; }
.mt-3          { margin-top: 1.5rem; }
.mb-1          { margin-bottom: 0.5rem; }
.mb-2          { margin-bottom: 1rem; }
.flex-center   { display: flex; align-items: center; gap: 8px; }
.flex-between  { display: flex; align-items: center; justify-content: space-between; }
.w-full        { width: 100%; }
.hidden        { display: none !important; }
