/* =====================================================================
   MejoraDNS portal - visual design system
   File: /opt/mejoradns/portal/static/css/portal.css
   ---------------------------------------------------------------------
   DESIGN IDEA
     Colours come from fibre-optic cable jackets, the everyday material
     of an ISP:
       aqua   (OM3 multimode fibre)  = main colour: links, buttons
       yellow (OS2 single-mode fibre)= attention only: keyboard focus,
                                       highlights. Used sparingly.
     Status uses the language of network equipment LEDs:
       green = online, amber = warning, red = problem, grey = never seen.
     Font: IBM Plex Sans (technical, has a matching Tamil version).
     IBM Plex Mono only for real technical values (IPs, domains).

   HOW TO CHANGE A COLOUR
     Edit the variables in :root (light) and the dark-mode block below.
     Every page uses these variables, so one change updates everything.
   ===================================================================== */

/* ---- Fonts (stored in /static/fonts, no outside dependency) -------- */
@font-face { font-family: "Plex Sans"; font-weight: 400; font-display: swap;
  src: url("../fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Plex Sans"; font-weight: 500; font-display: swap;
  src: url("../fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Plex Sans"; font-weight: 600; font-display: swap;
  src: url("../fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Plex Mono"; font-weight: 400; font-display: swap;
  src: url("../fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Plex Mono"; font-weight: 500; font-display: swap;
  src: url("../fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }

/* ---- Colour and spacing tokens ------------------------------------- */
:root {
  --ink: #13202e;           /* main text, sidebar background */
  --ink-soft: #4a5b6c;      /* secondary text */
  --ink-faint: #7b8a99;     /* hints, timestamps */
  --page: #eef2f5;          /* page background */
  --panel: #ffffff;         /* panels and tables */
  --line: #d8e0e7;          /* borders and dividers */
  --aqua: #00838f;          /* main colour (OM3 fibre aqua) */
  --aqua-strong: #006671;   /* hover / pressed */
  --aqua-wash: #e1f3f4;     /* light aqua backgrounds */
  --signal: #f2c230;        /* attention only (OS2 fibre yellow) */
  --ok: #1f9d55;
  --warn: #c27c0e;
  --bad: #c8352f;
  --idle: #98a6b3;
  --rail: #13202e;          /* sidebar */
  --rail-text: #c9d4de;
  --rail-active: #1d3044;
  --radius-small: 6px;      /* inputs, buttons, badges */
  --radius-panel: 10px;     /* panels */
  --font: "Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --on-aqua: #ffffff;       /* text on aqua buttons */
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e4ebf1;
    --ink-soft: #a9b7c4;
    --ink-faint: #7f8f9e;
    --page: #0d1620;
    --panel: #142231;
    --line: #23364a;
    --aqua: #2bb7c2;
    --aqua-strong: #5fd0d8;
    --aqua-wash: #12333d;
    --ok: #3ccf7f;
    --warn: #e7a33a;
    --bad: #f0605a;
    --idle: #5d6f80;
    --rail: #091119;
    --rail-text: #b3c1cd;
    --rail-active: #17283a;
    --on-aqua: #04262b;     /* dark text on the bright dark-mode aqua (readable contrast) */
  }
}

/* ---- Base ---------------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: 15px/1.55 var(--font); font-feature-settings: "tnum" 1; /* even-width digits */
}
a { color: var(--aqua); text-decoration: none; }
a:hover { color: var(--aqua-strong); text-decoration: underline; }
h1 { font-size: 1.6rem; line-height: 1.25; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; line-height: 1.35; font-weight: 600; margin: 0 0 12px; }
p { margin: 0 0 12px; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; border-radius: 3px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---- App frame: sidebar + main ------------------------------------ */
.frame { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.rail { background: var(--rail); color: var(--rail-text); padding: 20px 14px;
        display: flex; flex-direction: column; gap: 22px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; padding: 0 8px; }
.brand svg { width: 28px; height: 28px; flex: none; }
.brand-name { font-weight: 600; font-size: 1.05rem; letter-spacing: 0.01em; }
.workspace { padding: 0 8px; font-size: 0.85rem; color: var(--rail-text); }
.workspace b { display: block; color: #fff; font-weight: 500; font-size: 0.95rem; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a, .nav span { display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: var(--radius-small); color: var(--rail-text); font-weight: 500; }
.nav a:hover { background: var(--rail-active); color: #fff; text-decoration: none; }
.nav a[aria-current="page"] { background: var(--rail-active); color: #fff;
  box-shadow: inset 3px 0 0 var(--aqua); }
.nav svg { width: 18px; height: 18px; flex: none; opacity: 0.85; }
.nav .soon { opacity: 0.45; cursor: default; }
.nav .soon small { margin-left: auto; font-size: 0.72rem; font-weight: 400; }
.nav-group { font-size: 0.78rem; color: var(--idle); padding: 0 10px; margin-top: 6px; }
.rail-foot { margin-top: auto; font-size: 0.85rem; padding: 0 8px; }
.rail-foot form { margin: 6px 0 0; }
.rail-foot button { background: none; border: 0; color: var(--rail-text); padding: 0;
  font: inherit; cursor: pointer; text-decoration: underline; }

.main { min-width: 0; padding: 26px 32px 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { color: var(--ink-soft); margin: 4px 0 0; }

/* Mobile: sidebar becomes a top bar with a menu button */
.menu-toggle { display: none; }
@media (max-width: 860px) {
  .frame { grid-template-columns: 1fr; }
  .rail { padding: 12px 16px; gap: 12px; }
  .menu-toggle { display: inline-flex; margin-left: auto; background: none; color: #fff;
    border: 1px solid var(--rail-active); border-radius: var(--radius-small); padding: 6px 10px;
    font: inherit; cursor: pointer; }
  .rail-top { display: flex; align-items: center; }
  .rail:not(.open) .nav, .rail:not(.open) .rail-foot, .rail:not(.open) .workspace { display: none; }
  .main { padding: 20px 16px 40px; }
}
@media (min-width: 861px) { .rail-top { display: block; } }

/* ---- Panels, tables -------------------------------------------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-panel);
  padding: 18px 20px; }
.panel + .panel, .grid-2 + .panel, .panel + .grid-2 { margin-top: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.panel-head h2 { margin-bottom: 10px; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; margin-top: 18px; align-items: start; }
.grid-2 > * { min-width: 0; margin-top: 0 !important; }
.main > * { min-width: 0; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--ink-soft); font-size: 0.85rem;
  padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px 11px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; }
td.actions form { display: inline; }
.muted { color: var(--ink-faint); }
.empty { color: var(--ink-soft); padding: 18px 0 6px; }

/* ---- Status lamps (the signature element) ------------------------- */
.lamp { display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: var(--idle); vertical-align: middle; flex: none; }
.lamp.online { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.lamp.offline { background: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 22%, transparent); }
.lamp.warn { background: var(--warn); }

/* Node strip at the top of the dashboard: one lamp per DNS server */
.node-strip { display: flex; gap: 0; overflow-x: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius-panel); }
.node-chip { display: flex; align-items: center; gap: 12px; padding: 14px 20px; min-width: 230px;
  border-right: 1px solid var(--line); }
.node-chip:last-child { border-right: 0; }
.node-chip .lamp { width: 12px; height: 12px; }
.node-chip b { display: block; font-weight: 600; }
.node-chip small { display: block; color: var(--ink-soft); }
.node-chip .mono { display: block; color: var(--ink-soft); font-size: 0.85rem; }

/* Key numbers: one panel divided into cells (not separate cards) */
.meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-panel);
  overflow: hidden; margin-top: 18px; }
.meter { padding: 16px 20px; background: var(--panel); }
.meter .value { font-size: 1.75rem; font-weight: 600; line-height: 1.1; }
.meter .label { color: var(--ink-soft); font-size: 0.88rem; margin-top: 4px; }
.meter .value.waiting { color: var(--idle); }

/* Placeholder for live charts until the agent sends data */
.awaiting { display: flex; gap: 14px; align-items: center; padding: 18px;
  border: 1px dashed var(--line); border-radius: var(--radius-small); color: var(--ink-soft); }
.awaiting svg { width: 120px; height: 40px; flex: none; color: var(--idle); }

/* Activity list */
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 9px 0;
  border-bottom: 1px solid var(--line); }
.activity li:last-child { border-bottom: 0; }
.activity time { color: var(--ink-faint); font-size: 0.85rem; white-space: nowrap; }
.activity .who { color: var(--ink-soft); font-size: 0.88rem; grid-column: 1 / -1; }

/* ---- Badges ---------------------------------------------------- */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.8rem;
  font-weight: 500; border: 1px solid var(--line); color: var(--ink-soft); white-space: nowrap; }
.badge.role-platform_admin { border-color: var(--aqua); color: var(--aqua); }
.badge.active, .badge.online { border-color: color-mix(in srgb, var(--ok) 50%, transparent); color: var(--ok); }
.badge.locked, .badge.trial { border-color: color-mix(in srgb, var(--warn) 50%, transparent); color: var(--warn); }
.badge.disabled, .badge.suspended, .badge.offline { border-color: color-mix(in srgb, var(--bad) 50%, transparent); color: var(--bad); }
.event-failed { color: var(--bad); }

/* ---- Buttons and forms ----------------------------------------- */
.button { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px;
  border-radius: var(--radius-small); border: 1px solid var(--aqua); background: var(--aqua);
  color: var(--on-aqua); font: 500 0.95rem var(--font); cursor: pointer; text-decoration: none; }
.button:hover { background: var(--aqua-strong); border-color: var(--aqua-strong); color: var(--on-aqua);
  text-decoration: none; }
.button.secondary { background: transparent; color: var(--aqua); }
.button.secondary:hover { background: var(--aqua-wash); color: var(--aqua-strong); }
.button.small { padding: 3px 10px; font-size: 0.85rem; }
.button.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.button.danger:hover { background: var(--bad); color: #fff; }
.button.block { width: 100%; justify-content: center; padding: 11px 16px; }

.form { max-width: 620px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 500; margin-bottom: 5px; }
.field .help { color: var(--ink-faint); font-size: 0.85rem; margin-top: 4px; }
.field input[type=text], .field input[type=password], .field input[type=email],
.field input:not([type]), .field select, .field textarea {
  width: 100%; padding: 9px 11px; font: inherit; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius-small); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--aqua); outline: none;
  box-shadow: 0 0 0 3px var(--aqua-wash); }
.field.check { display: flex; gap: 10px; align-items: flex-start; }
.field.check label { font-weight: 400; margin: 0; }
.field.check input { margin-top: 4px; }
.errorlist { list-style: none; margin: 5px 0 0; padding: 0; color: var(--bad); font-size: 0.88rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 600px) { .field-row { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: 12px; align-items: center; margin-top: 8px; }

/* ---- One-time messages ("User created") ------------------------ */
.messages { list-style: none; margin: 0 0 18px; padding: 0; }
.messages li { padding: 10px 14px; border-radius: var(--radius-small); border: 1px solid var(--line);
  background: var(--panel); border-left: 4px solid var(--aqua); }
.messages li.error { border-left-color: var(--bad); }

/* ---- Login page ------------------------------------------------ */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: var(--rail); color: var(--rail-text); padding: 48px; position: relative;
  overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; }
.login-art .fibres { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.9; }
.login-art > *:not(.fibres) { position: relative; }
.login-art h1 { color: #fff; font-size: 2.3rem; line-height: 1.15; max-width: 14em; margin-top: 28px; }
.login-art .lede { max-width: 32em; margin-top: 14px; font-size: 1.02rem; }
.login-facts { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; max-width: 30em; }
.login-facts li { display: flex; gap: 10px; align-items: baseline; }
.login-facts .lamp { position: relative; top: -1px; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.login-box { width: 100%; max-width: 360px; }
.login-box h2 { font-size: 1.35rem; margin-bottom: 4px; }
.login-box > p { color: var(--ink-soft); margin-bottom: 22px; }
.login-box .note { color: var(--ink-faint); font-size: 0.85rem; margin-top: 18px; }
.form-error { background: color-mix(in srgb, var(--bad) 10%, var(--panel)); color: var(--bad);
  border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); padding: 10px 12px;
  border-radius: var(--radius-small); margin-bottom: 16px; font-size: 0.92rem; }
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-art { padding: 28px 20px; min-height: 0; }
  .login-art h1 { font-size: 1.6rem; margin-top: 18px; }
  .login-facts { display: none; }
}

/* ---- Filters / pagination -------------------------------------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar select { padding: 6px 10px; font: inherit; border: 1px solid var(--line);
  border-radius: var(--radius-small); background: var(--panel); color: var(--ink); }
.pager { display: flex; gap: 12px; align-items: center; margin-top: 14px; color: var(--ink-soft); }

/* ---- Error pages ----------------------------------------------- */
.error-page { max-width: 520px; margin: 12vh auto; padding: 0 20px; }
.error-page .code { font-family: var(--mono); color: var(--aqua); font-size: 1rem; }

/* ---- Small-screen touches ---------------------------------------- */
.nowrap { white-space: nowrap; }
@media (max-width: 600px) {
  /* With two columns, an odd last number fills the whole row (no empty grey cell) */
  .meters { grid-template-columns: 1fr 1fr; }
  .meter:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
