/* Design tokens shared with the Cloud Team's other tools: dark by
   default, explicit light toggle (not prefers-color-scheme), Inter body
   / Manrope display, sky-blue -> indigo accent. Accent values are the
   light-on-dark pair; the light theme swaps in darker ones that clear
   WCAG AA as text. */
:root {
  --bg: #0b1120;
  --bg-alt: #0f172a;
  --panel: #161f36;
  --panel-border: #263352;
  --text: #e8edf7;
  --muted: #aab6cf;
  --accent: #38bdf8;
  --accent-2: #6366f1;
  --accent-rgb: 56, 189, 248;
  --good: #22c55e;
  --bad: #f43f5e;
  --bad-bg: rgba(244, 63, 94, 0.12);
  --radius: 14px;
  --maxw: 860px;
}

:root[data-theme="light"] {
  --bg: #e8ecf3;
  --bg-alt: #f4f7fb;
  --panel: #ffffff;
  --panel-border: #d7deea;
  --text: #16202f;
  --muted: #47536b;
  --accent: #0284c7;
  --accent-2: #4338ca;
  --accent-rgb: 2, 132, 199;
  --good: #15803d;
  --bad: #dc2626;
  --bad-bg: rgba(220, 38, 38, 0.09);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(var(--accent-rgb), 0.12), transparent),
    radial-gradient(700px 500px at 105% 15%, rgba(var(--accent-rgb), 0.08), transparent),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background 0.4s ease, color 0.4s ease;
}

a { color: var(--accent); }

code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: rgba(var(--accent-rgb), 0.12);
  padding: 0.05em 0.35em;
  border-radius: 5px;
}

/* ---- theme toggle ---- */
#theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 20;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.4s ease;
}
#theme-toggle:hover { border-color: var(--accent); color: var(--text); }
#theme-toggle svg { width: 1.1rem; height: 1.1rem; }
.icon-moon { display: none; }
:root[data-theme="light"] .icon-sun { display: none; }
:root[data-theme="light"] .icon-moon { display: block; }

/* ---- header ---- */
header {
  width: 100%;
  max-width: var(--maxw);
  padding: 1.75rem 1.25rem 0.75rem;
}
.brand { display: flex; align-items: center; gap: 0.7rem; }
.brand-mark { flex-shrink: 0; }
.mark-stop-1 { stop-color: var(--accent); transition: stop-color 0.4s ease; }
.mark-stop-2 { stop-color: var(--accent-2); transition: stop-color 0.4s ease; }
.brand-name {
  font-family: "Manrope", sans-serif;
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
  color: var(--muted);
}
h1 {
  font-family: "Manrope", sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0.05rem 0 0;
}

/* ---- main / form ---- */
main {
  width: 100%;
  max-width: var(--maxw);
  padding: 1rem 1.25rem 2rem;
  flex: 1;
}

.intro { color: var(--muted); margin: 0.25rem 0 1.25rem; }

/* ---- mode toggle ---- */
.mode-toggle {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  margin-bottom: 1.25rem;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
}
.mode-btn {
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--muted);
  background: none;
  border: none;
  border-radius: 7px;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.mode-btn:hover { color: var(--text); }
.mode-btn.active {
  color: #fff;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.mode-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.35);
}

form {
  background: linear-gradient(180deg, var(--panel), var(--bg-alt));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.fields {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.1rem;
}
.field { display: flex; flex-direction: column; flex: 1 1 100%; }
@media (min-width: 620px) {
  .field { flex: 1 1 auto; min-width: 220px; }
  .field--sm { flex: 0 0 150px; min-width: 0; }
}

label {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

input,
select,
textarea {
  font: inherit;
  color: var(--text);
  /* background-color longhand, not the `background` shorthand — `select`
     paints a chevron via background-image/-repeat/-position below, and a
     shorthand here (or in the light override) would reset those and tile
     the chevron across the whole control. */
  background-color: var(--bg-alt);
  border: 1px solid var(--panel-border);
  border-radius: 9px;
  padding: 0.55rem 0.7rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
:root[data-theme="light"] input,
:root[data-theme="light"] select,
:root[data-theme="light"] textarea { background-color: #fff; }
input::placeholder,
textarea::placeholder { color: var(--muted); opacity: 0.7; }
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.3);
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 8rem;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.5;
}

/* Consistent dropdown chevron across browsers (Firefox keeps its own
   otherwise). Colour is baked into the data URI, so define one per theme. */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%23aab6cf' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
}
:root[data-theme="light"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%2347536b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
}

.field-help { color: var(--muted); font-size: 0.78rem; margin-top: 0.3rem; }

.btn {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: 9px;
  padding: 0.6rem 1.1rem;
  border: 1px solid transparent;
  transition: filter 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.35);
}
.btn-primary {
  color: #fff;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
:root[data-theme="light"] .btn-primary { color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }

/* ---- error ---- */
.error {
  margin-top: 1rem;
  padding: 0.8rem 1rem;
  border-radius: 10px;
  background: var(--bad-bg);
  border: 1px solid var(--bad);
  color: var(--text);
  font-size: 0.9rem;
}

/* ---- results ---- */
.results { margin-top: 1.5rem; }

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  padding: 0.9rem 1rem;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  font-size: 0.9rem;
}
.summary div { white-space: nowrap; }
.summary .k { color: var(--muted); margin-right: 0.35rem; }
.summary .v { font-variant-numeric: tabular-nums; font-weight: 600; }

.notes { margin: 0.75rem 0 0; display: flex; flex-direction: column; gap: 0.4rem; }
.note {
  font-size: 0.83rem;
  color: var(--muted);
  padding-left: 1.1rem;
  position: relative;
}
.note::before {
  content: "i";
  position: absolute;
  left: 0;
  top: 0.05rem;
  width: 0.85rem;
  height: 0.85rem;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 0.9rem;
  text-align: center;
  border-radius: 999px;
  color: var(--bg);
  background: var(--accent);
}

.table-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0 0.5rem; }

.table-scroll { overflow-x: auto; border: 1px solid var(--panel-border); border-radius: 10px; }

table { border-collapse: collapse; width: 100%; font-size: 0.86rem; }
th, td {
  text-align: center;
  padding: 0.55rem 0.75rem;
  white-space: nowrap;
  border-bottom: 1px solid var(--panel-border);
}
thead th {
  background: var(--panel);
  font-weight: 600;
  color: var(--muted);
  position: sticky;
  top: 0;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) { background: rgba(var(--accent-rgb), 0.045); }
td { font-variant-numeric: tabular-nums; }
td:nth-child(2) { font-weight: 600; }

/* Each CIDR is a click-to-copy target — styled as plain cell text until
   hovered/focused, then briefly shows "Copied". */
.cidr-copy {
  font: inherit;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: none;
  border: none;
  padding: 0.12rem 0.4rem;
  margin: -0.12rem -0.4rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.cidr-copy:hover { background: rgba(var(--accent-rgb), 0.16); }
.cidr-copy:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.45);
}
.cidr-copy:disabled { cursor: default; color: var(--accent); background: none; }

.truncation-note { color: var(--muted); font-size: 0.83rem; margin: 0.6rem 0 0; }
.table-note { color: var(--muted); font-size: 0.8rem; line-height: 1.5; margin: 0.7rem 0 0; }
.table-note strong { color: var(--text); font-weight: 600; }

.note--warn::before { background: var(--bad); }

.cidr-output {
  margin: 0;
  padding: 0.9rem 1rem;
  max-height: 28rem;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.86rem;
  line-height: 1.6;
  white-space: pre;
}

/* ---- footer ---- */
footer {
  width: 100%;
  max-width: var(--maxw);
  padding: 1rem 1.25rem 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
