/* Ansible managed
 *
 * Foxden UI theme variables — GENERATED from the `foxden_theme` ansible var
 * (inventories/<env>/group_vars/all/theme.yml). DO NOT EDIT ON THE SERVER; edit
 * theme.yml and re-run the foxden_apis role.
 *
 * :root holds the light palette (the default cascade). [data-theme="dark"] on
 * <html> overrides the same variables with the dark palette. A no-flash inline
 * script in each layout's <head> sets data-theme from localStorage before first
 * paint; the header toggle flips it and persists the choice.
 *
 * Every colour in the reservation-api UI resolves to one of these var(--fx-*)
 * tokens, so this file is the single knob for the whole site's colour scheme.
 */
:root {
  --fx-bg: #f5f7fa;
  --fx-surface: #ffffff;
  --fx-surface-2: #f3f5f7;
  --fx-surface-accent: #e6f8ff;
  --fx-text: #1d252c;
  --fx-text-muted: #666465;
  --fx-text-inverse: #ffffff;
  --fx-border: #d4dce2;
  --fx-border-strong: #bbbbbb;
  --fx-brand: #00af9a;
  --fx-brand-hover: #009684;
  --fx-brand-contrast: #ffffff;
  --fx-accent-blue: #006e96;
  --fx-accent-blue-dark: #003447;
  --fx-success: #28a745;
  --fx-success-bg: #eaf7ea;
  --fx-danger: #dc3545;
  --fx-danger-soft: #c98392;
  --fx-danger-bg: #f8d7da;
  --fx-warning: #ff9300;
  --fx-warning-bg: #fff8dc;
  --fx-info: #16ade3;
  --fx-info-bg: #e6f8ff;
  --fx-overlay: rgba(0,0,0,0.5);
  --fx-shadow: rgba(0,0,0,0.1);
  --fx-sidebar-bg: #7386d5;
  --fx-sidebar-header: #6d7fcc;
  --fx-sidebar-border: #47748b;
  --fx-banner-bg: #1a1a1a;
  --fx-banner-text: #cccccc;
  --fx-surface-inverse: #1e1e1e;
}

html[data-theme="dark"] {
  --fx-bg: #14181c;
  --fx-surface: #1e262d;
  --fx-surface-2: #262f37;
  --fx-surface-accent: #133038;
  --fx-text: #e6e9ec;
  --fx-text-muted: #9aa4ac;
  --fx-text-inverse: #ffffff;
  --fx-border: #333d45;
  --fx-border-strong: #4a555e;
  --fx-brand: #1fc9b2;
  --fx-brand-hover: #33d6c0;
  --fx-brand-contrast: #06231f;
  --fx-accent-blue: #2ca8d4;
  --fx-accent-blue-dark: #7dc3e8;
  --fx-success: #34c759;
  --fx-success-bg: #16321c;
  --fx-danger: #ff5b52;
  --fx-danger-soft: #c98392;
  --fx-danger-bg: #3a1a1d;
  --fx-warning: #ffb84d;
  --fx-warning-bg: #3a3213;
  --fx-info: #34c3ee;
  --fx-info-bg: #133038;
  --fx-overlay: rgba(0,0,0,0.7);
  --fx-shadow: rgba(0,0,0,0.5);
  --fx-sidebar-bg: #2a3550;
  --fx-sidebar-header: #222b42;
  --fx-sidebar-border: #3a4a63;
  --fx-banner-bg: #0d0d0d;
  --fx-banner-text: #c9cbce;
  --fx-surface-inverse: #12171c;
}

/* Honour an OS-level dark preference only when the user has not explicitly
 * chosen (no data-theme attribute set yet). Once they toggle, the attribute
 * wins over this block. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    --fx-bg: #14181c;
    --fx-surface: #1e262d;
    --fx-surface-2: #262f37;
    --fx-surface-accent: #133038;
    --fx-text: #e6e9ec;
    --fx-text-muted: #9aa4ac;
    --fx-text-inverse: #ffffff;
    --fx-border: #333d45;
    --fx-border-strong: #4a555e;
    --fx-brand: #1fc9b2;
    --fx-brand-hover: #33d6c0;
    --fx-brand-contrast: #06231f;
    --fx-accent-blue: #2ca8d4;
    --fx-accent-blue-dark: #7dc3e8;
    --fx-success: #34c759;
    --fx-success-bg: #16321c;
    --fx-danger: #ff5b52;
    --fx-danger-soft: #c98392;
    --fx-danger-bg: #3a1a1d;
    --fx-warning: #ffb84d;
    --fx-warning-bg: #3a3213;
    --fx-info: #34c3ee;
    --fx-info-bg: #133038;
    --fx-overlay: rgba(0,0,0,0.7);
    --fx-shadow: rgba(0,0,0,0.5);
    --fx-sidebar-bg: #2a3550;
    --fx-sidebar-header: #222b42;
    --fx-sidebar-border: #3a4a63;
    --fx-banner-bg: #0d0d0d;
    --fx-banner-text: #c9cbce;
    --fx-surface-inverse: #12171c;
  }
}

/* Smooth the switch so toggling does not hard-cut. */
body {
  background: var(--fx-bg);
  color: var(--fx-text);
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* ───────────────────────────────────────────────────────────────────────────
 * Bootstrap 4 dark override layer.
 *
 * The token migration recolours every literal in OUR CSS/templates, but the
 * Bootstrap 4 framework paints the navbar, cards, tables, form controls,
 * dropdowns, modals and default text with its own hard-coded light values
 * (#fff, #f8f9fa, #212529 …). Those never reference var(--fx-*), so in dark
 * mode they stay light — a white navbar and black-on-dark text. This block
 * repoints the Bootstrap components people actually see at the dark tokens.
 * It is scoped to html[data-theme="dark"] so light mode is untouched, and it
 * only applies when a dark palette is active. Utilities (.bg-light, .text-dark,
 * .border*) use !important in Bootstrap, so we match with !important to win;
 * component classes need no !important (the attribute selector out-specifies).
 * ─────────────────────────────────────────────────────────────────────────── */
/* Surfaces / backgrounds */
html[data-theme="dark"] .bg-light { background-color: var(--fx-surface) !important; }
html[data-theme="dark"] .bg-white { background-color: var(--fx-surface) !important; }

/* Navbar (navbar-light bg-light) */
html[data-theme="dark"] .navbar-light { background-color: var(--fx-surface) !important; border-color: var(--fx-border); }
html[data-theme="dark"] .navbar-light .navbar-brand,
html[data-theme="dark"] .navbar-light .navbar-nav .nav-link,
html[data-theme="dark"] .navbar-light .navbar-text { color: var(--fx-text); }
html[data-theme="dark"] .navbar-light .navbar-nav .nav-link:hover,
html[data-theme="dark"] .navbar-light .navbar-nav .nav-link:focus,
html[data-theme="dark"] .navbar-light .navbar-nav .active > .nav-link,
html[data-theme="dark"] .navbar-light .navbar-nav .nav-link.active { color: var(--fx-brand); }
html[data-theme="dark"] .navbar-light .navbar-toggler { border-color: var(--fx-border); }

/* Cards / list groups / modals / popovers / dropdowns */
html[data-theme="dark"] .card { background-color: var(--fx-surface); color: var(--fx-text); border-color: var(--fx-border); }
html[data-theme="dark"] .card-header,
html[data-theme="dark"] .card-footer { background-color: var(--fx-surface-2); border-color: var(--fx-border); }
html[data-theme="dark"] .list-group-item { background-color: var(--fx-surface); color: var(--fx-text); border-color: var(--fx-border); }
html[data-theme="dark"] .list-group-item-action { color: var(--fx-text); }
html[data-theme="dark"] .list-group-item-action:hover,
html[data-theme="dark"] .list-group-item-action:focus { background-color: var(--fx-surface-2); color: var(--fx-text); }
html[data-theme="dark"] .list-group-item.active { background-color: var(--fx-brand); border-color: var(--fx-brand); color: var(--fx-brand-contrast); }
html[data-theme="dark"] .modal-content { background-color: var(--fx-surface); color: var(--fx-text); border-color: var(--fx-border); }
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer { border-color: var(--fx-border); }
html[data-theme="dark"] .dropdown-menu { background-color: var(--fx-surface); color: var(--fx-text); border-color: var(--fx-border); }
html[data-theme="dark"] .dropdown-item { color: var(--fx-text); }
html[data-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:focus { background-color: var(--fx-surface-2); color: var(--fx-text); }
html[data-theme="dark"] .dropdown-divider { border-color: var(--fx-border); }
html[data-theme="dark"] .popover { background-color: var(--fx-surface); border-color: var(--fx-border); }
html[data-theme="dark"] .popover-body { color: var(--fx-text); }
html[data-theme="dark"] .popover-header { background-color: var(--fx-surface-2); color: var(--fx-text); border-color: var(--fx-border); }

/* Deep-linked domains row (domains.html adds .table-info): BS4's light-cyan bg
   is light-on-light in dark mode. Match the themed .active highlight. */
html[data-theme="dark"] .table-info,
html[data-theme="dark"] .table-info > td,
html[data-theme="dark"] .table-info > th { background-color: var(--fx-brand) !important; color: var(--fx-brand-contrast) !important; }

/* Forms */
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .custom-select,
html[data-theme="dark"] .custom-file-label,
html[data-theme="dark"] input.form-control,
html[data-theme="dark"] textarea.form-control,
html[data-theme="dark"] select.form-control { background-color: var(--fx-surface-2); color: var(--fx-text); border-color: var(--fx-border); }
html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .custom-select:focus { background-color: var(--fx-surface-2); color: var(--fx-text); border-color: var(--fx-border-strong); }
html[data-theme="dark"] .form-control::placeholder { color: var(--fx-text-muted); }
html[data-theme="dark"] .form-control:disabled,
html[data-theme="dark"] .form-control[readonly] { background-color: var(--fx-surface); }
html[data-theme="dark"] .input-group-text { background-color: var(--fx-surface-2); color: var(--fx-text); border-color: var(--fx-border); }
/* Bare inputs without .form-control (e.g. the custom email-reminder hours box,
 * class .numericlite) keep the browser-default white field. Repoint them onto
 * the same surface tokens as the framework inputs. */
html[data-theme="dark"] input.numericlite { background-color: var(--fx-surface-2); color: var(--fx-text); border: 1px solid var(--fx-border); }
html[data-theme="dark"] input.numericlite:focus { border-color: var(--fx-border-strong); outline: none; }

/* Tables */
html[data-theme="dark"] .table { color: var(--fx-text); }
html[data-theme="dark"] .table td,
html[data-theme="dark"] .table th,
html[data-theme="dark"] .table thead th,
html[data-theme="dark"] .table-bordered,
html[data-theme="dark"] .table-bordered td,
html[data-theme="dark"] .table-bordered th { border-color: var(--fx-border); }
html[data-theme="dark"] .table-hover tbody tr:hover { background-color: var(--fx-surface-2); color: var(--fx-text); }

/* Tabs (Create Lab / Group Labs / Backups) */
html[data-theme="dark"] .nav-tabs { border-color: var(--fx-border); }
html[data-theme="dark"] .nav-tabs .nav-link { color: var(--fx-text-muted); }
html[data-theme="dark"] .nav-tabs .nav-link:hover { border-color: var(--fx-border); }
html[data-theme="dark"] .nav-tabs .nav-link.active { background-color: var(--fx-surface); color: var(--fx-text); border-color: var(--fx-border) var(--fx-border) var(--fx-surface); }

/* Pagination */
html[data-theme="dark"] .page-link { background-color: var(--fx-surface); color: var(--fx-brand); border-color: var(--fx-border); }
html[data-theme="dark"] .page-item.disabled .page-link { background-color: var(--fx-surface); color: var(--fx-text-muted); border-color: var(--fx-border); }
html[data-theme="dark"] .page-item.active .page-link { background-color: var(--fx-brand); border-color: var(--fx-brand); color: var(--fx-brand-contrast); }

/* Text + border utilities (Bootstrap sets these !important) */
html[data-theme="dark"] .text-dark { color: var(--fx-text) !important; }
html[data-theme="dark"] .text-body { color: var(--fx-text); }
html[data-theme="dark"] .text-muted,
html[data-theme="dark"] .text-black-50 { color: var(--fx-text-muted) !important; }
html[data-theme="dark"] .border,
html[data-theme="dark"] .border-top,
html[data-theme="dark"] .border-bottom,
html[data-theme="dark"] .border-left,
html[data-theme="dark"] .border-right,
html[data-theme="dark"] .border-secondary,
html[data-theme="dark"] .border-light { border-color: var(--fx-border) !important; }

/* Misc chrome */
html[data-theme="dark"] hr { border-color: var(--fx-border); }
html[data-theme="dark"] .close { color: var(--fx-text); text-shadow: none; }
html[data-theme="dark"] .breadcrumb { background-color: var(--fx-surface-2); }
html[data-theme="dark"] .dataTables_wrapper .dataTables_length,
html[data-theme="dark"] .dataTables_wrapper .dataTables_filter,
html[data-theme="dark"] .dataTables_wrapper .dataTables_info,
html[data-theme="dark"] .dataTables_wrapper .dataTables_processing,
html[data-theme="dark"] .dataTables_wrapper .dataTables_paginate { color: var(--fx-text); }

/* Links: Bootstrap darkens links on hover (#0056b3), which disappears on a dark
 * background. Lift hover/focus to a light blue instead. (Navbar link hover is
 * handled above with higher specificity, so it stays brand-coloured.) */
html[data-theme="dark"] a:hover,
html[data-theme="dark"] a:focus { color: var(--fx-accent-blue-dark); }

/* "Powered by Everfox" brand lockup. The wordmark is a dark grayscale PNG that
 * vanishes on dark, and the muted label token is too dim — invert the logo and
 * brighten the label. Overrides the elements' inline styles, hence !important. */
html[data-theme="dark"] .fx-powered-by { color: var(--fx-text) !important; }
html[data-theme="dark"] .fx-powered-logo { filter: grayscale(1) invert(1) !important; opacity: 0.85 !important; }

/* Select2. The "Pretend as User" picker uses the default theme; the create-lab
 * pickers use theme:'bootstrap' but no bootstrap-theme CSS is loaded, so they
 * fall back to the generic select2 chrome. Target the GENERIC select2 classes
 * (not a theme-qualified selector) so every instance is covered regardless of
 * theme, with !important on the surfaces to guarantee the override. */
html[data-theme="dark"] .select2-dropdown { background-color: var(--fx-surface) !important; border-color: var(--fx-border) !important; }
html[data-theme="dark"] .select2-selection { background-color: var(--fx-surface-2) !important; border-color: var(--fx-border) !important; }
html[data-theme="dark"] .select2-container--disabled .select2-selection { background-color: var(--fx-surface) !important; }
html[data-theme="dark"] .select2-selection__rendered { color: var(--fx-text) !important; }
html[data-theme="dark"] .select2-selection__placeholder { color: var(--fx-text-muted) !important; }
html[data-theme="dark"] .select2-selection__arrow b { border-color: var(--fx-text-muted) transparent transparent transparent !important; }
html[data-theme="dark"] .select2-selection__choice { background-color: var(--fx-surface) !important; border-color: var(--fx-border) !important; color: var(--fx-text) !important; }
html[data-theme="dark"] .select2-search__field { background-color: var(--fx-surface-2) !important; color: var(--fx-text) !important; border-color: var(--fx-border) !important; }
html[data-theme="dark"] .select2-results__option { color: var(--fx-text); }
html[data-theme="dark"] .select2-results__option[aria-selected=true] { background-color: var(--fx-surface-2); }
html[data-theme="dark"] .select2-results__option--highlighted[aria-selected] { background-color: var(--fx-accent-blue) !important; color: var(--fx-text-inverse) !important; }
html[data-theme="dark"] .select2-results__message { color: var(--fx-text-muted); }

/* Neutral buttons (Action dropdown, Close, pagination-style controls). The
 * Bootstrap btn-secondary grey looks muddy on dark; use a surface-based button
 * that sits in the palette and lightens on hover. */
html[data-theme="dark"] .btn-secondary { background-color: var(--fx-surface-2); border-color: var(--fx-border-strong); color: var(--fx-text); }
html[data-theme="dark"] .btn-secondary:hover,
html[data-theme="dark"] .btn-secondary:focus,
html[data-theme="dark"] .btn-secondary:not(:disabled):not(.disabled):active,
html[data-theme="dark"] .btn-secondary:not(:disabled):not(.disabled).active,
html[data-theme="dark"] .show > .btn-secondary.dropdown-toggle { background-color: var(--fx-border-strong); border-color: var(--fx-border-strong); color: var(--fx-text); box-shadow: none; }

/* Light/outline buttons (Reload, New User, Back to Foxden, Export, Clear …).
 * .btn-light is pure white in Bootstrap and blazes on a dark page; the outline
 * variants inherit that light border/text. Repoint them onto the surface tokens
 * so they read as recessed neutral buttons that lighten on hover. The child
 * .text-secondary utility on these buttons keeps its own colour, so lift it to
 * the readable text token too. */
html[data-theme="dark"] .btn-light,
html[data-theme="dark"] .btn-outline-light,
html[data-theme="dark"] .btn-outline-secondary { background-color: var(--fx-surface-2); border-color: var(--fx-border-strong); color: var(--fx-text); }
html[data-theme="dark"] .btn-light .text-secondary,
html[data-theme="dark"] .btn-light.text-secondary,
html[data-theme="dark"] .btn-outline-secondary.text-secondary { color: var(--fx-text) !important; }
html[data-theme="dark"] .btn-light:hover,
html[data-theme="dark"] .btn-light:focus,
html[data-theme="dark"] .btn-light:not(:disabled):not(.disabled):active,
html[data-theme="dark"] .btn-light:not(:disabled):not(.disabled).active,
html[data-theme="dark"] .btn-outline-light:hover,
html[data-theme="dark"] .btn-outline-secondary:hover,
html[data-theme="dark"] .show > .btn-light.dropdown-toggle { background-color: var(--fx-border-strong); border-color: var(--fx-border-strong); color: var(--fx-text); box-shadow: none; }

/* Alerts (oversubscription warning, form errors …). Bootstrap's contextual
 * alerts use pale pastel backgrounds with dark text that glare on a dark page.
 * The palette carries dark-tinted *-bg tokens plus the matching accent colour,
 * so repaint each variant onto its own dark tint with a bright accent text and
 * border. <b>/<strong> inside inherits, so no per-child rule needed. */
html[data-theme="dark"] .alert-danger { background-color: var(--fx-danger-bg); color: var(--fx-danger); border-color: var(--fx-danger); }
html[data-theme="dark"] .alert-warning { background-color: var(--fx-warning-bg); color: var(--fx-warning); border-color: var(--fx-warning); }
html[data-theme="dark"] .alert-success { background-color: var(--fx-success-bg); color: var(--fx-success); border-color: var(--fx-success); }
html[data-theme="dark"] .alert-info,
html[data-theme="dark"] .alert-primary { background-color: var(--fx-info-bg); color: var(--fx-info); border-color: var(--fx-info); }
html[data-theme="dark"] .alert-secondary,
html[data-theme="dark"] .alert-light { background-color: var(--fx-surface-2); color: var(--fx-text); border-color: var(--fx-border); }
html[data-theme="dark"] .alert-danger .alert-link { color: var(--fx-danger); }
html[data-theme="dark"] .alert-warning .alert-link { color: var(--fx-warning); }

/* daterangepicker (lab Duration calendar popup). Third-party widget with its
 * own hard-coded white calendar, light grey off-days and #357ebd selection —
 * none reference our tokens, so it stays a white box on the dark form. Repoint
 * the popup, calendar cells, range/selection states, month-nav chevrons and the
 * hour/minute selects onto the palette. */
html[data-theme="dark"] .daterangepicker { background-color: var(--fx-surface); border-color: var(--fx-border); color: var(--fx-text); }
html[data-theme="dark"] .daterangepicker:after { border-bottom-color: var(--fx-surface); }
html[data-theme="dark"] .daterangepicker:before { border-bottom-color: var(--fx-border); }
html[data-theme="dark"] .daterangepicker .calendar-table { background-color: var(--fx-surface); border-color: var(--fx-surface); }
html[data-theme="dark"] .daterangepicker td,
html[data-theme="dark"] .daterangepicker th { color: var(--fx-text); }
html[data-theme="dark"] .daterangepicker td.available:hover,
html[data-theme="dark"] .daterangepicker th.available:hover { background-color: var(--fx-surface-2); }
html[data-theme="dark"] .daterangepicker td.off,
html[data-theme="dark"] .daterangepicker td.off.in-range,
html[data-theme="dark"] .daterangepicker td.off.start-date,
html[data-theme="dark"] .daterangepicker td.off.end-date { background-color: var(--fx-surface); color: var(--fx-text-muted); }
html[data-theme="dark"] .daterangepicker td.in-range { background-color: var(--fx-surface-2); color: var(--fx-text); }
html[data-theme="dark"] .daterangepicker td.active,
html[data-theme="dark"] .daterangepicker td.active:hover { background-color: var(--fx-brand); color: var(--fx-brand-contrast); }
html[data-theme="dark"] .daterangepicker td.disabled,
html[data-theme="dark"] .daterangepicker option.disabled { color: var(--fx-text-muted); }
html[data-theme="dark"] .daterangepicker .calendar-table .next span,
html[data-theme="dark"] .daterangepicker .calendar-table .prev span { border-color: var(--fx-text); }
html[data-theme="dark"] .daterangepicker select.hourselect,
html[data-theme="dark"] .daterangepicker select.minuteselect,
html[data-theme="dark"] .daterangepicker select.secondselect,
html[data-theme="dark"] .daterangepicker select.ampmselect,
html[data-theme="dark"] .daterangepicker select.monthselect,
html[data-theme="dark"] .daterangepicker select.yearselect { background-color: var(--fx-surface-2); color: var(--fx-text); border-color: var(--fx-border); }
html[data-theme="dark"] .daterangepicker .drp-buttons { border-top-color: var(--fx-border); }
html[data-theme="dark"] .daterangepicker .drp-selected { color: var(--fx-text-muted); }

/* Inbound Rules (DNAT) modal fields. The rows are built in JS with bespoke
 * classes (.sourceip, .fp-label, .dport, .tport, .octet, .fp-select) rather
 * than .form-control, so they miss the form override above and render as bare
 * white browser inputs. Repoint them onto the surface tokens; disabled cells
 * (Dest/Target Port until a protocol is chosen) drop to the dimmer surface. */
html[data-theme="dark"] .sourceip,
html[data-theme="dark"] .fp-label,
html[data-theme="dark"] .dport,
html[data-theme="dark"] .tport,
html[data-theme="dark"] .octet,
html[data-theme="dark"] .fp-select { background-color: var(--fx-surface-2); color: var(--fx-text); border: 1px solid var(--fx-border); }
html[data-theme="dark"] .sourceip:focus,
html[data-theme="dark"] .fp-label:focus,
html[data-theme="dark"] .dport:focus,
html[data-theme="dark"] .tport:focus,
html[data-theme="dark"] .octet:focus,
html[data-theme="dark"] .fp-select:focus { border-color: var(--fx-border-strong); outline: none; }
html[data-theme="dark"] .sourceip:disabled,
html[data-theme="dark"] .fp-label:disabled,
html[data-theme="dark"] .dport:disabled,
html[data-theme="dark"] .tport:disabled,
html[data-theme="dark"] .octet:disabled { background-color: var(--fx-surface); color: var(--fx-text-muted); }
html[data-theme="dark"] .fp-select option { background-color: var(--fx-surface-2); color: var(--fx-text); }
