/* The Alerts panel (#alerts-panel, its Current and History tabs and their cards), reimagined in the buoy modal's
   language (buoy_modal.css). Look only: what it shows and does is app.js's, unchanged. Every rule is scoped by
   #alerts-panel, over the base rules in app.css, which stay as they were.

   - Where: docked at the right as its siblings are (the buoy modal, the farm card, the Ocean stations panel: 100 px
     down, 16 px in), sized to what it holds up to 16 px off the foot, and sliding in from the right. Non-blocking, as
     before (its overlay stays hidden): the map keeps the pointer.
   - Look: the panels' glass (app.css --bc-glass-*); an Oxanium title over a quiet meta line (how many are active, its
     dot in the highest one's colour, as the bell's badge); the close a quiet 28 px icon button; Current / History as
     the buoy modal's segmented control; an active alert as a reading tile, its severity in a glowing bar on its left
     edge (as the DO Forecast's red and amber rows) and in a pill, the readings that crossed its rules in a dark well;
     History as one quiet list, its rows' bars unlit (it's past); the empty states centred, each with its icon in a
     tinted chip (as the buoy modal's "No alerts for … yet."); "Create a new alert" the brand's blue button.
   Severity colours (--tone, --ink): info sky, monitoring cyan, warning amber, critical and severe red (severe's bar
   pulsing); an acknowledged alert's bar unlit, its edge dimmed. The pills: warning, critical and severe deepened for
   their white text (#8f6d15, #b91c1c), as the farm card's; info and monitoring tinted. */

/* ── Where: docked at the right, sized to its content ─────────────────────────────────────────────────────── */
#alerts-panel {
    --ap-gap: 18px;
    top: 100px;
    right: 16px;
    bottom: auto;
    width: 400px;
    min-width: 0;
    max-width: calc(100vw - 32px);
    height: auto;
    max-height: calc(100vh - 116px);
    border: var(--bc-glass-border);
    border-radius: 18px;
    box-shadow: var(--bc-glass-edge), 0 18px 44px rgba(0, 8, 22, 0.55);
    color: #e2e8f0;
    font-family: Manrope, system-ui, sans-serif;
    /* Closed: off past the right edge. app.js shows it, then adds .open (and hides it 250 ms after taking .open off). */
    transform: translateX(calc(100% + 24px));
    opacity: 0;
    transition: transform 0.25s cubic-bezier(0.2, 0.7, 0.3, 1), opacity 0.2s ease;
}
#alerts-panel.open { right: 16px; transform: none; opacity: 1; }

/* Its buttons: none of app.css's global button (navy fill, 18 px padding, 15 px type). :where() keeps this reset
   below each button's own rules here. */
#alerts-panel :where(button) {
    isolation: auto;
    overflow: visible;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    line-height: 1.2;
    text-shadow: none;
}
#alerts-panel :where(button):focus-visible { outline: 2px solid #2e8eff; outline-offset: 2px; }

/* ── The header: the title over its meta line; close at its right ──────────────────────────────────────── */
#alerts-panel .ai-panel-header {
    align-items: flex-start;
    gap: 12px;
    padding: 16px var(--ap-gap) 0;
    border-bottom: 0;
    background: transparent;
}
#alerts-panel .alerts-panel-heading { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
#alerts-panel .ai-panel-title {
    font-family: Oxanium, Manrope, sans-serif;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.3px;
    line-height: 1.2;
    text-transform: none;
    color: #f8fafc;
}
/* The meta line: "5 active · 2 acknowledged", after a dot in the highest one's colour (--sev, from app.js, the bell
   badge's); "All clear" after a quiet blue one. */
#alerts-panel .alerts-panel-meta {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    color: rgba(203, 213, 225, 0.72);
    font-variant-numeric: tabular-nums;
}
#alerts-panel .alerts-panel-meta:empty { display: none; }
#alerts-panel .alerts-panel-meta::before {
    content: "";
    flex: none;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--sev, #f59e0b);
    box-shadow: 0 0 8px var(--sev, #f59e0b);
}
#alerts-panel .alerts-panel-meta.is-clear::before { background: #60a5fa; box-shadow: none; }

/* The close: the date card's icon button (a quiet 28 px square). */
#alerts-panel .ai-panel-header .bc-btn-group { flex: none; margin: -2px -6px 0 0; background: none; border: 0; border-radius: 0; }
#alerts-panel .ai-panel-header .bc-btn-group__btn {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: transparent;
    color: rgba(226, 232, 240, 0.65);
    transition: background-color 0.15s ease, color 0.15s ease;
}
#alerts-panel .ai-panel-header .bc-btn-group__btn:hover { background: rgba(255, 255, 255, 0.1); color: #ffffff; }
#alerts-panel .ai-panel-header .bc-btn-group__btn i { font-size: 13px; }

/* ── Current / History: the buoy modal's segmented control, its two halves even ─────────────────────────── */
#alerts-panel .alerts-panel-tabs {
    flex: none;
    gap: 2px;
    margin: 14px var(--ap-gap) 0;
    padding: 4px;
    border: 0;
    border-radius: 12px;
    background: rgba(2, 10, 24, 0.5);
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.12);
}
#alerts-panel .alerts-tab {
    flex: 1 1 0;
    margin: 0;
    padding: 7px 12px 8px;
    border: 0;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.2px;
    text-transform: none;
    color: rgba(226, 232, 240, 0.62);
    transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
#alerts-panel .alerts-tab:hover { background: rgba(255, 255, 255, 0.06); color: #f8fafc; }
#alerts-panel .alerts-tab.active { background: rgba(46, 142, 255, 0.22); box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.5); color: #ffffff; }
#alerts-panel .alerts-tab:focus-visible { outline-offset: 1px; }

/* ── The body: the glass shows through; it scrolls between the tabs and the foot, the cards fading out at its top
   and foot as they pass (the fades lie over its padding, so a list that fits is never touched by them) ─────── */
#alerts-panel .alerts-panel-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 14px var(--ap-gap) 14px;
    background: transparent;
    -webkit-mask-image: linear-gradient(180deg, transparent, #000 14px, #000 calc(100% - 14px), transparent);
    mask-image: linear-gradient(180deg, transparent, #000 14px, #000 calc(100% - 14px), transparent);
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}
#alerts-panel .alerts-panel-body::-webkit-scrollbar { width: 4px; }
#alerts-panel .alerts-panel-body::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 2px; }

/* ── An alert: a reading tile, its severity on its left edge and in its pill ───────────────────────────── */
#alerts-panel .alert-trigger-card {
    --tone: 148, 163, 184;   /* its severity's colour (below) */
    --ink: #e2e8f0;          /* that colour, light, for a reading in it */
    position: relative;
    margin: 0 0 10px;
    padding: 13px 14px 14px 16px;
    border: 0;
    border-radius: 14px;
    background:
        radial-gradient(120% 90% at 0% 0%, rgba(var(--tone), 0.09), transparent 60%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.12);
    cursor: pointer;   /* to its buoy (app.js) */
    transition: box-shadow 0.2s ease;
}
#alerts-panel .alert-trigger-card:last-child { margin-bottom: 0; }
#alerts-panel .alert-trigger-card:hover { box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.4); }
#alerts-panel .alert-trigger-card.sev-info       { --tone: 56, 189, 248;  --ink: #7dd3fc; }
#alerts-panel .alert-trigger-card.sev-monitoring { --tone: 34, 211, 238;  --ink: #67e8f9; }
#alerts-panel .alert-trigger-card.sev-warning    { --tone: 251, 191, 36;  --ink: #fcd34d; }
#alerts-panel .alert-trigger-card.sev-critical,
#alerts-panel .alert-trigger-card.sev-severe     { --tone: 239, 68, 68;   --ink: #fca5a5; }
/* Its edge: a bar in its colour, glowing; severe's pulsing. */
#alerts-panel .alert-trigger-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 14px;
    bottom: 14px;
    width: 3px;
    border-radius: 0 2px 2px 0;
    background: rgb(var(--tone));
    box-shadow: 0 0 12px rgba(var(--tone), 0.65);
}
#alerts-panel .alert-trigger-card.sev-severe::before { animation: ap-severe 2.4s ease-in-out infinite; }
@keyframes ap-severe {
    0%, 100% { box-shadow: 0 0 10px rgba(239, 68, 68, 0.6); }
    50%      { box-shadow: 0 0 18px rgba(239, 68, 68, 1), 0 0 4px rgba(254, 202, 202, 0.8); }
}
/* Acknowledged: seen, so its edge goes quiet (unlit, dimmed) and its wash with it. */
#alerts-panel .alert-trigger-card:has(.atc-ack)::before { opacity: 0.55; box-shadow: none; animation: none; }
#alerts-panel .alert-trigger-card:has(.atc-ack) { background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.012)); }

/* The head: its name (Oxanium, up to two lines) and its severity pill at the right. */
#alerts-panel .atc-head { align-items: flex-start; flex-wrap: nowrap; gap: 10px; margin: 0; }
#alerts-panel .atc-name {
    flex: 1 1 auto;
    min-width: 0;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    font-family: Oxanium, Manrope, sans-serif;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.3px;
    line-height: 1.25;
    color: #f8fafc;
    overflow-wrap: anywhere;
}
/* The pill, in sentence case ("SEVERE" from app.js reads "Severe"). */
#alerts-panel .atc-sev {
    order: 2;
    flex: none;
    margin-top: 1px;
    padding: 3px 9px 4px;
    border-radius: 999px;
    background: rgba(var(--tone), 0.16);
    box-shadow: inset 0 0 0 1px rgba(var(--tone), 0.32);
    color: var(--ink);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.3px;
    line-height: 1.2;
    text-transform: lowercase;
    white-space: nowrap;
}
#alerts-panel .atc-sev::first-letter { text-transform: uppercase; }
#alerts-panel .sev-warning .atc-sev,
#alerts-panel .sev-critical .atc-sev,
#alerts-panel .sev-severe .atc-sev { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22); color: #f8fafc; }
#alerts-panel .sev-warning .atc-sev { background: #8f6d15; }
#alerts-panel .sev-critical .atc-sev,
#alerts-panel .sev-severe .atc-sev { background: #b91c1c; }
#alerts-panel .sev-severe .atc-sev { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 0 0 1px rgba(248, 113, 113, 0.55), 0 0 12px rgba(239, 68, 68, 0.5); }

/* The meta line: its buoy · when, then Acknowledged in a quiet pill. */
#alerts-panel .atc-meta,
#alerts-panel .compact .atc-time {
    margin: 5px 0 0;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
    color: rgba(203, 213, 225, 0.72);
    font-variant-numeric: tabular-nums;
}
#alerts-panel .atc-buoy { font-size: inherit; color: rgba(226, 232, 240, 0.9); }
#alerts-panel .atc-time { font-size: inherit; color: inherit; }
#alerts-panel .atc-ack {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    vertical-align: 1px;
    white-space: nowrap;
    padding: 2px 8px 3px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.14);
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.26);
    color: #cbd5e1;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.3px;
    line-height: 1.2;
}
#alerts-panel .atc-ack i { font-size: 9px; color: #93c5fd; }

/* The readings that crossed its rules: a dark well (the comms list's), a row each: the measurement over its rule,
   the reading in Oxanium at the right, in the severity's colour. */
#alerts-panel .atc-rules {
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
    border-radius: 10px;
    background: rgba(2, 10, 24, 0.45);
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.12);
}
#alerts-panel .atc-rules li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "name value" "when value";
    align-items: center;
    column-gap: 12px;
    row-gap: 2px;
    padding: 8px 12px 9px;
}
#alerts-panel .atc-rules li + li { border-top: 1px solid rgba(148, 163, 184, 0.1); }
#alerts-panel .atc-rule-name {
    grid-area: name;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 600;
    color: rgba(226, 232, 240, 0.86);
}
#alerts-panel .atc-rule-when {
    grid-area: when;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 600;
    color: rgba(148, 163, 184, 0.85);
}
#alerts-panel .atc-rule-when::before { content: "Rule: "; color: rgba(148, 163, 184, 0.6); }
#alerts-panel .atc-rule-value {
    grid-area: value;
    font-family: Oxanium, Manrope, sans-serif;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.2px;
    line-height: 1.1;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
#alerts-panel .atc-rule-uom { margin-left: 3px; font-family: Manrope, sans-serif; font-size: 11px; font-weight: 600; letter-spacing: 0; color: rgba(148, 163, 184, 0.9); }
#alerts-panel .atc-rule-uom:empty { display: none; }

/* A maintenance alert's procedure: the same well, its wrench in maintenance's violet chip. */
#alerts-panel .atc-procedure {
    margin: 12px 0 0;
    padding: 8px 12px 8px 8px;
    border: 0;
    border-radius: 10px;
    background: rgba(2, 10, 24, 0.45);
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.12);
}
#alerts-panel .atc-procedure-label { gap: 10px; font-size: 12px; font-weight: 600; line-height: 1.35; color: rgba(226, 232, 240, 0.86); }
#alerts-panel .atc-procedure-label i {
    flex: none;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: rgba(168, 85, 247, 0.16);
    box-shadow: inset 0 0 0 1px rgba(192, 132, 252, 0.3);
    color: #c4b5fd;
    font-size: 11px;
}

/* Acknowledge: at the card's foot, right; a quiet glass button in the brand's blue (the panel's one loud blue is
   "Create a new alert"). Its width held while it spins. */
#alerts-panel .atc-clear.blue-pill-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: max-content;
    min-width: 118px;
    height: 30px;
    margin: 12px 0 0 auto;
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    background: rgba(46, 142, 255, 0.16);
    box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.4);
    color: #dbeafe;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.2px;
    text-shadow: none;
    transition: background-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}
#alerts-panel .atc-clear.blue-pill-button:hover { background: rgba(46, 142, 255, 0.3); box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.7); color: #ffffff; }
#alerts-panel .atc-clear.blue-pill-button:active { background: rgba(46, 142, 255, 0.36); }
#alerts-panel .atc-clear .text { display: inline-flex; align-items: center; gap: 6px; }
#alerts-panel .atc-clear .text i { font-size: 10px; }
#alerts-panel .atc-clear.atc-clear--loading { opacity: 0.75; cursor: default; }

/* ── History: one quiet list (it's past), a row per alert, its bar unlit ───────────────────────────────── */
#alerts-panel .alerts-history-bar { align-items: center; justify-content: flex-end; margin: -2px 0 10px; }
/* Clear history: a quiet text button, red on hover (it deletes). */
#alerts-panel .alerts-clear-history.blue-pill-button {
    display: inline-flex;
    align-items: center;
    height: 26px;
    padding: 0 8px;
    margin-right: -8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    box-shadow: none;
    color: rgba(226, 232, 240, 0.65);
    font-size: 12px;
    font-weight: 700;
    text-shadow: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}
#alerts-panel .alerts-clear-history.blue-pill-button:hover { background: rgba(239, 68, 68, 0.14); color: #fca5a5; }
#alerts-panel .alerts-clear-history.blue-pill-button:disabled { background: transparent; color: rgba(226, 232, 240, 0.5); cursor: default; }
#alerts-panel .alerts-clear-history .text { display: inline-flex; align-items: center; gap: 6px; }
#alerts-panel .alerts-clear-history i { margin: 0; font-size: 11px; }

#alerts-panel .alert-trigger-card.compact {
    margin: 0;
    padding: 11px 14px 12px 16px;
    border-radius: 0;
    background: rgba(255, 255, 255, 0.025);
}
#alerts-panel .alert-trigger-card.compact + .alert-trigger-card.compact { border-top: 1px solid rgba(148, 163, 184, 0.1); }
#alerts-panel .alerts-history-bar + .alert-trigger-card.compact { border-top-left-radius: 14px; border-top-right-radius: 14px; }
#alerts-panel .alert-trigger-card.compact:last-child { border-bottom-left-radius: 14px; border-bottom-right-radius: 14px; }
/* The list's ring, drawn round all its rows: each row rings its sides, the first its top too, the last its foot. */
#alerts-panel .alert-trigger-card.compact { --ring: rgba(148, 163, 184, 0.12); box-shadow: inset 1px 0 0 var(--ring), inset -1px 0 0 var(--ring); }
#alerts-panel .alerts-history-bar + .alert-trigger-card.compact { box-shadow: inset 1px 0 0 var(--ring), inset -1px 0 0 var(--ring), inset 0 1px 0 var(--ring); }
#alerts-panel .alert-trigger-card.compact:last-child { box-shadow: inset 1px 0 0 var(--ring), inset -1px 0 0 var(--ring), inset 0 -1px 0 var(--ring); }
#alerts-panel .alerts-history-bar + .alert-trigger-card.compact:last-child { box-shadow: inset 0 0 0 1px var(--ring); }
#alerts-panel .alert-trigger-card.compact:hover { background: rgba(96, 165, 250, 0.08); }
#alerts-panel .alert-trigger-card.compact::before { top: 12px; bottom: 12px; opacity: 0.5; box-shadow: none; animation: none; }
#alerts-panel .compact .atc-name { font-size: 14px; -webkit-line-clamp: 1; }
#alerts-panel .compact .atc-sev { background: rgba(var(--tone), 0.14); box-shadow: inset 0 0 0 1px rgba(var(--tone), 0.28); color: var(--ink); }
#alerts-panel .compact .atc-time { margin-top: 3px; }

/* ── The empty states: centred and quiet, an icon in a tinted chip over a line and a note ──────────────── */
#alerts-panel .alerts-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 28px 20px 26px;
    text-align: center;
    font-style: normal;
    font-size: 13px;
    color: rgba(203, 213, 225, 0.72);
}
#alerts-panel .alerts-empty-icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    margin-bottom: 8px;
    border-radius: 50%;
    background: rgba(56, 189, 248, 0.12);
    box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.25);
    color: #38bdf8;
    font-size: 22px;
}
#alerts-panel .alerts-empty-title { font-size: 15px; font-weight: 700; color: #e2e8f0; }
#alerts-panel .alerts-empty-sub { max-width: 280px; text-wrap: balance; font-size: 12.5px; font-weight: 500; line-height: 1.5; color: rgba(203, 213, 225, 0.68); }

/* ── The foot: "Create a new alert", the brand's blue button (the buoy modal's Add Alert) ──────────────── */
#alerts-panel .alerts-panel-footer {
    flex: none;
    padding: 4px var(--ap-gap) var(--ap-gap);
    border-top: 0;
    background: transparent;
}
#alerts-panel #btn-new-alert.blue-pill-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 40px;
    padding: 0 16px;
    border: 0;
    border-radius: 12px;
    background: radial-gradient(circle at 50% 0%, #5aa8ff, #2e8eff 60%, #1f6fd6);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 6px 18px rgba(46, 142, 255, 0.3);
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.2px;
    text-shadow: none;
}
#alerts-panel #btn-new-alert.blue-pill-button:hover { background: radial-gradient(circle at 50% 0%, #74b6ff, #4b9dff 60%, #2e8eff); }
#alerts-panel #btn-new-alert.blue-pill-button:active { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 3px 10px rgba(46, 142, 255, 0.3); }
#alerts-panel #btn-new-alert .text { display: inline-flex; align-items: center; gap: 8px; }
#alerts-panel #btn-new-alert .text i { font-size: 11px; }

/* ── A phone: across the screen, under the app's top bar (as the buoy modal), its foot clear of the map-layer
   switcher in the corner under it (app.css #map-layer-switcher: 12 px up, 36 px tall) ─────────────────────── */
@media (max-width: 768px) {
    #alerts-panel { --ap-gap: 14px; top: 72px; right: 8px; left: 8px; width: auto; max-width: none; max-height: calc(100vh - 72px - 60px); }
    #alerts-panel.open { right: 8px; }
    #alerts-panel .ai-panel-header .bc-btn-group__btn { width: 44px; height: 44px; }
    #alerts-panel .ai-panel-header .bc-btn-group { margin: -10px -12px 0 0; }
}

@media (prefers-reduced-motion: reduce) {
    #alerts-panel { transition: none; }
    #alerts-panel .alert-trigger-card.sev-severe::before { animation: none; }
    #alerts-panel .ai-panel-header .bc-btn-group__btn, #alerts-panel .alerts-tab, #alerts-panel .alert-trigger-card,
    #alerts-panel .atc-clear.blue-pill-button, #alerts-panel .alerts-clear-history.blue-pill-button { transition: none; }
}
