/* DeckForge Web UI — TruRating-inspired theme */

:root {
  --purple:     #360A3D;
  --purple-mid: #4d1157;
  --blue:       #039BEF;
  --blue-dark:  #1863DC;
  --bg:         #F9F9FB;
  --surface:    #ffffff;
  --text:       #212121;
  --text-muted: #666666;
  --text-faint: #999999;
  --border:     #E2E8F0;
  --border-light: #F1F5F9;
  --danger:     #dc2626;
  --shadow-sm:  0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md:  0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg:  0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-pill: 9999px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
header {
  background: var(--surface);
  color: var(--text);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow-sm);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  height: 64px;
  gap: 32px;
  max-width: 1200px;
  margin: 0 auto;
}
.logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--purple);
}
nav {
  display: flex;
  gap: 8px;
}
nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  transition: all 0.2s ease;
}
nav a:hover {
  background: var(--border-light);
  color: var(--text);
}
nav a.active {
  background: var(--purple);
  color: #fff;
}

/* ── Main content ────────────────────────────────────────────────────────── */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}

.page { max-width: 720px; margin: 0 auto; }
.page h1 { font-size: 28px; font-weight: 800; margin-bottom: 24px; color: var(--purple); letter-spacing: -0.5px; }
h1 { font-size: 28px; font-weight: 800; margin-bottom: 24px; color: var(--purple); letter-spacing: -0.5px; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 24px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
}

/* ── Fields ──────────────────────────────────────────────────────────────── */
.field-group { margin-bottom: 20px; }
.field-group label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.field-group input[type=text],
.field-group input[type=number],
.field-group select,
.field-group textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  background: var(--surface);
  transition: all 0.2s ease;
  color: var(--text);
}
.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(3,155,239,0.15);
}
.field-group input:hover,
.field-group select:hover,
.field-group textarea:hover {
  border-color: #cbd5e1;
}
.field-group.blocked { opacity: 0.5; pointer-events: none; filter: grayscale(1); }
.field-row { display: flex; gap: 16px; }
.field-row .field-group { flex: 1; }

/* ── Multi-select checkboxes ─────────────────────────────────────────────── */
.multi-select {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--surface);
  max-height: 200px;
  overflow-y: auto;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 4px;
  font-weight: 500;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}
.checkbox-label:hover {
  background: var(--border-light);
}
.checkbox-label input[type=checkbox] {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
  cursor: pointer;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}
.btn:active {
  transform: translateY(1px);
}
.btn-primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 4px 6px rgba(3, 155, 239, 0.25);
}
.btn-primary:hover {
  background: var(--blue-dark);
  box-shadow: 0 6px 12px rgba(3, 155, 239, 0.3);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--border);
}
.btn-secondary:hover {
  border-color: var(--blue);
  color: var(--blue);
}
.btn-link {
  background: none;
  color: var(--blue);
  font-weight: 600;
  box-shadow: none;
  padding: 6px 12px;
}
.btn-link:hover {
  background: rgba(3,155,239,0.1);
  color: var(--blue-dark);
}
.btn-danger {
  background: var(--surface);
  color: var(--danger);
  border: 2px solid #fecaca;
  box-shadow: none;
}
.btn-danger:hover {
  background: #fef2f2;
  border-color: var(--danger);
}
.btn-small { font-size: 13px; padding: 6px 12px; }

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  align-items: center;
}

/* ── Status badges ───────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge.status-running { background: #fef3c7; color: #92400e; }
.badge.status-done    { background: #d1fae5; color: #065f46; }
.badge.status-error   { background: #fee2e2; color: #991b1b; }

/* ── Status box ──────────────────────────────────────────────────────────── */
.status-box {
  padding: 16px;
  border-radius: 4px;
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.status-running { background: #fffbeb; border: 1px solid #fde68a; }
.status-done    { background: #f0fdf4; border: 1px solid #86efac; }
.status-error   { background: #fef2f2; border: 1px solid #fca5a5; }
.error-detail { font-family: monospace; font-size: 12px; white-space: pre-wrap; flex: 1 1 100%; margin-top: 8px; }

/* ── Misc ────────────────────────────────────────────────────────────────── */
.hint     { color: var(--text-faint); font-size: 13px; margin: 8px 0; }
.dim      { color: var(--text-faint); }
.required { color: var(--danger); }
.field-desc { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; margin-top: 2px; }

/* ── Setup layout ────────────────────────────────────────────────────────── */
.setup-layout {
  display: grid;
  grid-template-columns: 1fr 480px;
  gap: 32px;
  align-items: start;
  max-width: 1200px;
}

@media (max-width: 900px) {
  .setup-layout {
    grid-template-columns: 1fr;
  }
  .setup-editor {
    position: static;
    top: auto;
    max-height: none;
  }
}

.setup-lists { min-width: 0; }
.setup-editor {
  position: sticky;
  top: 88px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.setup-section {
  margin-bottom: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
}
.section-header h2 { font-size: 18px; font-weight: 700; color: var(--purple); }
.setup-table { margin: 0; }
.setup-table th { padding: 12px 24px; }
.setup-table td { padding: 12px 24px; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.setup-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.setup-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  padding: 8px;
}
.setup-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
.setup-table tr:hover td { background: #f9f9f9; }
.setup-table code { font-family: monospace; font-size: 12px; background: #f0f0f0; padding: 2px 5px; border-radius: 3px; }

/* ── Editor panel ────────────────────────────────────────────────────────── */
.editor-panel h3 { font-size: 15px; margin-bottom: 16px; color: var(--purple); }
.editor-name { color: var(--text-muted); font-size: 13px; margin-bottom: 12px; }

/* ── Test results ────────────────────────────────────────────────────────── */
.test-results {
  margin-top: 16px;
  padding: 12px;
  background: #fafafa;
  border: 1px solid var(--border-light);
  border-radius: 3px;
  font-size: 13px;
  min-height: 0;
}
.test-results:empty { display: none; }
.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 8px;
}
.result-table th { background: #efefef; padding: 4px 8px; text-align: left; }
.result-table td { padding: 4px 8px; border-bottom: 1px solid #efefef; }
.result-text { font-family: monospace; white-space: pre-wrap; font-size: 12px; }
.error { color: var(--danger); font-size: 13px; }

/* ── HTMX loading indicator ──────────────────────────────────────────────── */
.htmx-request {
  opacity: 0.6;
  transition: opacity 200ms;
  pointer-events: none;
  position: relative;
}

/* Spinner overlay for elements loading */
.htmx-request::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 3px solid rgba(3,155,239,0.2);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: dep-spin 0.8s linear infinite;
  z-index: 100;
}

/* ── Info boxes ──────────────────────────────────────────────────────────── */
.info-box {
  background: #e8f5fd;
  border: 1px solid #b3dff7;
  border-radius: 3px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.6;
  margin-bottom: 12px;
  color: #0a5a8c;
}
.info-box code {
  background: #cceefa;
  padding: 1px 4px;
  border-radius: 3px;
  font-family: monospace;
}
.info-box--neutral {
  background: #f8f8f8;
  border-color: var(--border);
  color: #444;
}
.info-box--neutral code { background: #ebebeb; }

/* ── Section dividers and labels in editor ───────────────────────────────── */
.section-divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 16px 0 12px;
}
.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Hint inline ─────────────────────────────────────────────────────────── */
.hint-inline {
  font-size: 11px;
  font-weight: normal;
  color: var(--text-faint);
  text-transform: none;
  letter-spacing: normal;
}
.hint-inline code {
  background: #f0f0f0;
  padding: 1px 4px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 11px;
}

/* ── Option list in test results ─────────────────────────────────────────── */
.option-list { margin: 6px 0 0 16px; font-size: 13px; }
.option-list li { margin: 2px 0; }

/* ── Resolved query ──────────────────────────────────────────────────────── */
.resolved-query {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 3px;
}
.resolved-query-label {
  display: block;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--text-muted);
}
.resolved-query summary {
  padding: 5px 10px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.resolved-query summary:hover { color: var(--text); }
.resolved-query pre {
  margin: 0;
  padding: 8px 10px;
  font-size: 11px;
  font-family: monospace;
  background: #fafafa;
  white-space: pre-wrap;
  word-break: break-all;
  border-top: 1px solid var(--border-light);
  max-height: 200px;
  overflow-y: auto;
}

/* ── Modal dialog ────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(54,10,61,0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-box {
  background: var(--surface);
  border-radius: 4px;
  padding: 24px;
  min-width: 340px;
  max-width: 520px;
  max-height: 80vh;
  width: 100%;
  box-shadow: 0 8px 32px rgba(54,10,61,0.18);
  overflow-y: auto;
}
.modal-box h4 {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--purple);
}
.modal-box .field-group { margin-bottom: 12px; }
.modal-box label { display: block; font-size: 12px; font-weight: 500; margin-bottom: 4px; color: var(--text-muted); }
.modal-box input[type=text],
.modal-box input[type=number] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 13px;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}
.dep-multi-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 6px 8px;
}

/* ── Multi-select select/deselect all ────────────────────────────────────── */
.multi-select-actions,
.dep-multi-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}
.multi-select-sep {
  font-size: 12px;
  color: var(--text-muted);
}
.btn-link-inline {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  color: var(--blue);
  cursor: pointer;
  text-decoration: underline;
  line-height: 1;
}
.btn-link-inline:hover { color: var(--purple); }

/* ── Modal dep-widget states ─────────────────────────────────────────────── */
.dep-widget { min-height: 32px; }
.dep-widget.dep-loading,
.dep-widget.dep-waiting {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-faint);
  font-size: 12px;
  font-style: italic;
}
.dep-widget.dep-waiting { opacity: 0.55; }
.dep-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  flex-shrink: 0;
  animation: dep-spin 0.7s linear infinite;
}
@keyframes dep-spin { to { transform: rotate(360deg); } }

/* ── Slide thumbnail strip ────────────────────────────────────────────────── */
.thumb-strip {
  margin: 20px 0 12px;
}
.thumb-strip-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.thumb-strip-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  flex: 1;
}
.thumb-strip-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.thumb-action-btn {
  font-size: 11px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}
.thumb-action-btn:hover {
  background: var(--hover);
  color: var(--text);
}
.thumb-select-count {
  font-size: 11px;
  color: var(--text-faint);
  min-width: 60px;
}
.thumb-strip-scroll {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  padding: 4px 0 12px;
}
.thumb-card {
  text-align: center;
  cursor: default;
  position: relative;
}

/* Checkbox overlay */
.thumb-checkbox-wrap {
  display: block;
  position: relative;
  cursor: pointer;
}
.thumb-checkbox-wrap input[type=checkbox] {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 14px;
  height: 14px;
  margin: 0;
  cursor: pointer;
  z-index: 2;
  accent-color: var(--blue);
}
.thumb-card img {
  width: 140px;
  height: auto;
  border-radius: 3px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: border-color 0.15s, box-shadow 0.15s;
  display: block;
}
.thumb-card img:hover {
  border-color: var(--blue);
  box-shadow: 0 2px 8px rgba(3,155,239,0.18);
}
/* Dim deselected slides */
.thumb-card:has(.thumb-cb:not(:checked)) img {
  opacity: 0.4;
}
.thumb-card:has(.thumb-cb:not(:checked)) {
  opacity: 0.6;
}
.thumb-label {
  display: block;
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 4px;
}
.thumb-strip-notice {
  font-size: 12px;
  color: var(--text-faint);
  padding: 8px 0;
}

/* Slide badges (loop / condition) */
.thumb-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 11px;
  line-height: 1;
  padding: 1px 3px;
  border-radius: 3px;
  z-index: 3;
}
.thumb-badge-loop {
  background: rgba(3,155,239,0.85);
  color: #fff;
  right: 4px;
}
.thumb-badge-cond {
  background: rgba(245,166,35,0.85);
  color: #fff;
  right: 22px;
}

/* ── Placeholder card (no thumbnail available) ─────────────────────────── */
.thumb-placeholder {
  width: 140px;
  height: 79px;   /* ~16:9 at 140px wide */
  border-radius: 3px;
  border: 1px dashed var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.thumb-placeholder-num {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-faint);
  line-height: 1;
}
.thumb-placeholder-name {
  font-size: 9px;
  color: var(--text-faint);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}
.thumb-no-preview-hint {
  font-weight: 400;
  font-size: 10px;
  color: var(--text-faint);
}

/* ── Loop toggle button ─────────────────────────────────────────────────── */
.thumb-loop-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  padding: 0;
  font-size: 11px;
  line-height: 1;
  border-radius: 3px;
  border: 1px solid transparent;
  background: rgba(255,255,255,0.15);
  color: var(--text-faint);
  cursor: pointer;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;           /* hidden until card hovered */
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.thumb-card:hover .thumb-loop-btn,
.thumb-loop-btn.active {
  opacity: 1;
}
.thumb-loop-btn.active {
  background: rgba(3,155,239,0.85);
  color: #fff;
  border-color: transparent;
}
.thumb-loop-btn:hover {
  background: var(--blue);
  color: #fff;
  opacity: 1;
}
.thumb-condition-btn {
  right: 26px;
}
.thumb-condition-btn.active {
  background: rgba(245,166,35,0.9);
  color: #fff;
}
.thumb-condition-btn:hover {
  background: #f5a623;
}
/* Touch devices: always show the loop button at a finger-friendly size */
@media (hover: none) {
  .thumb-loop-btn {
    opacity: 1;
    width: 26px;
    height: 26px;
    font-size: 13px;
    background: rgba(255,255,255,0.88);
    color: var(--text-muted);
    border-color: var(--border);
  }
}
/* Shift condition badge left when loop button is present */
.thumb-badge-cond {
  right: 26px;
}

/* ── Loop input picker popover ──────────────────────────────────────────── */
.loop-picker {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
}
.loop-picker-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
  width: 320px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.loop-picker-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.loop-picker-icon {
  font-size: 24px;
  color: var(--blue);
  line-height: 1;
  flex-shrink: 0;
}
.loop-picker-title {
  font-weight: 600;
  font-size: 14px;
  margin: 0 0 2px;
}
.loop-picker-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}
.loop-picker-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 14px;
  line-height: 1.5;
}
.loop-picker-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.loop-picker-select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  margin-bottom: 16px;
}
.loop-picker-empty {
  font-size: 12px;
  color: var(--text-faint);
  margin: 0 0 16px;
  font-style: italic;
}
.loop-picker-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.condition-picker-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 240px;
  overflow-y: auto;
  margin-bottom: 16px;
}
.condition-picker-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13px;
}
.condition-picker-item small {
  display: block;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Slide lightbox modal ───────────────────────────────────────────────── */
@media (max-width: 600px) {
  .slide-modal-content { flex-direction: column; }
  .slide-modal-image-wrap { padding: 16px 24px; flex: 0 0 auto; }
  .slide-modal-image-wrap img { max-height: 45vw; }
  .slide-modal-info {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 200px;
  }
  .slide-modal-nav { display: none; }
}

.slide-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.slide-modal-box {
  position: relative;
  background: var(--surface);
  border-radius: 6px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.45);
  max-width: 92vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.slide-modal-close {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 22px;
  line-height: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  z-index: 10;
  padding: 2px 6px;
  border-radius: 3px;
}
.slide-modal-close:hover { background: var(--hover); color: var(--text); }
.slide-modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 28px;
  background: rgba(0,0,0,0.22);
  border: none;
  color: #fff;
  cursor: pointer;
  z-index: 10;
  padding: 6px 10px;
  border-radius: 3px;
  line-height: 1;
}
.slide-modal-nav:disabled { opacity: 0.2; cursor: default; }
.slide-modal-nav:not(:disabled):hover { background: rgba(0,0,0,0.45); }
.slide-modal-prev { left: 6px; }
.slide-modal-next { right: 6px; }
.slide-modal-content {
  display: flex;
  overflow: hidden;
  flex: 1;
}
.slide-modal-image-wrap {
  flex: 1 1 auto;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  padding: 32px 48px;
}
.slide-modal-image-wrap img {
  max-width: 100%;
  max-height: 75vh;
  border-radius: 3px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.5);
}
.slide-modal-info {
  width: 220px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 14px;
  overflow-y: auto;
}
.slide-modal-header {
  margin-bottom: 12px;
}
.slide-modal-num {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
}
.slide-modal-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: block;
  margin-top: 3px;
}
.slide-modal-tags-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.modal-tab-bar {
  display: flex;
  gap: 2px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.modal-tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: -1px;
}
.modal-tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.modal-tab-panel {
  min-height: 40px;
}
.tag-row {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-size: 12px;
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
}
.tag-row:last-child { border-bottom: none; }
.tag-status-icon {
  flex-shrink: 0;
  font-size: 11px;
  width: 14px;
  text-align: center;
}
.tag-row.tag-ok .tag-status-icon { color: #22a55a; }
.tag-row.tag-missing .tag-status-icon { color: #e0443c; }
.tag-row.tag-input .tag-status-icon { color: #5b8dee; }
.tag-name {
  flex: 1;
  color: var(--text);
  font-family: monospace;
  word-break: break-all;
}
/* Input rows in the lightbox: stacked name + description */
.tag-row.tag-input { flex-wrap: wrap; }
.tag-input-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.tag-input-desc {
  width: 100%;
  font-size: 10px;
  color: var(--text-faint);
  padding-left: 19px;
}
.tag-type {
  flex-shrink: 0;
  font-size: 10px;
  color: var(--text-faint);
  background: var(--hover);
  border-radius: 2px;
  padding: 0 4px;
}
.tag-loading, .tag-none {
  font-size: 11px;
  color: var(--text-faint);
  padding: 4px 0;
}

/* ── htmx loading indicator for cascade form ─────────────────────────────── */
#inputs-container {
  position: relative;
  transition: opacity 0.2s;
  min-height: 100px;
}
#inputs-container.htmx-request {
  opacity: 0.5;
  pointer-events: none;
  cursor: wait;
}

/* ── Input kind selector (radio cards) ───────────────────────────────────── */
.kind-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.kind-selector label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.kind-selector input[type=radio] { accent-color: var(--blue); }
.kind-selector label:has(input:checked) {
  border-color: var(--blue);
  background: rgba(3,155,239,0.05);
}
.kind-panel { display: none; }
.kind-panel.active { display: block; }

/* ── Daterange in generate form ──────────────────────────────────────────── */
.daterange-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.daterange-group input[type=date] {
  flex: 1;
}
.daterange-label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Date inputs in field-group ──────────────────────────────────────────── */
.field-group input[type=date] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 14px;
  background: var(--surface);
  transition: border-color 0.15s;
}
.field-group input[type=date]:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(3,155,239,0.12);
}

/* ── Date picker widget (Absolute / Relative) ────────────────────────────── */
.dp-widget { margin-bottom: 4px; }

.dp-mode-row {
  display: flex;
  gap: 20px;
  margin-bottom: 10px;
}
.dp-mode-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
}
.dp-mode-label input[type=radio] { cursor: pointer; }

.dp-abs-date {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 14px;
  background: var(--surface);
  width: 100%;
  box-sizing: border-box;
}

.dp-rel-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.dp-n {
  width: 72px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 14px;
  background: var(--surface);
  text-align: center;
}
.dp-unit {
  flex: 1;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 14px;
  background: var(--surface);
}
.dp-ago { font-size: 13px; color: var(--text-muted); white-space: nowrap; }

.dp-pin-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-muted);
}
.dp-on-the, .dp-of-month { white-space: nowrap; }
.dp-pin {
  padding: 5px 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 13px;
  background: var(--surface);
}
.dp-preview { margin-top: 4px; margin-bottom: 0; font-size: 12px; }

/* Daterange side-by-side pickers */
.dp-daterange-wrap {
  display: flex;
  gap: 12px;
}
.dp-daterange-wrap > * { flex: 1; }
.dp-daterange-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
