/* =====================================================================
   DNS Operations Console — theme.css
   A deliberate "operations console" identity:
   dark command rail, calm light workspace, DNS data set in monospace.
   Works alongside the Tailwind CDN already loaded on each page.
   ===================================================================== */

:root {
    --ink:        #0b1120;   /* command rail background        */
    --ink-soft:   #131c30;   /* raised surfaces on the rail    */
    --ink-line:   #1e293b;   /* hairlines on the rail          */

    --surface:    #f6f8fb;   /* workspace background           */
    --card:       #ffffff;   /* cards / panels                 */
    --line:       #e4e9f2;   /* borders                        */

    --text:       #1a2233;   /* primary text                   */
    --muted:      #64748b;   /* secondary text                 */
    --faint:      #94a3b8;   /* tertiary text                  */

    --brand:      #3b6ff6;   /* primary action (operational)   */
    --brand-700:  #2c54c9;
    --brand-tint: #eaf0ff;

    --ok:         #1fa971;   /* healthy                        */
    --ok-tint:    #e4f6ee;
    --warn:       #d98a1f;   /* warning                        */
    --warn-tint:  #fdf2e0;
    --bad:        #e5484d;   /* error / down                   */
    --bad-tint:   #fdeaea;

    --radius:     14px;
    --radius-sm:  10px;
    --shadow:     0 1px 2px rgba(16,24,40,.04), 0 6px 20px rgba(16,24,40,.06);
    --shadow-lg:  0 12px 40px rgba(16,24,40,.12);

    --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono",
            "Fira Code", Menlo, Consolas, monospace;
    --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
            Roboto, Helvetica, Arial, sans-serif;
}

/* ---- base ---------------------------------------------------------- */
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--sans);
    color: var(--text);
    background: var(--surface) !important;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
.app-shell { display: flex; min-height: 100vh; }
.app-main  { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-body  { flex: 1; padding: 28px clamp(16px, 3vw, 40px); }

h1, h2, h3 { letter-spacing: -.01em; }

/* DNS data, IPs, tokens — the signature */
.mono, code, .record-value, .token { font-family: var(--mono); }

.rail {
    width: 256px;
    background: var(--ink);
    color: #cdd6e6;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
    flex-shrink: 0;
    z-index: 50;
    overflow: hidden;
}
.rail-brand {
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    padding: 26px 20px 22px; text-align: center;
    border-bottom: 1px solid var(--ink-line);
    flex-shrink: 0;
}
.rail-brand img { width: 150px; max-width: 85%; height: auto; border-radius: 12px; }
.rail-brand .brand-text { font-weight: 700; color: #fff; font-size: 16px; line-height: 1.25; }
.rail-brand .brand-sub  { font-size: 11px; color: #6b7a96; letter-spacing: .08em; text-transform: uppercase; margin-top: 2px; }

.rail-nav { padding: 14px 12px; overflow-y: auto; flex: 1; min-height: 0; }
.rail-group-label {
    font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase;
    color: #5b6b88; padding: 16px 12px 6px;
}
.rail-link {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 12px; margin: 2px 0;
    border-radius: 9px; color: #b6c1d6;
    font-size: 14px; font-weight: 500;
    text-decoration: none;
    transition: background .12s, color .12s;
}
.rail-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.rail-link:hover { background: var(--ink-soft); color: #fff; }
.rail-link.active { background: var(--brand); color: #fff; }
.rail-link.active svg { opacity: 1; }
.rail-foot { padding: 12px; border-top: 1px solid var(--ink-line); }

/* ---- topbar -------------------------------------------------------- */
.topbar {
    height: 60px; background: var(--card);
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 14px;
    padding: 0 clamp(16px, 3vw, 28px);
    position: sticky; top: 0; z-index: 40;
}
.topbar h1 { font-size: 17px; font-weight: 650; margin: 0; }
.topbar .spacer { flex: 1; }
.topbar .user-chip {
    display: flex; align-items: center; gap: 9px;
    font-size: 13px; color: var(--muted);
    text-decoration: none;
    cursor: pointer;
    border-radius: 8px;
    padding: 4px 8px;
    transition: background .12s;
}
.topbar .user-chip:hover { background: var(--line); }
.topbar .avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--brand-tint); color: var(--brand-700);
    display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.hamburger {
    display: none; background: none; border: none; cursor: pointer;
    color: var(--text); padding: 6px;
}

/* ---- cards / panels ------------------------------------------------ */
.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 20px 22px; }
.card-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 22px; border-bottom: 1px solid var(--line);
}
.card-head h2 { font-size: 15px; font-weight: 650; margin: 0; }

.page-title { font-size: 24px; font-weight: 700; margin: 0 0 4px; }
.page-sub   { color: var(--muted); font-size: 14px; margin: 0 0 22px; }

/* ---- stat / telemetry cards --------------------------------------- */
.stat-grid {
    display: grid; gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    margin-bottom: 22px;
}
.stat {
    background: var(--card); border: 1px solid var(--line);
    border-left: 3px solid var(--brand);
    border-radius: var(--radius); padding: 18px 20px;
    box-shadow: var(--shadow);
}
.stat.ok   { border-left-color: var(--ok); }
.stat.warn { border-left-color: var(--warn); }
.stat.bad  { border-left-color: var(--bad); }
.stat .label {
    font-size: 12px; color: var(--muted); font-weight: 600;
    letter-spacing: .02em; display: flex; align-items: center; gap: 7px;
}
.stat .label svg { width: 15px; height: 15px; opacity: .6; }
.stat .value { font-size: 30px; font-weight: 750; margin-top: 8px; line-height: 1; }
.stat .meta  { font-size: 12px; color: var(--faint); margin-top: 7px; }

/* ---- pills / badges ------------------------------------------------ */
.pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600; line-height: 1.4;
}
.pill::before { content:""; width:6px; height:6px; border-radius:50%; background: currentColor; }
.pill.ok   { background: var(--ok-tint);   color: var(--ok); }
.pill.warn { background: var(--warn-tint); color: var(--warn); }
.pill.bad  { background: var(--bad-tint);  color: var(--bad); }
.pill.info { background: var(--brand-tint);color: var(--brand-700); }
.pill.mute { background: #eef1f6; color: var(--muted); }
.pill.plain::before { display:none; }

/* ---- buttons ------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 16px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600; border: 1px solid transparent;
    cursor: pointer; text-decoration: none; transition: background .12s, border-color .12s, opacity .12s;
    line-height: 1.2;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-700); }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: #f3f6fb; }
.btn-danger { background: #fff; color: var(--bad); border-color: #f3c9cb; }
.btn-danger:hover { background: var(--bad-tint); }
.btn-sm { padding: 6px 11px; font-size: 13px; }

/* ---- forms --------------------------------------------------------- */
.field { margin-bottom: 16px; }
.field label { display:block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.field .hint { font-size: 12px; color: var(--faint); margin-top: 5px; }
.input, select.input, textarea.input {
    width: 100%; padding: 10px 12px; font-size: 14px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: #fff; color: var(--text); font-family: var(--sans);
    transition: border-color .12s, box-shadow .12s;
}
.input:focus, select.input:focus, textarea.input:focus {
    outline: none; border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(59,111,246,.15);
}
.input.mono { font-family: var(--mono); font-size: 13px; }

/* ---- tables -------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* NB: Tailwind's CDN ships a `.grid { display:grid }` utility that hijacks
   our table class — force real table semantics back with higher specificity. */
table.grid { display: table; width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid thead { display: table-header-group; }
table.grid tbody { display: table-row-group; }
table.grid tr    { display: table-row; }
table.grid th,
table.grid td    { display: table-cell; }
table.grid th {
    text-align: left; font-size: 11.5px; letter-spacing: .04em;
    text-transform: uppercase; color: var(--muted); font-weight: 600;
    padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.grid td { padding: 12px 14px; border-bottom: 1px solid #eef1f6; vertical-align: middle; }
table.grid tr:last-child td { border-bottom: none; }
table.grid tbody tr:hover { background: #f9fbfe; }

/* ---- alerts -------------------------------------------------------- */
.alert { border-radius: var(--radius-sm); padding: 12px 16px; font-size: 14px; margin-bottom: 18px; border: 1px solid; }
.alert.ok  { background: var(--ok-tint);  border-color:#bfe6d4; color:#157a52; }
.alert.bad { background: var(--bad-tint); border-color:#f3c9cb; color:#b3373b; }
.alert.info{ background: var(--brand-tint);border-color:#cdddff; color: var(--brand-700); }

/* ---- misc ---------------------------------------------------------- */
.scrim {
    display: none; position: fixed; inset: 0; background: rgba(11,17,32,.5);
    z-index: 45;
}
.muted { color: var(--muted); }
.empty {
    text-align: center; padding: 40px 20px; color: var(--faint);
}
.empty svg { width: 36px; height: 36px; opacity: .4; margin: 0 auto 10px; }

/* ---- responsive: drawer ------------------------------------------- */
@media (max-width: 900px) {
    .rail {
        position: fixed; left: 0; top: 0; height: 100vh;
        transform: translateX(-100%); transition: transform .22s ease;
        box-shadow: var(--shadow-lg);
    }
    body.nav-open .rail { transform: translateX(0); }
    body.nav-open .scrim { display: block; }
    .hamburger { display: inline-flex; }
    .app-body { padding: 18px 16px; }
    .stat .value { font-size: 26px; }
}

/* =====================================================================
   DARK MODE — activated by adding .dark to <html>.
   Preference lives in localStorage('dnsops_theme'); a tiny inline script
   in every <head> applies the class before first paint (no flash).
   The command rail is already dark and stays untouched.
   ===================================================================== */

html.dark {
    --surface:    #0e1526;
    --card:       #161e30;
    --line:       #263149;

    --text:       #dbe4f5;
    --muted:      #8b9bbd;
    --faint:      #6b7a96;

    --brand-tint: #1c2a4d;
    --ok-tint:    #11342a;
    --warn-tint:  #3a2c12;
    --bad-tint:   #3d1d1f;

    --shadow:     0 1px 2px rgba(0,0,0,.25), 0 6px 20px rgba(0,0,0,.25);
    --shadow-lg:  0 12px 40px rgba(0,0,0,.5);
    color-scheme: dark;
}

/* ---- components that hardcode light colors ------------------------- */
html.dark .pill.ok   { color: #4ed4a2; }
html.dark .pill.warn { color: #f2b25c; }
html.dark .pill.bad  { color: #ff8a8e; }
html.dark .pill.info { color: #8fb0ff; }
html.dark .pill.mute { background: #222c44; color: var(--muted); }

html.dark .btn-ghost  { background: #1b2438; color: var(--text); border-color: var(--line); }
html.dark .btn-ghost:hover { background: #222d46; }
html.dark .btn-danger { background: #1b2438; color: #ff8a8e; border-color: #51262a; }
html.dark .btn-danger:hover { background: var(--bad-tint); }

html.dark .input,
html.dark select.input,
html.dark textarea.input {
    background: #10182b; color: var(--text); border-color: var(--line);
}
html.dark .input::placeholder,
html.dark textarea.input::placeholder { color: #5d6c8c; }

html.dark table.grid td { border-bottom-color: #1f2940; }
html.dark table.grid tbody tr:hover { background: #1a2338; }

html.dark .alert.ok  { background: var(--ok-tint);   border-color:#1d4a3a; color:#5fd9ab; }
html.dark .alert.bad { background: var(--bad-tint);  border-color:#5a2c30; color:#ff9c9f; }
html.dark .alert.info{ background: var(--brand-tint);border-color:#2c4070; color:#9db9ff; }

html.dark .topbar .avatar { background: #21305a; color: #9db9ff; }

/* ---- legacy Tailwind pages (utility-class skin) -------------------- */
html.dark .bg-slate-100 { background-color: var(--surface) !important; }
html.dark .bg-white     { background-color: var(--card) !important; }
html.dark .bg-slate-200 { background-color: #1a2336 !important; }
html.dark .bg-slate-50  { background-color: #131b2d !important; }
html.dark .shadow       { box-shadow: var(--shadow) !important; }

html.dark .text-slate-900,
html.dark .text-slate-800,
html.dark .text-slate-700 { color: #cbd7ec !important; }
html.dark .text-slate-600 { color: var(--muted) !important; }
html.dark .text-slate-500 { color: var(--muted) !important; }
html.dark .text-slate-400,
html.dark .text-slate-300 { color: var(--faint) !important; }
html.dark body { color: var(--text); }

html.dark .border            { border-color: var(--line) !important; }
html.dark .border-t          { border-top-color: var(--line) !important; }
html.dark .border-b          { border-bottom-color: var(--line) !important; }
html.dark .border-slate-100,
html.dark .border-slate-200  { border-color: var(--line) !important; }

/* status banners + bulk bar on legacy pages */
html.dark .bg-green-50,
html.dark .bg-green-100  { background-color: #11342a !important; }
html.dark .border-green-200,
html.dark .border-green-300 { border-color: #1d4a3a !important; }
html.dark .text-green-800,
html.dark .text-green-700 { color: #5fd9ab !important; }

html.dark .bg-red-50,
html.dark .bg-red-100  { background-color: #3d1d1f !important; }
html.dark .border-red-200,
html.dark .border-red-300 { border-color: #5a2c30 !important; }
html.dark .text-red-800,
html.dark .text-red-700 { color: #ff9c9f !important; }

html.dark .bg-blue-50 { background-color: #1c2a4d !important; }
html.dark .border-blue-200 { border-color: #2c4070 !important; }
html.dark .text-blue-900 { color: #9db9ff !important; }
html.dark .text-blue-700 { color: #8fb0ff !important; }

/* keep solid action buttons readable (they stay branded) */
html.dark .bg-blue-900,
html.dark .bg-slate-700,
html.dark .bg-indigo-700,
html.dark .bg-red-700 { color: #fff !important; }

/* ---- inline-styled details (diff boxes, chart tracks, hairlines) --- */
html.dark [style*="#f6f8fb"] {
    background-color: #10182b !important;
    border-color: var(--line) !important;
}
html.dark [style*="#eef2f9"] { background-color: #222c44 !important; }
html.dark [style*="#eef1f6"] { border-color: #1f2940 !important; }
html.dark [style*="#e3e8f0"] { border-color: var(--line) !important; }

/* server-rendered SVG charts: axis labels, values, donut center */
html.dark svg text { fill: #9fb0d0 !important; }

/* ---- theme toggle button in the rail ------------------------------- */
.theme-toggle {
    display: flex; align-items: center; gap: 11px;
    width: 100%; padding: 9px 12px; margin: 0 0 4px;
    border-radius: 9px; border: none; cursor: pointer;
    background: transparent; color: #b6c1d6;
    font-size: 14px; font-weight: 500; font-family: var(--sans);
    text-align: left; transition: background .12s, color .12s;
}
.theme-toggle:hover { background: var(--ink-soft); color: #fff; }
.theme-toggle svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.theme-toggle .tt-sun  { display: none; }
.theme-toggle .tt-moon { display: block; }
html.dark .theme-toggle .tt-sun  { display: block; }
html.dark .theme-toggle .tt-moon { display: none; }

/* ---- notes & reminders --------------------------------------------- */
.note-card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 16px 18px; margin-bottom: 12px;
}
.note-card.note-done { opacity: .62; }
.note-content { font-size: 14.5px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.note-done .note-content { text-decoration: line-through; }
.note-meta {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    font-size: 12px; color: var(--faint); margin-top: 10px;
}
.note-actions { display: flex; gap: 8px; margin-left: auto; }

/* =====================================================================
   DARK MODE — round 2 polish
   1) Readable links: domain links use inline color:var(--brand-700),
      which is too dark on a dark background.
   2) Native form fields on legacy pages (no .input class) fell back to
      the browser's dark-grey defaults — give them the same look as the
      styled .input fields everywhere.
   ===================================================================== */

/* 1) links rendered with the inline brand color (domain names etc.) */
html.dark [style*="--brand-700"] { color: #8fb0ff !important; }
html.dark .bg-blue-100 { background-color: #1c2a4d !important; }

/* 2) every native input/select/textarea matches the .input look */
html.dark input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="reset"]),
html.dark select,
html.dark textarea {
    background-color: #10182b !important;
    color: var(--text) !important;
    border-color: var(--line) !important;
}
html.dark input::placeholder,
html.dark textarea::placeholder { color: #5d6c8c !important; }

/* keep the blue focus highlight working */
html.dark input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="reset"]):focus,
html.dark select:focus,
html.dark textarea:focus {
    border-color: var(--brand) !important;
}


/* =====================================================================
   DARK MODE — round 3
   JS-toggled panels ("Show values", "What's inside") lose their hex
   inline styles when the browser re-serializes them as rgb(), which
   broke the attribute-selector overrides. They now use a real class.
   ===================================================================== */

.soft-panel {
    background: #f6f8fb;
    border: 1px solid #e3e8f0;
    border-radius: 10px;
}
html.dark .soft-panel {
    background: #10182b;
    border-color: var(--line);
}

/* insurance: match the rgb() serialization of the old hex values too */
html.dark [style*="rgb(246, 248, 251)"] {
    background-color: #10182b !important;
    border-color: var(--line) !important;
}
html.dark [style*="rgb(238, 242, 249)"] { background-color: #222c44 !important; }
html.dark [style*="rgb(227, 232, 240)"] { border-color: var(--line) !important; }

/* yellow/amber accents on legacy pages (status badges etc.) */
html.dark .bg-yellow-100 { background-color: #3a2c12 !important; }
html.dark .border-yellow-300 { border-color: #5c451d !important; }
html.dark .text-yellow-800,
html.dark .text-yellow-700 { color: #f2b25c !important; }

