/* Caddy Configurator — CDS SOFT corporate light theme. */
/* Covers the CDS SOFT brand colors: navy sidebar + blue primary, yellow accent. */
:root {
  --cds-blue: #4778BD;
  --cds-blue-dark: #3a63a4;
  --cds-blue-soft: #e9f0f9;
  --cds-yellow: #FEE530;
  --cds-navy: #091424;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #dce3ee;
  --text: #16233a;
  --muted: #5b6b82;
  --green: #1e8e5a;
  --green-bg: #e6f5ee;
  --red: #b23b2e;
  --red-bg: #fbeae8;
  --amber: #9a6b0a;
  --amber-bg: #fdf3dd;
  --shadow: 0 1px 2px rgba(9,20,36,.05), 0 4px 14px rgba(9,20,36,.05);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

h1, h2, h3, h4 { margin: 0; }
button { font-family: inherit; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }

/* ---------- sidebar (navy) ---------- */
.sidebar {
  background: var(--cds-navy);
  color: #d8e2f2;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 18px; }
.brand-mark { flex: none; filter: drop-shadow(0 1px 2px rgba(0,0,0,.35)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { color: #ffffff; font-size: 13px; letter-spacing: .14em; }
.brand-text span { color: #93a5c4; font-size: 11.5px; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  appearance: none;
  border: none;
  background: transparent;
  color: #aebfd9;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  cursor: pointer;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #ffffff; }
.nav-item.active {
  background: rgba(71,120,189,.22);
  color: #ffffff;
  border-left-color: var(--cds-yellow);
  font-weight: 600;
}

.sidebar-foot { display: flex; flex-direction: column; gap: 8px; padding: 14px 6px 4px; }
.dev-badge {
  align-self: flex-start;
  background: var(--cds-yellow);
  color: var(--cds-navy);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .1em;
  padding: 3px 9px;
  border-radius: 999px;
}
.not-connected { color: #7d8fae; font-size: 11.5px; }

/* ---------- main column ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 17px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.pill {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .08em;
  padding: 3px 10px;
  border-radius: 999px;
}
.dev-pill { background: var(--cds-yellow); color: var(--cds-navy); }

.conn { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #b0bccd; }
.dot.ready { background: var(--green); }
.dot.error { background: var(--red); }

.content { padding: 22px; display: flex; flex-direction: column; gap: 16px; max-width: 1180px; width: 100%; margin: 0 auto; }

.loading { color: var(--muted); padding: 40px; text-align: center; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; }
.card-head h2 { font-size: 15px; font-weight: 700; }
.card-head .sub { font-size: 12px; color: var(--muted); }

.section-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 6px 0 10px; }

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { border-color: var(--cds-blue); color: var(--cds-blue); }
.btn.primary { background: var(--cds-blue); border-color: var(--cds-blue); color: #ffffff; font-weight: 600; }
.btn.primary:hover { background: var(--cds-blue-dark); color: #ffffff; }
.btn.danger { background: var(--red-bg); border-color: #e9c1bc; color: var(--red); }
.btn.danger:hover { border-color: var(--red); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--cds-blue); border-color: var(--border); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn-icon {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  width: 28px; height: 28px;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { color: var(--cds-blue); border-color: var(--border); background: var(--bg); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 11.5px; color: var(--muted); }
input[type="text"], input[type="number"], input[type="email"], input[type="password"], select, textarea {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  width: 100%;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--cds-blue-soft); border-color: var(--cds-blue); }
input[disabled], select[disabled] { background: var(--surface-alt); color: var(--muted); cursor: not-allowed; }

.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.checkbox-row input { width: auto; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 760px) { .grid2, .grid3, .form-grid { grid-template-columns: 1fr; } }

.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface);
}
.badge.ok { background: var(--green-bg); border-color: #bfe4d2; color: var(--green); }
.badge.warn { background: var(--amber-bg); border-color: #ecd9a6; color: var(--amber); }
.badge.bad { background: var(--red-bg); border-color: #ecc4be; color: var(--red); }
.badge.info { background: var(--cds-blue-soft); border-color: #c7d9ef; color: var(--cds-blue-dark); }
.badge .dot { width: 6px; height: 6px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}
.tbl td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: var(--surface-alt); }
.tbl .addr { font-weight: 600; }
.tbl .muted-note { color: var(--muted); font-size: 12px; }
.tbl .actions { display: flex; gap: 4px; justify-content: flex-end; }
.tbl .domain-chip {
  display: inline-block;
  background: var(--cds-blue-soft);
  color: var(--cds-blue-dark);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 11px;
  margin: 1px 2px 1px 0;
}
.row-disabled { opacity: .55; }
.row-disabled .addr { text-decoration: line-through; }

/* ---------- switch (enable/disable) ---------- */
.switch { position: relative; display: inline-block; width: 34px; height: 19px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0;
  background: #c3cddb;
  border-radius: 999px;
  transition: background .15s;
  cursor: pointer;
}
.switch .slider::before {
  content: "";
  position: absolute;
  height: 15px; width: 15px;
  left: 2px; top: 2px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(15px); }

/* ---------- stat cards (dashboard) ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat .label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat .value { font-size: 26px; font-weight: 800; color: var(--cds-navy); }
.stat .value.accent { color: var(--cds-blue); }
.stat .sub { font-size: 12px; color: var(--muted); }

.banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
}
.banner.warn { background: var(--amber-bg); border: 1px solid #ecd9a6; color: var(--amber); }
.banner.info { background: var(--cds-blue-soft); border: 1px solid #c7d9ef; color: var(--cds-blue-dark); }
.banner.ok { background: var(--green-bg); border: 1px solid #bfe4d2; color: var(--green); }
.banner.danger { background: var(--red-bg); border: 1px solid #ecc4be; color: var(--red); }
.banner-title { font-weight: 700; }

/* ---------- diagnostics ---------- */
.diagnostics { margin-top: 4px; }
.diag-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.diag-list li { font-size: 12.5px; display: flex; gap: 8px; align-items: baseline; padding: 5px 8px; border-radius: 6px; }
.diag-list .sev { font-weight: 700; min-width: 52px; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; }
.diag-list li.err { background: var(--red-bg); } .diag-list li.err .sev { color: var(--red); }
.diag-list li.warn { background: var(--amber-bg); } .diag-list li.warn .sev { color: var(--amber); }
.diag-list li.info { background: var(--cds-blue-soft); } .diag-list li.info .sev { color: var(--cds-blue-dark); }
.diag-list .code { color: var(--muted); font-size: 11px; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(9,20,36,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 20px;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(9,20,36,.25);
  width: min(760px, 94vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  padding: 16px 18px;
}
.modal-box.wide { width: min(980px, 96vw); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h2 { font-size: 16px; }
#modal-body { overflow: auto; }

/* ---------- code editor ---------- */
.code-editor {
  width: 100%;
  min-height: 420px;
  resize: vertical;
  background: #0b1524; /* dark code surface against the light app */
  color: #d7e3f5;
  border: 1px solid #22304a;
  border-radius: 8px;
  padding: 14px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  tab-size: 4;
  white-space: pre;
}
.code-editor:focus { outline: 2px solid var(--cds-blue); border-color: var(--cds-blue); }
.code-block {
  background: #0b1524;
  color: #d7e3f5;
  border: 1px solid #22304a;
  border-radius: 8px;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre;
  overflow: auto;
  max-height: 480px;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  background: var(--cds-navy);
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(9,20,36,.35);
  font-size: 13px;
  max-width: 420px;
  border-left: 4px solid var(--cds-blue);
}
.toast.error { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }
.toast.hidden { display: none; }

/* ---------- routes editor ---------- */
.route-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  background: var(--surface-alt);
}
.route-box-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.route-manual { color: var(--muted); font-size: 11.5px; }

.list-rows { display: flex; flex-direction: column; gap: 6px; }
.row-line { display: flex; gap: 8px; align-items: center; }
.row-line .grow { flex: 1; min-width: 0; }

/* ---------- auth gate (FASE 2A) ---------- */
.auth-screen {
  position: fixed;
  inset: 0;
  background: rgba(9,20,36,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  padding: 20px;
}
.auth-screen.hidden, .auth-error.hidden, #auth-confirm.hidden, .sidebar-user.hidden { display: none; }
.auth-card {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(9,20,36,.25);
  width: min(420px, 100%);
  padding: 26px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.auth-brand { display: flex; align-items: center; gap: 10px; padding-bottom: 2px; }
.auth-brand .brand-text strong { color: var(--text); font-size: 13px; letter-spacing: .14em; }
.auth-brand .brand-text span { color: var(--muted); font-size: 11.5px; }
.auth-card h2 { font-size: 18px; }
.auth-sub { margin: 0; color: var(--muted); font-size: 12.5px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.auth-form .btn.primary { justify-content: center; }
.auth-error {
  background: var(--red-bg);
  border: 1px solid #ecc4be;
  color: var(--red);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
}
.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #93a5c4;
  font-size: 12px;
  min-width: 0;
}
.sidebar-user .who { color: #ffffff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .btn { color: #aebfd9; border-color: rgba(255,255,255,.28); background: transparent; }
.sidebar-user .btn:hover { color: #ffffff; border-color: #ffffff; }

/* ---------- DNS / BIND (FASE 2B.3) ---------- */
.bind-page { padding: 20px; }
.bind-staging-banner {
  background: var(--amber-bg);
  border: 1px solid #f0d172;
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 20px;
}
.bind-staging-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--amber);
  margin-bottom: 6px;
}
.bind-zone-list { margin: 16px 0; }
.bind-zone-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.bind-zone-item:hover { background: var(--cds-blue-soft); }
.bind-zone-item.selected {
  border-color: var(--cds-blue);
  background: var(--cds-blue-soft);
}
.bind-zone-name { font-weight: 600; }
.bind-zone-error { color: var(--red); font-size: 12px; margin-top: 4px; }
.bind-readonly-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--amber-bg);
  color: var(--amber);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
.bind-error-msg { color: var(--red); font-size: 12px; margin-top: 8px; }
.bind-preview-result { margin-top: 12px; }
.bind-preview-result textarea { margin-top: 6px; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .content { padding: 14px; }
}
