/* ============================================================================
   MAA Failover tab
   ============================================================================
   Everything is namespaced .fx-* and scoped under #failovertab so it cannot
   collide with the Bootstrap and bootstrap-table styling the other nine tabs
   rely on.

   PALETTE - severity ramp, worst first:

     PRIMARY UNAVAILABLE     red      nothing answered; customers failing now
     PRIMARY NO CERT         magenta  answered, but cannot sign for this provider
     FAILED OVER             orange   serving from secondary => MAA is READ-ONLY
     SECONDARY UNAVAILABLE   purple   no impact today, but cannot fail over
     SECONDARY NO CERT       teal     no impact today, and failover would not work
     NO REDUNDANCY           blue     design risk, steady state
     STABLE                  green

   Orange outranks the secondary states deliberately: while failed over MAA runs
   read-only, whereas a dead secondary has no present customer impact.

   Each side reports two faults because they are different problems for different
   people.  Unavailable is an availability fault - nothing answered.  No cert is a
   provisioning fault - the deployment answered promptly and correctly, its
   signing certificate just does not name this provider.  Hue carries the side
   (red family = primary, cool family = secondary) so a glance still separates a
   customer-impacting fault from one nobody has noticed yet.
   ============================================================================ */

/* The tokens live on :root rather than #failovertab because .fx-tip is
   position:fixed and therefore portaled out to <body>; scoped to the tab it
   could not see a single one of them.

   Sizes here are rebased: this tab was already at the density the rest of the
   app is moving toward, so each value is authored as (oldPx / 13.6)rem to hold
   still today while still tracking --ui-density from now on.  See density.css. */
:root {
    --fx-healthy:     #107C10;   /* serving from a healthy primary            */
    --fx-degraded:    #8661C5;   /* secondary unavailable - cannot fail over  */
    --fx-critical:    #B10E1E;   /* primary unavailable - nothing answered    */
    --fx-atrisk:      #0F6CBD;   /* no secondary and no AZ - design risk      */
    --fx-azprotected: #8A8886;   /* no secondary, but AZ covers it            */

    /* The signing-certificate faults.  Each sits immediately beside its own
       side's unavailable colour in the ramp, so it is pulled as far away in hue
       as the palette allows rather than being a shade of it - the lesson
       recorded just below about #C50F1F next to #CA5010 applies here too.  Both
       are dark enough to carry white chip text and to read as a 3px segment.

       The weakest pair in the palette is magenta against purple.  They are never
       adjacent in the ramp (amber sits between the primary block and the
       secondary block), they differ in lightness as well as hue, and they carry
       different labels and different icons.                                   */
    --fx-primary-nocert:   #C239B3;   /* 4.6:1 on white                        */
    --fx-secondary-nocert: #038387;   /* 4.6:1 on white, and dark enough to
                                         read on the pale-green healthy track  */

    /* "Failed over" is not an error - it is the design working - so it must not
       read as a second shade of red.  The old pair (#C50F1F / #CA5010) was 26
       degrees of hue apart at 1.34:1 contrast against each other: no difference
       at all in a 10px pill or a 3px history segment, and none whatsoever under
       red-green colour deficiency, where both collapse to the same brown.  The
       separation is now carried by lightness, which survives both.

       That costs three tokens instead of one, because a fill light enough to
       stand apart from the red is far too pale to be legible as text or as a
       thin stroke on the page:
         (base) text and strokes drawn on the white background
         -fill  filled shapes - chip, history segments, legend swatches
         -ink   text drawn on top of that fill                                */
    --fx-failedover:      #8A5300;   /* 6.3:1 on white                        */
    --fx-failedover-fill: #EAA300;   /* 3.3:1 against --fx-critical           */
    --fx-failedover-ink:  #2B1F00;   /* 6.4:1 on --fx-failedover-fill         */

    --fx-track-ok:    #CDE9CD;   /* history track background = known healthy  */
    --fx-nodata:      #E1DFDD;   /* before we started collecting              */

    --fx-ink:         #201F1E;
    --fx-ink-muted:   #605E5C;
    --fx-ink-faint:   #8A8886;
    --fx-line:        #EDEBE9;
    --fx-line-strong: #D2D0CE;
    --fx-hover:       #F3F9FD;
    --fx-selected:    #DEECF9;
    --fx-head-bg:     #FAF9F8;
    --fx-accent:      #0F6CBD;

    --fx-row-h:       1.912rem;  /* 26px - font + a little spacing, like the other tabs */
    --fx-detail-w:    430px;     /* driven by the drag handle, so it stays px:  the
                                    drag math and the persisted value are both px and
                                    script overwrites this on #failovertab anyway   */
}

#failovertab {
    color: var(--fx-ink);
    font-family: "Segoe UI", "Segoe UI Web (West European)", -apple-system, sans-serif;
}

body.fx-resizing { cursor: col-resize; user-select: none; }

/* Height is set from script to the space actually left below the tab bar, so
   the grid scrolls internally and the toolbar and legend stay pinned. */
#failovertab .fx-shell {
    display: flex;
    flex-direction: column;
    height: 600px;
    border: 1px solid var(--fx-line-strong);
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
}

/* ================================================================
   TOOLBAR
   The toolbar itself is plain Bootstrap / bootstrap-table markup so it matches
   the service tabs exactly; only the filter bar below it is styled here.
   ================================================================ */
#failovertab .fixed-table-toolbar h5 { margin: 0; }
/* bootstrap-table gives .bs-bars, .search and .columns a shared vertical margin
   (restated on the density scale in maainfo.css); the Timeframe group is ours,
   so it has to opt into the same rhythm or it rides up above the search box and
   the buttons.  Only the right margin is set here - top and bottom come from
   the shared toolbar rule so every tab's toolbar stays the same height. */
#failovertab .fx-timeframe {
    display: flex; align-items: center; gap: 0.588rem;
    margin-right: 0.735rem;
}

/* Filter bar - Bootstrap buttons in a wrapping row, boxed like the other
   labelled control groups in the app (border rounded bg-light). */
#failovertab .fx-chipbar {
    display: flex; align-items: center; gap: 0.735rem;
    padding: 0.441rem 0.735rem; margin-bottom: 0.735rem;
}
#failovertab .fx-chiplabel {
    font-size: var(--fs-sm); font-weight: 600; letter-spacing: .04em;
    text-transform: uppercase; color: var(--fx-ink-muted); white-space: nowrap;
}
#failovertab .fx-chips { display: flex; gap: 0.441rem; flex-wrap: wrap; }
/* Chips are grouped by the question they answer - live status, the selected
   window, static configuration - so a hairline and a micro-label separate the
   clusters.  Each group is its own flex box, which also stops one from being
   split across a wrap. */
#failovertab .fx-chipgroup {
    display: inline-flex; align-items: center; gap: 0.441rem;
    padding-left: 0.735rem; border-left: 1px solid var(--fx-line);
}
#failovertab .fx-chipgroup:first-child { padding-left: 0; border-left: 0; }
/* Deliberately quieter than the FILTER label beside it: these name a group, they
   are not a control, and they must not compete with the chips they head. */
#failovertab .fx-chipgrouplabel {
    font-size: var(--fs-xs); font-weight: 600; letter-spacing: .04em;
    text-transform: uppercase; color: var(--fx-ink-faint);
    white-space: nowrap; cursor: default;
}
/* Age of the data on screen, pushed to the far end of the filter bar.  Refresh
   re-reads the poller's cache rather than probing, so this is the only thing
   that tells the user how current "current" is. */
#failovertab .fx-asof {
    margin-left: auto; white-space: nowrap; cursor: default;
    font-size: var(--fs-sm); color: var(--fx-ink-muted);
}
/* Past a few sweeps old the reading is evidence of a fault, not just an older
   number, so it stops looking like the rest of the muted furniture.  Amber
   rather than red: the data is stale, which is not the same as the service
   being unhealthy, and red here would compete with the status chips. */
#failovertab .fx-asof.fx-stale { color: var(--fx-failedover); font-weight: 600; }
#failovertab .fx-chip { display: inline-flex; align-items: center; gap: 0.441rem; white-space: nowrap; }
/* The hairline is what lets the pale swatches - amber, healthy track, no-data -
   keep their shape on a near-white background.  Repeated on the other two colour
   keys below so all three read the same. */
#failovertab .fx-chip .fx-dot {
    width: 0.662rem; height: 0.662rem; border-radius: 50%;
    background: var(--c, #8A8886); flex: 0 0 auto;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14);
}
/* Outline buttons flip their text to white when active, so the count badge has
   to invert with them or it disappears into the fill. */
#failovertab .fx-chip .fx-badge {
    background: var(--fx-line); color: var(--fx-ink);
    font-size: var(--fs-sm); font-weight: 700; padding: .15em .5em;
}
#failovertab .fx-chip.active .fx-badge { background: #fff; color: var(--fx-ink); }

/* ================================================================
   BODY = scrolling table + drag handle + docked detail pane
   ================================================================ */
#failovertab .fx-body { display: flex; flex: 1 1 auto; min-height: 0; }
#failovertab .fx-tablewrap { flex: 1 1 auto; overflow: auto; min-width: 0; }

#failovertab table.fx-table {
    width: 100%; border-collapse: collapse; table-layout: fixed;
    font-size: var(--fs-md); margin: 0;
}
#failovertab table.fx-table thead th {
    position: sticky; top: 0; z-index: 3;
    background: var(--fx-head-bg);
    border-bottom: 1px solid var(--fx-line-strong);
    border-top: 0;
    font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
    color: var(--fx-ink-muted);
    padding: 0.368rem 0.588rem; text-align: left; white-space: nowrap;
    user-select: none;
    /* table-layout:fixed keeps the column at its assigned width, but nowrap header
       text still paints past it and makes the wrapper scroll horizontally. */
    overflow: hidden; text-overflow: ellipsis;
}
/* The history track is the only elastic column, and it is deliberately allowed to
   shrink rather than forcing a horizontal scrollbar: scrolling would push the
   right-hand "now" edge - the part that matters most - out of view.  When the
   column does get narrow the middle axis tick is dropped so the remaining two
   labels never collide.  (The container lives on the axis div, not the th -
   table cells cannot be size containers.) */
#failovertab .fx-axis { container-type: inline-size; }
/* rem in a container query resolves against :root, so this breakpoint tracks
   --ui-density along with the axis labels it is protecting.  16.912rem = the
   230px this used to be. */
@container (max-width: 16.912rem) {
    #failovertab .fx-axis span:nth-child(2) { display: none; }
}
/* Every column sorts.  The neutral caret only appears on hover so six carets do
   not compete with the data; the active one is always shown. */
#failovertab table.fx-table thead th.fx-sortable { cursor: pointer; }
#failovertab table.fx-table thead th.fx-sortable:hover { color: var(--fx-ink); background: #F3F2F1; }
#failovertab table.fx-table thead th .fx-caret { font-size: var(--fs-2xs); margin-left: 0.294rem; opacity: 0; }
#failovertab table.fx-table thead th.fx-sortable:hover .fx-caret { opacity: .5; }
#failovertab table.fx-table thead th.fx-sorted { color: var(--fx-ink); box-shadow: inset 0 -2px 0 var(--fx-accent); }
#failovertab table.fx-table thead th.fx-sorted .fx-caret { opacity: 1; color: var(--fx-accent); }
/* With several sort levels active the carets alone do not say which column
   wins, so each participating header also carries its 1-based priority. */
#failovertab table.fx-table thead th .fx-rank {
    display: inline-block; margin-left: 0.221rem; padding: 0 0.221rem;
    font-size: var(--fs-2xs); line-height: 0.882rem; border-radius: 6px;
    background: var(--fx-accent); color: #fff; vertical-align: 1px;
}
/* "Sort by" / "Then by" gutter in the Multiple Sort dialog. */
#sortModal_fxtable .fx-sortlabel { white-space: nowrap; vertical-align: middle; }
#failovertab table.fx-table thead th.fx-r { text-align: right; }

#failovertab table.fx-table tbody td {
    height: var(--fx-row-h);
    padding: 0 0.588rem;
    border-bottom: 1px solid var(--fx-line);
    border-top: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    vertical-align: middle;
}
#failovertab table.fx-table tbody tr { cursor: pointer; }
#failovertab table.fx-table tbody tr:hover { background: var(--fx-hover); }
#failovertab table.fx-table tbody tr.fx-sel { background: var(--fx-selected); }
#failovertab table.fx-table tbody tr.fx-sel td:first-child { box-shadow: inset 3px 0 0 var(--fx-accent); }

#failovertab tr.fx-envrow td {
    background: #fff; border-bottom: 1px solid var(--fx-line-strong);
    padding-top: 0.735rem;
    font-size: var(--fs-xs); font-weight: 700; letter-spacing: .05em;
    color: var(--fx-ink-muted); text-transform: uppercase;
}
#failovertab tr.fx-envrow { cursor: default; }
#failovertab tr.fx-envrow:hover { background: #fff; }
#failovertab tr.fx-envrow .fx-envcount {
    font-weight: 400; color: var(--fx-ink-faint); text-transform: none; letter-spacing: 0;
}

#failovertab .fx-mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: var(--fs-sm); }
#failovertab .fx-muted { color: var(--fx-ink-muted); }
#failovertab .fx-faint { color: var(--fx-ink-faint); }
#failovertab .fx-r { text-align: right; }
#failovertab .fx-c { text-align: center; }

#failovertab .fx-t-true   { color: var(--fx-healthy);    font-weight: 600; }
#failovertab .fx-t-false  { color: var(--fx-critical);   font-weight: 700; }
#failovertab .fx-t-warn   { color: var(--fx-degraded);   font-weight: 700; }
#failovertab .fx-t-pcert  { color: var(--fx-primary-nocert);   font-weight: 700; }
#failovertab .fx-t-scert  { color: var(--fx-secondary-nocert); font-weight: 700; }
#failovertab .fx-t-fo     { color: var(--fx-failedover); font-weight: 700; }
#failovertab .fx-t-na     { color: var(--fx-ink-faint); }
#failovertab .fx-t-narisk { color: var(--fx-atrisk); }

/* ---------------- status chip ----------------
   Actionable states are filled; steady states are outlined, so the only
   saturated things on a healthy screen are the ones worth looking at.  The AZ
   suffix distinguishes zone-redundant "stable" from single-zone "stable"
   without adding a whole column. */
#failovertab .fx-state {
    display: inline-flex; align-items: center; gap: 0.368rem;
    font-size: var(--fs-xs); font-weight: 700; letter-spacing: .02em;
    line-height: 1; padding: 0.221rem 0.515rem 0.221rem 0.368rem; border-radius: 10px;
    color: #fff; background: var(--s);
}
#failovertab .fx-state.fx-quiet {
    background: #fff; color: var(--s); border: 1px solid var(--s); padding: 0.147rem 0.441rem 0.147rem 0.294rem;
}
#failovertab .fx-s-healthy     { --s: var(--fx-healthy); }
#failovertab .fx-s-stable      { --s: var(--fx-healthy); }
#failovertab .fx-s-stableaz    { --s: var(--fx-healthy); }
#failovertab .fx-s-failedover  { --s: var(--fx-failedover-fill); }
#failovertab .fx-s-primaryunavailable   { --s: var(--fx-critical); }
#failovertab .fx-s-primarynocert        { --s: var(--fx-primary-nocert); }
#failovertab .fx-s-secondaryunavailable { --s: var(--fx-degraded); }
#failovertab .fx-s-secondarynocert      { --s: var(--fx-secondary-nocert); }
#failovertab .fx-s-atrisk      { --s: var(--fx-atrisk); }
#failovertab .fx-s-azprotected { --s: var(--fx-azprotected); }

/* The one filled chip that is light instead of dark - which is the entire point
   of it - so it takes dark text, plus a hairline to give the pill an edge it
   would otherwise lack against the white row.  box-shadow rather than border:
   a border would make this chip 2px wider than every other one. */
#failovertab .fx-state.fx-s-failedover:not(.fx-quiet) {
    color: var(--fx-failedover-ink);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .22);
}

/* AZ / no-AZ suffix inside the chip */
#failovertab .fx-sfx {
    font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .04em;
    padding: 1px 0.294rem; border-radius: 6px; margin-left: 1px;
}
#failovertab .fx-sfx.fx-azyes { background: rgba(16,124,16,.13); color: var(--fx-healthy); }
#failovertab .fx-sfx.fx-azno  { background: rgba(15,108,189,.13); color: var(--fx-atrisk); }

/* Marks a row whose failover state could not be observed because DNS failed. */
#failovertab .fx-unknown { color: var(--fx-failedover); font-weight: 700; margin-left: 0.294rem; }

/* ---------------- single history track ---------------- */
#failovertab .fx-hist {
    position: relative; height: 0.882rem; border-radius: 2px; overflow: hidden; background: var(--fx-track-ok);
}
#failovertab .fx-hist .fx-nod  { position: absolute; top: 0; bottom: 0; background: var(--fx-nodata); }
#failovertab .fx-hist .fx-seg2 { position: absolute; top: 0; bottom: 0; min-width: 0.221rem; background: var(--c); }
#failovertab .fx-hist .fx-seg2.fx-ongoing {
    background-image: repeating-linear-gradient(45deg,
        rgba(255,255,255,.55) 0 2px, rgba(255,255,255,0) 2px 5px);
}
#failovertab .fx-histcell { position: relative; padding-right: 0.882rem !important; }
#failovertab .fx-axis {
    display: flex; justify-content: space-between; font-size: var(--fs-2xs);
    font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--fx-ink-faint);
}

/* ================================================================
   RESIZE HANDLE + DETAIL PANE
   ================================================================ */
#failovertab .fx-resizer {
    flex: 0 0 5px; width: 5px; cursor: col-resize; background: var(--fx-line-strong);
    display: none; position: relative;
}
#failovertab .fx-resizer::after {
    content: ""; position: absolute; top: 50%; left: 1px;
    width: 3px; height: 34px; margin-top: -17px; border-radius: 2px; background: var(--fx-ink-faint);
}
#failovertab .fx-resizer:hover, #failovertab .fx-resizer.fx-dragging { background: var(--fx-accent); }
#failovertab .fx-resizer:hover::after, #failovertab .fx-resizer.fx-dragging::after { background: #fff; }
body.fx-detailopen #failovertab .fx-resizer { display: block; }

/* No scrollbar-gutter here on purpose.  Reserving the gutter did make the
   timeline's width measurement invariant, but a reserved gutter is space no
   child can paint into, so the sticky header's background stopped short of the
   right edge and left a white stripe down the pane whenever it was not actually
   scrolling.  The measurement problem is handled in failover.js instead, by
   observing the timeline host and redrawing when its real width changes. */
#failovertab .fx-detail {
    flex: 0 0 var(--fx-detail-w); width: var(--fx-detail-w);
    background: #fff; overflow-y: auto; overflow-x: hidden; display: none;
}
#failovertab .fx-detail.fx-open { display: block; }
#failovertab .fx-dhead {
    position: sticky; top: 0; z-index: 2; background: var(--fx-head-bg);
    border-bottom: 1px solid var(--fx-line-strong);
    padding: 0.588rem 0.882rem; display: flex; align-items: flex-start; gap: 0.588rem;
}
#failovertab .fx-dhead h2 { font-size: var(--fs-lg); font-weight: 600; margin: 0; }
#failovertab .fx-dhead .fx-ddns {
    font-size: var(--fs-sm); color: var(--fx-ink-faint); font-family: Consolas, monospace; word-break: break-all;
}
#failovertab .fx-dclose {
    margin-left: auto; border: 0; background: transparent; font-size: var(--fs-lg);
    color: var(--fx-ink-muted); cursor: pointer; line-height: 1; padding: 0.147rem 0.294rem;
}
#failovertab .fx-dclose:hover { color: var(--fx-ink); }
#failovertab .fx-dsec { padding: 0.735rem 0.882rem; border-bottom: 1px solid var(--fx-line); }
#failovertab .fx-dsec h3 {
    font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    color: var(--fx-ink-muted); margin: 0 0 0.441rem;
}
#failovertab table.fx-facts { width: 100%; font-size: var(--fs-md); border-collapse: collapse; }
#failovertab table.fx-facts td { padding: 0.221rem 0; vertical-align: top; border: 0; }
#failovertab table.fx-facts td:first-child { color: var(--fx-ink-muted); width: 9.706rem; }
#failovertab table.fx-eps { width: 100%; font-size: var(--fs-sm); border-collapse: collapse; }
#failovertab table.fx-eps th {
    text-align: left; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .03em;
    color: var(--fx-ink-muted); border-bottom: 1px solid var(--fx-line); padding: 0.221rem 0.294rem 0.221rem 0;
}
#failovertab table.fx-eps td {
    padding: 0.221rem 0.294rem 0.221rem 0; border-bottom: 1px solid var(--fx-line); white-space: nowrap;
}
#failovertab .fx-kind { display: inline-flex; align-items: center; gap: 0.294rem; font-weight: 600; }
#failovertab .fx-kind .fx-dot {
    width: 0.515rem; height: 0.515rem; border-radius: 50%; background: var(--c);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14);
}

#failovertab .fx-empty { padding: 2.059rem 0.882rem; text-align: center; color: var(--fx-ink-faint); font-size: var(--fs-md); }

#failovertab .fx-legend {
    display: flex; gap: 0.882rem; flex-wrap: wrap; font-size: var(--fs-sm); color: var(--fx-ink-muted);
    padding: 0.441rem 0.882rem; border-top: 1px solid var(--fx-line-strong); background: var(--fx-head-bg);
    flex: 0 0 auto; align-items: center;
}
/* Every legend entry carries a tooltip explaining how the condition is
   detected. The cursor is deliberately left alone - a help cursor over a
   six-item colour key reads as though something is broken. */
#failovertab .fx-legend .fx-li { display: inline-flex; align-items: center; gap: 0.368rem; }
#failovertab .fx-legend .fx-sw {
    width: 1.324rem; height: 0.662rem; border-radius: 2px; background: var(--c);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14);
}
#failovertab .fx-legend .fx-sw.fx-hatch {
    background-image: repeating-linear-gradient(45deg,
        rgba(255,255,255,.6) 0 2px, rgba(255,255,255,0) 2px 5px);
}
#failovertab .fx-warn {
    margin-left: auto; font-weight: 600; color: var(--fx-failedover); cursor: default;
}

/* The tooltip is position:fixed so it must live outside #failovertab's stacking
   context; it is therefore the one rule here not scoped to the tab. */
.fx-tip {
    position: fixed; z-index: 9999; pointer-events: none;
    background: #201F1E; color: #fff; font-size: var(--fs-sm); line-height: 1.45;
    padding: 0.441rem 0.662rem; border-radius: 4px; max-width: 25rem;
    box-shadow: 0 4px 14px rgba(0,0,0,.28); opacity: 0; transition: opacity .08s;
    font-family: "Segoe UI", "Segoe UI Web (West European)", -apple-system, sans-serif;
}
.fx-tip.fx-show { opacity: 1; }
.fx-tip .fx-tk { color: #C8C6C4; }

@keyframes fxpulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
/* The pulse hangs off the tab root, not the rows: the table is re-rendered the
   moment a sweep starts, which would otherwise throw away a per-row class. */
#failovertab.fx-loading #fx-tbody tr[data-dns] td { animation: fxpulse .5s ease-in-out infinite; }
#failovertab tr.fx-justupdated { background: #FFF4CE !important; transition: background 1.2s; }
