/* Solan Orchestrator — dashboard styles (Astren-aligned) */

* { box-sizing: border-box; }

:root {
  --bg: #0F172A;
  --surface-1: rgba(31, 41, 55, 0.55);
  --surface-2: rgba(31, 41, 55, 0.85);
  --surface-3: rgba(55, 65, 81, 0.6);
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.1);
  --border-accent: rgba(168, 85, 247, 0.4);
  --text: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  --primary: #a855f7;
  --pink: #ec4899;
  --gradient: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
  --gradient-soft: linear-gradient(135deg, rgba(168, 85, 247, 0.18) 0%, rgba(236, 72, 153, 0.18) 100%);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #6366f1;
  --radius: 14px;
  --radius-sm: 8px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --font-head: 'Plus Jakarta Sans', 'Inter', sans-serif;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: radial-gradient(ellipse 800px 600px at top, #1f2937 0%, #111827 35%, #0F172A 100%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.4;
}

h1, h2, h3 { font-family: var(--font-head); margin: 0; }
code { font-family: ui-monospace, "JetBrains Mono", "Cascadia Code", Consolas, monospace; }

.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: 0.85em; }
.error-msg { color: var(--danger); margin-top: 0.5rem; }

/* ============================== auth overlay */
.auth-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(3, 7, 18, 0.85);
  backdrop-filter: blur(8px);
}
.auth-card {
  background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
  width: min(420px, 90vw);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.auth-card h1 { font-size: 1.4rem; margin-bottom: 0.5rem; background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-card p { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 1.2rem; }
.auth-card code { background: rgba(0,0,0,0.3); padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.82em; }
#auth-form { display: flex; flex-direction: column; gap: 0.65rem; }
#auth-form input { padding: 0.65rem 0.9rem; background: rgba(0,0,0,0.25); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: 0.9rem; }
#auth-form input:focus { outline: none; border-color: var(--border-accent); }
#auth-form button { padding: 0.7rem 1rem; background: var(--gradient); color: white; border: none; border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; }
#auth-form button:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(168, 85, 247, 0.4); }

/* ============================== app shell */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 1rem 1.5rem 2rem;
}

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.5rem 0 1rem;
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.logo { display: flex; align-items: center; gap: 0.4rem; font-family: var(--font-head); font-size: 1.05rem; }
.logo strong { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gradient); box-shadow: 0 0 8px var(--primary); }
.version { color: var(--text-dim); font-size: 0.78rem; padding: 0.15rem 0.5rem; border: 1px solid var(--border); border-radius: 999px; }
.topbar-right { display: flex; align-items: center; gap: 0.5rem; }

.pill {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.3rem 0.7rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600;
  background: rgba(0,0,0,0.25); border: 1px solid var(--border);
}
.pill-ok { color: var(--success); border-color: rgba(16, 185, 129, 0.3); }
.pill-warn { color: var(--warning); border-color: rgba(245, 158, 11, 0.3); }
.pill-error { color: var(--danger); border-color: rgba(239, 68, 68, 0.3); }
.pill-info { color: var(--info); border-color: rgba(99, 102, 241, 0.3); }
.pill-muted { color: var(--text-muted); }

.btn {
  padding: 0.5rem 0.9rem; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface-3); color: var(--text); font-size: 0.85rem; cursor: pointer;
  transition: all 0.2s;
}
.btn:hover { border-color: var(--border-accent); background: rgba(168, 85, 247, 0.08); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-primary { background: var(--gradient); border: none; color: white; font-weight: 600; box-shadow: 0 4px 14px rgba(168, 85, 247, 0.25); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(168, 85, 247, 0.4); }
.btn-danger { color: var(--danger); border-color: rgba(239, 68, 68, 0.4); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.08); }

.tabs {
  display: inline-flex; gap: 0.25rem; padding: 0.35rem;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 999px; backdrop-filter: blur(12px); margin-bottom: 1.25rem;
  align-self: flex-start;
}
.tab {
  padding: 0.5rem 1.1rem; border: none; background: transparent;
  color: var(--text-muted); font-size: 0.88rem; font-weight: 600;
  border-radius: 999px; cursor: pointer; transition: all 0.2s;
}
.tab:hover { color: var(--text); background: rgba(168, 85, 247, 0.08); }
.tab.active { color: white; background: var(--gradient); box-shadow: 0 4px 14px rgba(168, 85, 247, 0.35); }

.content { flex: 1; }
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.view-header {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 1rem; margin-bottom: 1.25rem;
}
.view-header h2 { font-size: 1.2rem; }
.view-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.view-actions input, .view-actions select {
  padding: 0.45rem 0.7rem; background: rgba(0,0,0,0.25);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 0.85rem;
}
.view-actions input:focus, .view-actions select:focus { outline: none; border-color: var(--border-accent); }

/* ============================== cards */
.card-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}
.card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem; position: relative; overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
  display: flex; flex-direction: column; gap: 0.75rem;
}
.card:hover { border-color: var(--border-accent); transform: translateY(-2px); }
.card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--gradient); opacity: 0; transition: opacity 0.2s;
}
.card:hover::before { opacity: 1; }
.card-title {
  font-family: var(--font-head); font-size: 1rem; font-weight: 600;
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
}
.card-title .pill { font-size: 0.7rem; padding: 0.2rem 0.55rem; }
.card-meta { color: var(--text-muted); font-size: 0.82rem; display: flex; gap: 1rem; flex-wrap: wrap; }
.card-meta span { display: inline-flex; align-items: center; gap: 0.3rem; }
.card-actions { display: flex; gap: 0.4rem; margin-top: auto; }

.progress {
  height: 4px; background: rgba(255,255,255,0.04); border-radius: 999px; overflow: hidden;
}
.progress-bar { height: 100%; background: var(--gradient); transition: width 0.3s ease; }

.error-detail {
  background: rgba(239, 68, 68, 0.06); border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-sm); padding: 0.55rem 0.75rem;
  color: #fca5a5; font-size: 0.78rem; word-break: break-word; line-height: 1.5;
}

/* ============================== table */
.table-wrap {
  background: var(--surface-1); backdrop-filter: blur(12px);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0; overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; }
thead { background: rgba(0,0,0,0.25); }
th {
  text-align: left; padding: 0.7rem 1rem; color: var(--text-dim);
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 0.7rem 1rem; color: var(--text-muted); font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}
tbody tr:hover { background: rgba(168, 85, 247, 0.05); }
tbody tr:last-child td { border-bottom: none; }
td .file-name { color: var(--text); font-weight: 500; }

/* ============================== detail drawer */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 95vw);
  background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  border-left: 1px solid var(--border-strong);
  box-shadow: -16px 0 48px rgba(0,0,0,0.4);
  z-index: 5000; padding: 1.5rem; overflow-y: auto;
  display: none;
}
.drawer.active { display: block; animation: slideIn 0.25s ease; }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.drawer-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; }

.timeline { position: relative; padding-left: 1.75rem; margin: 1rem 0; }
.timeline::before {
  content: ''; position: absolute; left: 8px; top: 4px; bottom: 4px;
  width: 2px; background: linear-gradient(180deg, var(--border-strong), transparent);
}
.timeline-step {
  position: relative; padding: 0.7rem 1rem; margin-bottom: 0.6rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.timeline-step::before {
  content: ''; position: absolute; left: -1.75rem; top: 0.95rem;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--text-dim); border: 3px solid #0F172A;
  box-shadow: 0 0 0 2px var(--text-dim);
}
.timeline-step.status-success::before { background: var(--success); box-shadow: 0 0 0 2px rgba(16,185,129,0.4); }
.timeline-step.status-running::before { background: var(--info); box-shadow: 0 0 0 2px rgba(99,102,241,0.4); animation: pulse 1.5s infinite; }
.timeline-step.status-error::before { background: var(--danger); box-shadow: 0 0 0 2px rgba(239,68,68,0.4); }
.timeline-step.status-skipped::before { background: var(--warning); box-shadow: 0 0 0 2px rgba(245,158,11,0.4); }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.5; transform: scale(1.4); } }
.step-header { display: flex; justify-content: space-between; align-items: center; }
.step-name { font-weight: 600; }
.step-duration { color: var(--text-dim); font-size: 0.75rem; }
.step-meta { color: var(--text-muted); font-size: 0.78rem; margin-top: 0.4rem; }

.counters-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.5rem; margin-top: 1rem;
}
.counter {
  text-align: center; padding: 0.6rem; background: rgba(168, 85, 247, 0.06);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.counter-value { font-family: var(--font-head); font-size: 1.1rem; font-weight: 700; color: var(--text); }
.counter-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin-top: 0.2rem; }

/* ============================== settings */
.settings-form {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}
.setting {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
}
.setting label { display: block; font-weight: 600; margin-bottom: 0.35rem; }
.setting p { color: var(--text-muted); font-size: 0.8rem; margin: 0 0 0.6rem; }
.setting input[type="text"], .setting input[type="number"] {
  width: 100%; padding: 0.5rem 0.75rem;
  background: rgba(0,0,0,0.25); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 0.9rem;
}
.setting input:focus { outline: none; border-color: var(--border-accent); }
.setting .switch { display: flex; align-items: center; gap: 0.5rem; }

/* ============================== system view */
#system-panel {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}
.system-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem;
}
.system-card h3 { font-size: 0.95rem; margin-bottom: 0.75rem; color: var(--text); }
.kv-list { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.85rem; }
.kv-list .kv { display: flex; justify-content: space-between; gap: 1rem; color: var(--text-muted); }
.kv-list .kv strong { color: var(--text); font-weight: 500; }

/* ============================== toast */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9000;
  background: var(--surface-2); border: 1px solid var(--border-accent);
  border-radius: var(--radius-sm); padding: 0.75rem 1rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  font-size: 0.88rem; max-width: 360px;
}
.toast.error { border-color: rgba(239, 68, 68, 0.4); color: #fca5a5; }
.toast.success { border-color: rgba(16, 185, 129, 0.4); color: #a7f3d0; }

/* ============================== empty / loading */
.empty {
  text-align: center; padding: 3rem 1rem; color: var(--text-muted);
}
.empty h3 { color: var(--text); margin-bottom: 0.4rem; }
.loading {
  display: flex; justify-content: center; padding: 2rem;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .topbar { flex-direction: column; gap: 0.75rem; align-items: flex-start; }
  .drawer { width: 100%; padding: 1rem; }
  .view-actions { width: 100%; }
}
