/* V.A — Video Agent panel */
:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-hover: #1c2330;
  --border: #2d333b;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #4493f8;
  --green: #3fb950;
  --red: #f85149;
  --amber: #d29922;
  --teal: #39c5cf;
  --radius: 12px;
  font-size: 15px;
}

/* الوضع الفاتح — الافتراضي، مريح للعين نهاراً */
:root[data-theme="light"] {
  --bg: #f4f6f9;
  --bg-card: #ffffff;
  --bg-hover: #eef1f5;
  --border: #d8dee6;
  --text: #1f2328;
  --muted: #59636e;
  --accent: #0969da;
  --green: #1a7f37;
  --red: #cf222e;
  --amber: #9a6700;
  --teal: #1b7c83;
}
:root[data-theme="light"] .card {
  box-shadow: 0 1px 3px rgba(31, 35, 40, .06);
}
:root[data-theme="light"] .btn-primary,
:root[data-theme="light"] .btn-danger { color: #ffffff; }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

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

/* ─── topbar ─── */
.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 20px; height: 56px;
}
.brand { color: var(--text); font-size: 1.05rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand b { color: var(--accent); }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a {
  color: var(--muted); padding: 6px 12px; border-radius: 8px;
}
.topbar nav a:hover { color: var(--text); background: var(--bg-hover); text-decoration: none; }
.topbar nav a.active { color: var(--text); background: var(--bg-hover); }
.logout-form { display: flex; align-items: center; gap: 10px; margin: 0; }
.who { color: var(--muted); font-size: .9rem; }

/* ─── layout ─── */
.container { max-width: 1100px; margin: 24px auto; padding: 0 16px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}
.cards .card { margin-bottom: 0; }

.card-title {
  color: var(--muted); font-size: .88rem; margin-bottom: 10px;
  display: flex; align-items: center; gap: 10px;
}
.card-title .more { margin-inline-start: auto; font-size: .85rem; }

.big-status { font-size: 1.5rem; font-weight: 700; }
.big-status.ok { color: var(--green); }
.big-status.bad { color: var(--red); }
.big-num { font-size: 2rem; font-weight: 700; }
.big-num .unit { font-size: 1rem; color: var(--muted); font-weight: 400; }
.muted { color: var(--muted); font-size: .88rem; }
.mono { font-family: ui-monospace, Consolas, monospace; }

.mode-badge {
  display: inline-block; margin-top: 8px; padding: 3px 10px;
  border-radius: 20px; font-size: .82rem;
}
.mode-dry { background: rgba(210,153,34,.15); color: var(--amber); }
.mode-live { background: rgba(248,81,73,.15); color: var(--red); }

/* ─── buttons ─── */
.btn {
  border: 1px solid var(--border); background: var(--bg-hover);
  color: var(--text); padding: 8px 16px; border-radius: 8px;
  cursor: pointer; font-size: .9rem; font-family: inherit;
}
.btn:hover { filter: brightness(1.15); }
.btn-primary { background: #1f6feb; border-color: #1f6feb; }
.btn-danger { background: #b62324; border-color: #b62324; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: .82rem; }
.btn-block { width: 100%; margin-top: 6px; }
.btn-row { display: flex; gap: 8px; margin-top: 12px; }
.btn-row form { margin: 0; }

/* ─── settings ─── */
.settings-form {
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap; margin: 0;
}
.inline-field { display: flex; align-items: center; gap: 8px; }
.inline-field input {
  width: 70px; padding: 7px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-size: 1rem; text-align: center;
}
.switch-field { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.switch-field input { width: 18px; height: 18px; accent-color: var(--red); }
.hint { margin: 10px 0 0; }

/* ─── tables ─── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
  text-align: right; color: var(--muted); font-weight: 500;
  padding: 8px 10px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 9px 10px; border-bottom: 1px solid var(--border); }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: none; }
.reason { color: var(--red); font-size: .85rem; }

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: .8rem; white-space: nowrap;
}
.b-green { background: rgba(63,185,80,.15); color: var(--green); }
.b-red { background: rgba(248,81,73,.15); color: var(--red); }
.b-blue { background: rgba(68,147,248,.15); color: var(--accent); }
.b-teal { background: rgba(57,197,207,.15); color: var(--teal); }
.b-gray { background: rgba(139,148,158,.15); color: var(--muted); }

.state-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.alert-card { border-color: rgba(248,81,73,.4); }

/* ─── flash ─── */
.flash {
  padding: 10px 14px; border-radius: 8px; margin-bottom: 14px;
  font-size: .92rem;
}
.flash-ok { background: rgba(63,185,80,.12); color: var(--green); border: 1px solid rgba(63,185,80,.3); }
.flash-error { background: rgba(248,81,73,.12); color: var(--red); border: 1px solid rgba(248,81,73,.3); }

/* ─── login ─── */
.login-box {
  max-width: 360px; margin: 10vh auto; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 32px; text-align: center;
}
.login-logo { font-size: 3rem; }
.login-box h1 { font-size: 1.3rem; margin: 8px 0 4px; }
.login-box form { text-align: right; margin-top: 20px; }
.login-box label { display: block; margin-bottom: 12px; color: var(--muted); font-size: .88rem; }
.login-box input {
  width: 100%; margin-top: 4px; padding: 10px 12px;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 1rem;
}

/* ─── job detail ─── */
.job-name { font-size: 1.1rem; color: var(--text); }
.details {
  display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; margin: 0;
}
.details dt { color: var(--muted); font-size: .88rem; }
.details dd { margin: 0; word-break: break-word; }

.timeline { position: relative; padding-inline-start: 8px; }
.tl-item { display: flex; gap: 12px; padding-bottom: 16px; position: relative; }
.tl-item:not(:last-child)::before {
  content: ""; position: absolute; top: 16px; bottom: 0;
  inset-inline-start: 5px; width: 2px; background: var(--border);
}
.tl-dot {
  width: 12px; height: 12px; border-radius: 50%; margin-top: 4px;
  background: var(--muted); flex-shrink: 0;
}
.tl-dot.b-green { background: var(--green); }
.tl-dot.b-red { background: var(--red); }
.tl-dot.b-blue { background: var(--accent); }
.tl-dot.b-teal { background: var(--teal); }
.tl-head { display: flex; align-items: center; gap: 10px; }
.tl-note { color: var(--muted); font-size: .85rem; margin-top: 4px; direction: ltr; text-align: left; }

/* ─── log ─── */
.logview {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px; max-height: 70vh; overflow: auto;
  font-family: ui-monospace, Consolas, monospace; font-size: .8rem;
  direction: ltr; text-align: left; white-space: pre-wrap; margin: 0;
}

@media (max-width: 640px) {
  .topbar-inner { gap: 8px; }
  .who { display: none; }
  .details { grid-template-columns: 110px 1fr; }
  .settings-form { gap: 12px; }
}
