/*
 * Status Page Styles
 * Consolidated and optimized CSS for status page display
 */

/* ============================================
   CSS Variables & Theme Configuration
   ============================================ */
:root {
    /* Font Family */
    --sp-font-family: 'Quicksand', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

    /* Status Colors - Light Theme */
    --status-operational: #0b7a3c;
    --status-degraded: #8f5b00;
    --status-partial-outage: #b34700;
    --status-major-outage: #b00020;
    --status-maintenance: #3e5a6d;
    --status-unknown: #5b6470;

    /* Primary accents tuned for contrast */
    --sp-primary: #2f45d0;
    --sp-primary-hover: #2639b0;
    --sp-primary-contrast: #ffffff;
}

/* Dark Theme Status Colors */
[data-bs-theme=dark] :root,
[data-bs-theme=dark] body {
    --status-operational: #0b7a3c;
    --status-degraded: #8f5b00;
    --status-partial-outage: #b34700;
    --status-major-outage: #b00020;
    --status-maintenance: #3e5a6d;
    --status-unknown: #7b8694;
}

/* ============================================
   Base Typography & Layout
   ============================================ */
html,
body {
    font-family: var(--sp-font-family);
    line-height: 1.6;
    color: var(--bs-body-color, #333);
    background-color: var(--bs-body-bg, #f8f9fa);
    scroll-behavior: smooth;
}

/* Prevent FOUC - hide body until CSS and critical resources load */
body:not(.page-loaded) {
    visibility: hidden;
}

body.page-loaded {
    visibility: visible;
}

h1, h2, h3, h4, h5, h6,
.badge, .btn, .nav,
.status-ticks, .uptime-pill {
    font-family: var(--sp-font-family);
}

/* ============================================
   Header & Navigation
   ============================================ */
header.sticky-top {
    transition: backdrop-filter 0.3s ease, background-color 0.3s ease, -webkit-mask-image 0.3s ease, mask-image 0.3s ease;
}

header.sticky-top.scrolled {
    backdrop-filter: blur(10px) saturate(180%);
    -webkit-backdrop-filter: blur(10px) saturate(180%);
    background-color: rgba(var(--bs-body-bg-rgb, 248, 249, 250), 0.8) !important;
    box-shadow: none;
    padding-bottom: 20px;
    margin-bottom: -20px;
    -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 20px), transparent 100%);
    mask-image: linear-gradient(to bottom, black calc(100% - 20px), transparent 100%);
}

[data-bs-theme=dark] header.sticky-top.scrolled {
    background-color: rgba(var(--bs-body-bg-rgb, 33, 37, 41), 0.8) !important;
}

.navbar-brand img {
    max-height: 40px;
}

/* ============================================
   Status Indicators & Pills
   ============================================ */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.status-indicator::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Status Indicator Colors */
.status-indicator.status-operational::before { background-color: var(--status-operational); box-shadow: 0 0 0 3px rgba(11, 122, 60, 0.22); }
.status-indicator.status-degraded::before { background-color: var(--status-degraded); box-shadow: 0 0 0 3px rgba(143, 91, 0, 0.22); }
.status-indicator.status-partial-outage::before { background-color: var(--status-partial-outage); box-shadow: 0 0 0 3px rgba(179, 71, 0, 0.22); }
.status-indicator.status-major-outage::before { background-color: var(--status-major-outage); box-shadow: 0 0 0 3px rgba(176, 0, 32, 0.22); }
.status-indicator.status-maintenance::before { background-color: var(--status-maintenance); box-shadow: 0 0 0 3px rgba(62, 90, 109, 0.22); }
.status-indicator.status-unknown::before { background-color: var(--status-unknown); }

/* Status Pills */
.status-pill {
    border-radius: 16px;
    padding: 4px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
}

.status-pill-operational { background-color: var(--status-operational); }
.status-pill-degraded { background-color: var(--status-degraded); }
.status-pill-partial-outage { background-color: var(--status-partial-outage); }
.status-pill-major-outage { background-color: var(--status-major-outage); }
.status-pill-maintenance { background-color: var(--status-maintenance); }
.status-pill-unknown { background-color: var(--status-unknown); }

/* Mixed Status Gradients */
.status-mixed-high {
    background: linear-gradient(to bottom, var(--status-operational) 75%, var(--status-major-outage) 25%);
}

.status-mixed-medium {
    background: linear-gradient(to bottom, var(--status-operational) 50%, var(--status-partial-outage) 50%);
}

.status-mixed-low {
    background: linear-gradient(to bottom, var(--status-operational) 25%, var(--status-degraded) 75%);
}

/* ============================================
   Component Cards & Groups
   ============================================ */
.component-card {
    border-radius: 8px;
    transition: all 0.2s ease;
    border: none;
}

.component-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Component Groups - Minimal & Discrete */
.component-group-wrapper {
    margin-bottom: 2rem;
}

/* High-contrast primary buttons/links */
.btn-primary {
    background-color: var(--sp-primary);
    border-color: var(--sp-primary);
    color: var(--sp-primary-contrast);
}

.btn-primary:hover,
.btn-primary:focus-visible {
    background-color: var(--sp-primary-hover);
    border-color: var(--sp-primary-hover);
    color: var(--sp-primary-contrast);
}

.btn-outline-primary {
    color: var(--sp-primary);
    border-color: var(--sp-primary);
    font-weight: 600;
}

.btn-outline-primary:hover,
.btn-outline-primary:focus-visible {
    background-color: var(--sp-primary);
    color: var(--sp-primary-contrast);
    border-color: var(--sp-primary);
}

[data-bs-theme=dark] .btn-outline-primary {
    color: #dbe3ff;
    border-color: #8fa2ff;
}

[data-bs-theme=dark] .btn-outline-primary:hover,
[data-bs-theme=dark] .btn-outline-primary:focus-visible {
    background-color: #8fa2ff;
    color: #0b1537;
    border-color: #8fa2ff;
}

.component-group-card {
    border: none;
    background: transparent;
    box-shadow: none;
}

.component-group-card .card-header {
    border: none;
    background: transparent !important;
    padding: 0.5rem 0 0.5rem 0.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.component-group-card .card-header:hover {
    background: transparent !important;
}

.component-group-card .card-header[aria-expanded="true"] {
    border-bottom: none;
}

.group-collapse-icon {
    transition: transform 0.2s ease;
    width: 0.875rem;
    height: 0.875rem;
    fill: #6c757d;
    opacity: 0.6;
}

.card-header[aria-expanded="true"] .group-collapse-icon {
    transform: rotate(180deg);
}

.cursor-pointer {
    cursor: pointer;
}

.group-status-badge .status-pill {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
    opacity: 0.8;
}

.component-group-card .card-body {
    padding: 0;
    background: transparent;
    border: none;
}

.component-group-card .card-body .component-card {
    border-radius: 8px;
    margin-bottom: 0.75rem;
    padding: 1rem;
    --component-card-padding: 1rem; /* for full-bleed chart calculations */
}

.ungrouped-components-wrapper {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px dashed rgba(0, 0, 0, 0.1);
}

.ungrouped-components-wrapper.no-border {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.ungrouped-components-wrapper h3 {
    opacity: 0.7;
    font-weight: 600;
}

/* Component 90-day strip animation */
.component-90d-strip {
    --c90d-duration: 300ms;
    transition: opacity var(--c90d-duration) ease, transform var(--c90d-duration) ease;
    opacity: 1;
}

.component-90d-strip.fade-hide {
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
}

/* Fade content during collapse/expand animation */
.component-card .collapse > .card-body,
.component-card .collapsing > .card-body {
    transition: opacity 120ms ease-out;
}

/* When collapsing (not expanding), fade out immediately */
.component-card .collapsing:not(.expanding) > .card-body {
    opacity: 0;
    transition: opacity 120ms ease-out;
}

/* When expanding, show content immediately */
.component-card .collapsing.expanding > .card-body {
    opacity: 1;
}

.component-card .collapse:not(.show) > .card-body {
    opacity: 0;
}

.component-card .collapse.show > .card-body {
    opacity: 1;
}

/* ============================================
   Uptime Pills & Daily History
   ============================================ */
.uptime-pill {
    width: 30px;
    height: 45px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 3px;
    font-size: 0.7rem;
    color: white;
    text-align: center;
    padding: 3px;
    cursor: help;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.uptime-pill:hover {
    transform: scale(1.06);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
}

.uptime-pill span {
    line-height: 1;
    display: block;
    margin: 1px 0;
}

/* Remove focus outline */
.uptime-pill:focus,
.uptime-pill:focus-visible,
.uptime-pill:active {
    outline: none !important;
    box-shadow: none !important;
}

.uptime-pill {
    -webkit-tap-highlight-color: transparent;
}

.daily-uptime-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    margin-bottom: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 0;
    scrollbar-width: none;
}

.daily-uptime-container::-webkit-scrollbar {
    display: none;
}

.daily-uptime-pills {
    display: flex;
    flex-wrap: nowrap;
    gap: 2px;
    height: 70px;
    padding-top: 10px;
    overflow-x: hidden;
}

.daily-uptime-label {
    min-width: 100px;
    font-size: 0.85rem;
}

/* ============================================
   Hourly Uptime Pills
   ============================================ */
.hourly-uptime-container {
    margin-bottom: 20px;
}

.hourly-uptime-pills {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 4px;
    margin-bottom: 4px;
}

.hourly-tight {
    justify-content: center;
}

/* Hourly progress bar (24 segments) - continuous bar style */
.daily-uptime-pills.hourly-tight {
    gap: 0;
    height: 10px;
    padding-top: 0;
    border-radius: 6px;
    overflow: hidden;
    /* Default: green (operational) base */
    background: var(--status-operational);
    width: 100%;
    max-width: 720px;
}

.daily-uptime-pills.hourly-tight .hour-seg {
    flex: 1 1 0;
    min-width: 10px;
    height: 100%;
    display: block;
    position: relative;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    /* Transparent by default - operational hours blend with green base */
    background: transparent;
}

/* Operational hours: keep transparent (shows green base) */
.daily-uptime-pills.hourly-tight .hour-seg.tick-operational,
.daily-uptime-pills.hourly-tight .hour-seg.tick-up {
    background: transparent;
}

/* Hours with no data: subtle gray */
.daily-uptime-pills.hourly-tight .hour-seg[data-hasdata="0"] {
    background: var(--status-unknown);
    opacity: 0.6;
}

/* No visible separators - continuous look */
.daily-uptime-pills.hourly-tight .hour-seg:not(:last-child)::after {
    display: none;
}

.daily-uptime-pills.hourly-tight .hour-seg:hover,
.daily-uptime-pills.hourly-tight .hour-seg:focus-visible {
    z-index: 5;
}

/* Hover highlight overlay */
.daily-uptime-pills.hourly-tight .hour-seg::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    transition: background 0.1s ease;
}

.daily-uptime-pills.hourly-tight .hour-seg:hover::before,
.daily-uptime-pills.hourly-tight .hour-seg:focus-visible::before {
    background: rgba(255, 255, 255, 0.25);
}

/* Remove focus outline (hour segments) */
.hourly-tight .hour-seg,
.hourly-tight .hour-seg:focus,
.hourly-tight .hour-seg:focus-visible,
.hourly-tight .hour-seg:focus-within,
.hourly-tight .hour-seg:active {
    outline: none !important;
}

/* Incident/outage hours: pinkish-magenta overlay (like in the reference) */
.daily-uptime-pills.hourly-tight .hour-seg.tick-major-outage,
.daily-uptime-pills.hourly-tight .hour-seg.tick-partial-outage {
    background: #c06078;
}

/* Degraded hours: muted amber */
.daily-uptime-pills.hourly-tight .hour-seg.tick-degraded {
    background: #d4a053;
}

/* Maintenance hours */
.daily-uptime-pills.hourly-tight .hour-seg.tick-maintenance {
    background: var(--status-maintenance);
}

/* Unknown hours (future or no monitoring) */
.daily-uptime-pills.hourly-tight .hour-seg.tick-unknown {
    background: rgba(0, 0, 0, 0.25);
    opacity: 0.8;
}

/* Mixed status hours - show as incident color */
.daily-uptime-pills.hourly-tight .hour-seg.tick-mixed-high,
.daily-uptime-pills.hourly-tight .hour-seg.tick-mixed-medium {
    background: #c06078;
}
.daily-uptime-pills.hourly-tight .hour-seg.tick-mixed-low {
    background: #d4a053;
}

/* Unhealthy hours - same incident styling, no filter needed */
.daily-uptime-pills.hourly-tight .hour-seg.tick-unhealthy {
    filter: none;
    background: #c06078 !important;
}

/* ============================================
   Status Ticks / History Heatmap
   ============================================ */
.status-ticks-wrapper {
    margin-top: 0.5rem;
}

/* Month labels */
.status-ticks-months {
    --tick-size: 14px;
    --tick-gap: 3px;
    display: flex;
    flex-wrap: nowrap;
    gap: var(--tick-gap);
    padding: 0 2px 2px;
    font-size: 0.55rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #666;
    overflow: hidden;
    max-width: 100%;
}

/* Heatmap ticks */
.status-ticks {
    --tick-size: 14px;
    --tick-gap: 1px;
    display: flex;
    flex-wrap: nowrap;
    gap: var(--tick-gap);
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 6px 2px 8px;
    scrollbar-width: thin;
}

.status-ticks::-webkit-scrollbar {
    height: 6px;
}

.status-ticks::-webkit-scrollbar-thumb {
    background: rgba(var(--bs-body-color-rgb, 33, 37, 41), 0.4);
    border-radius: 4px;
}

.tick {
    width: var(--tick-size);
    height: var(--tick-size);
    border-radius: 3px;
    position: relative;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.08);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    transform-origin: center center;
}

.tick-week-start {
    box-shadow: -3px 0 0 0 rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.08);
}

.tick:hover,
.tick:focus-visible {
    transform: scale(1.35) translateY(-2px);
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    outline: none;
}

/* Gradient enlargement for neighboring ticks on hover */
/* 2 ticks to the left */
.tick:hover + .tick + .tick,
.tick:focus-visible + .tick + .tick {
    transform: scale(1.08) translateY(-1px);
    z-index: 6;
}

.tick:hover + .tick,
.tick:focus-visible + .tick {
    transform: scale(1.20) translateY(-1.5px);
    z-index: 8;
}

/* 2 ticks to the right (using :has selector for previous siblings) */
.tick:has(+ .tick:hover),
.tick:has(+ .tick:focus-visible) {
    transform: scale(1.20) translateY(-1.5px);
    z-index: 8;
}

.tick:has(+ .tick + .tick:hover),
.tick:has(+ .tick + .tick:focus-visible) {
    transform: scale(1.08) translateY(-1px);
    z-index: 6;
}

/* Tick Status Colors */
.tick-operational { background: var(--status-operational); }
.tick-degraded { background: var(--status-degraded); }
.tick-partial-outage { background: var(--status-partial-outage); }
.tick-major-outage { background: var(--status-major-outage); }
.tick-maintenance { background: var(--status-maintenance); }
.tick-unknown { background: var(--status-unknown); }

/* Future hours - neutral/unknown since we don't have data yet */
.tick-future {
    background: var(--status-unknown, #9e9e9e) !important;
    opacity: 0.6 !important;
}

/* Much lighter future ticks in light theme */
:root .tick-future,
.light-style .tick-future,
[data-theme="theme-default"] .tick-future {
    background: #e8e8e8 !important;
    opacity: 0.5 !important;
}

/* Keep current styling for dark theme */
[data-bs-theme=dark] .tick-future,
.dark-style .tick-future,
[data-theme="theme-dark"] .tick-future {
    background: var(--status-unknown, #b0b0b0) !important;
    opacity: 0.6 !important;
}

/* Darken unhealthy ticks */
.tick-unhealthy {
    filter: saturate(0.85) brightness(0.75);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.20), 0 1px 3px rgba(0, 0, 0, 0.20);
}

/* Unhealthy ticks use inline gradient styles, so disable class-based backgrounds when tick-unhealthy is present */
.tick-unhealthy.tick-mixed-high,
.tick-unhealthy.tick-mixed-medium,
.tick-unhealthy.tick-mixed-low,
.tick-unhealthy.tick-operational,
.tick-unhealthy.tick-degraded,
.tick-unhealthy.tick-partial-outage,
.tick-unhealthy.tick-major-outage {
    background: none; /* Let inline style take over */
}

/* Mixed Status Ticks (only apply when NOT unhealthy - these are fallbacks) */
.tick-mixed-high:not(.tick-unhealthy) {
    background: linear-gradient(to top,
        var(--status-major-outage) 25%, var(--status-major-outage) 25%,
        var(--status-operational) 25%, var(--status-operational) 100%);
}

.tick-mixed-medium:not(.tick-unhealthy) {
    background: linear-gradient(to top,
        var(--status-partial-outage) 50%, var(--status-partial-outage) 50%,
        var(--status-operational) 50%, var(--status-operational) 100%);
}

.tick-mixed-low:not(.tick-unhealthy) {
    background: linear-gradient(to top,
        var(--status-degraded) 75%, var(--status-degraded) 75%,
        var(--status-operational) 75%, var(--status-operational) 100%);
}

/* Status History Legend */
.status-history-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

.status-history-legend span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}

/* Day Ticks Layout */
.component-90d-strip .d-flex.flex-wrap {
    flex-wrap: nowrap !important;
    width: 100%;
}

.status-ticks {
    display: flex;
    flex-wrap: nowrap;
    width: 100%;
}

.component-90d-strip .day-tick,
.status-ticks .day-tick {
    flex: 1 1 0;
    width: auto !important;
    display: inline-block;
    min-width: 2px;
    height: 20px;
    border-radius: 2px;
}

.status-ticks .day-tick {
    height: 30px;
}

.day-ticks-truncated {
    display: none;
    font-size: 0.65rem;
    color: var(--bs-secondary-color, #6c757d);
    margin-left: 0.35rem;
    vertical-align: middle;
}

/* ============================================
   Incident Timeline & Updates
   ============================================ */
.incident-item {
    position: relative;
    margin-bottom: 40px;
}

.incident-item:last-child::before {
    bottom: 0.5rem;
}

/* Resolved incident styling */
.incident-item.resolved .card {
    background: #f0f2f4;
    border: 1px solid #e2e5e7;
}

.incident-item.resolved .card-body {
    background: transparent;
}

/* Dashed line for ongoing incidents */
.incident-item.unresolved::before {
    background: repeating-linear-gradient(
        to bottom,
        rgba(var(--bs-body-color-rgb, 33, 37, 41), 0.3) 0 10px,
        transparent 10px 20px
    );
}

/* Incident Dots */
.incident-dot {
    display: none;
}

.incident-dot.pulsate::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid currentColor;
    animation: incidentPulseRing 1.8s ease-out infinite;
    opacity: 0.75;
}

@keyframes incidentPulseRing {
    0% { transform: scale(0.5); opacity: 0.7; }
    60% { transform: scale(1.8); opacity: 0; }
    100% { transform: scale(1.8); opacity: 0; }
}

.incident-dot-resolved {
    border-color: var(--status-operational);
    background: var(--status-operational);
}

.incident-dot-investigating {
    border-color: var(--status-partial-outage);
    background: var(--status-partial-outage);
}

.incident-dot-identified {
    border-color: var(--status-degraded);
    background: var(--status-degraded);
}

.incident-dot-monitoring {
    border-color: var(--status-maintenance);
    background: var(--status-maintenance);
}

/* Update State Dots */
.update-state-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
    position: relative;
    top: -1px;
    background: var(--status-unknown);
    box-shadow: 0 0 0 2px var(--bs-body-bg, #fff);
}

.update-state-investigating { background: var(--status-partial-outage); }
.update-state-identified { background: var(--status-degraded); }
.update-state-monitoring { background: var(--status-maintenance); }
.update-state-resolved { background: var(--status-operational); }
.update-state-initial { background: var(--status-unknown); }

/* Unified Update Timeline */
.incident-updates-timeline {
    list-style: none;
    margin: 0;
    padding: 0 0 0 24px;
    position: relative;
}

.incident-updates-timeline::before {
    content: "";
    position: absolute;
    left: 6px;
    top: var(--timeline-line-top, 4px);
    width: 2px;
    background: #e2e2e2;
    height: var(--timeline-line-height, calc(64%));
}

.incident-updates-timeline > li {
    position: relative;
    margin-bottom: 26px;
}

.incident-updates-timeline > li:last-child {
    margin-bottom: 4px;
}

.incident-updates-timeline .update-circle {
    position: absolute;
    left: -24px;
    top: 4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    box-shadow: 0 0 0 3px var(--bs-body-bg, #fff);
}

.incident-updates-timeline .update-item.latest-update {
    position: relative;
}

.incident-updates-timeline .update-item.latest-update::before {
    display: none !important;
}

.incident-updates-timeline .update-item.latest-update .update-circle {
    left: -28px;
}

.incident-updates-timeline .update-item.latest-update {
    background-clip: padding-box;
}

.update-circle-investigating {
    border-color: #ff9800;
    background: #ff9800;
}

.update-circle-identified {
    border-color: #ffc107;
    background: #ffc107;
}

.update-circle-monitoring {
    border-color: #17a2b8;
    background: #17a2b8;
}

.update-circle-resolved {
    border-color: #198754;
    background: #198754;
}

.update-circle-initial {
    border-color: var(--status-unknown);
    background: var(--status-unknown);
}

.incident-initial-message {
    font-size: 0.85rem;
}

/* Resolved Incident Collapsible Toggle */
.resolved-incident-toggle {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.resolved-incident-toggle:hover {
    background-color: rgba(var(--bs-body-color-rgb, 33, 37, 41), 0.03);
}

.resolved-incident-toggle .toggle-chevron {
    transition: transform 0.2s ease;
}

.resolved-incident-toggle[aria-expanded="true"] .toggle-chevron {
    transform: rotate(180deg);
}

.resolved-incident-toggle[aria-expanded="true"] .toggle-text {
    display: none;
}

.resolved-incident-toggle[aria-expanded="true"]::before {
    content: "Click to hide details";
}

.incident-updates-timeline .update-meta {
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-weight: 600;
    opacity: 0.75;
}

.incident-updates-timeline .update-body {
    font-size: 0.85rem;
    color: var(--bs-body-color, #333);
}

/* Latest Update Highlight */
.update-item.latest-update {
    background: rgba(13, 110, 253, 0.05);
    border-left: 4px solid #0d6efd;
    padding: 0.75rem;
    border-radius: 0.25rem;
}

/* Incident Badges */
.incident-badge {
    font-size: 0.65rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.badge-state-investigating { background: #ff9800; }
.badge-state-identified { background: #ffc107; color: #212529; }
.badge-state-monitoring { background: #17a2b8; }
.badge-state-resolved { background: #198754; }
.badge-update { background: #6c757d; }
.badge-latest { background: #0d6efd; }

.incident-main-state-badge {
    font-size: 0.55rem;
    vertical-align: middle;
    margin-left: 0.35rem;
}

.incident-item h3 {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

/* ============================================
   Postmortem Styles
   ============================================ */
.postmortem-public h4 {
    margin-top: 1.5rem;
    font-weight: 600;
}

.postmortem-public pre {
    background: #1e1e1e;
    color: #f8f8f2;
    padding: 12px 14px;
    border-radius: 6px;
    overflow: auto;
    font-size: 0.85rem;
}

.postmortem-public code {
    background: #f1f3f5;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 0.85em;
}

[data-bs-theme="dark"] .postmortem-public code {
    background: #333;
}

/* ============================================
   Response Chart / Sparklines
   ============================================ */
/* Ensure component cards don't allow overflow */
.component-card,
.component-card.card {
    overflow: visible !important; /* allow full-bleed charts */
}

.component-card .card-body {
    overflow: visible !important; /* allow full-bleed children like charts */
    max-width: 100%;
}

/* Ensure collapse container doesn't clip full-bleed content */
.component-card .collapse,
.component-card .collapsing {
    overflow: visible !important;
}

.resp-chart-wrapper {
    margin-top: 0.35rem;
    /* Allow full bleed both sides */
    overflow: visible !important;
    width: 100%;
    /* max-width removed to allow full-bleed to extend beyond parent */
    position: relative;
    box-sizing: border-box;
}

.resp-chart-wrapper.full-bleed {
    /* Base styles - JS will override margin/width for full-bleed */
    box-sizing: border-box;
    position: relative;
}

/* Chart container divs inside full-bleed wrapper */
.resp-chart-wrapper.full-bleed > div[id^='resp-chart-minute'],
.resp-chart-wrapper.full-bleed > div[id^='resp-chart-'] {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
}

/* Chart.js canvas and container should fill the full-bleed wrapper */
.resp-chart-wrapper.full-bleed canvas {
    width: 100% !important;
    max-width: none !important;
    display: block;
    box-sizing: border-box;
}

.resp-chart-wrapper.full-bleed > div[id^='resp-chart'] {
    width: 100% !important;
    max-width: none !important;
    box-sizing: border-box;
}

/* Override Chart.js responsive container constraints */
.resp-chart-wrapper.full-bleed .chartjs-size-monitor,
.resp-chart-wrapper.full-bleed > div {
    width: 100% !important;
    max-width: none !important;
}

/* Force canvas parent to take full width */
.resp-chart-wrapper.full-bleed div[style*="width:100%"] {
    width: 100% !important;
}

/* Chart.js sometimes wraps canvas in a relative div */
.resp-chart-wrapper.full-bleed > div > canvas,
.resp-chart-wrapper.full-bleed canvas[style] {
    width: 100% !important;
    max-width: none !important;
}

.resp-chart-title {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #666;
    margin: 0 0 2px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding-left: var(--component-card-padding, var(--bs-card-spacer-x, 1rem));
    padding-right: var(--component-card-padding, var(--bs-card-spacer-x, 1rem));
}

[data-bs-theme=dark] .resp-chart-title {
    color: #8d96a0;
}

/* Hourly pills wrapper - center contents */
.hourly-today-wrapper {
    text-align: center;
}

.hourly-today-wrapper h6 {
    text-align: center;
}

.hourly-today-wrapper .daily-uptime-container {
    display: flex;
    justify-content: center;
}

/* Daily 90-day section - center heading and "(X shown)" text */
.status-ticks {
    justify-content: center;
}

/* Center the parent wrapper of status-ticks */
.card-body > .mt-3:has(.status-ticks) {
    text-align: center;
}

.card-body > .mt-3:has(.status-ticks) > h6 {
    text-align: center;
}

/* Chart container constraints - prevent overflow and layout shifts */
.resp-chart-wrapper > div[id^='resp-chart'] {
    width: 100% !important;
    max-width: 100%;
    overflow: visible;
}

/* Hide charts during initial load to prevent FOUC */
.resp-chart-wrapper > div[id^='resp-chart']:not(.chart-loaded) {
    opacity: 0;
    transition: opacity 0.2s ease-in;
}

.resp-chart-wrapper > div[id^='resp-chart'].chart-loaded {
    opacity: 1;
}

/* ApexCharts canvas sizing constraint */
.apexcharts-canvas {
    max-width: 100% !important;
    width: 100% !important;
}

/* Prevent ApexCharts from breaking out of container */
.apexcharts-svg,
.apexcharts-canvas svg {
    max-width: 100% !important;
    width: 100% !important;
}

/* Force all ApexCharts inner elements to respect container */
.resp-chart-wrapper .apexcharts-inner,
.resp-chart-wrapper .apexcharts-graphical,
.resp-chart-wrapper foreignObject {
    max-width: 100% !important;
    overflow: visible !important;
}

/* Ensure the parent container of ApexCharts also has constraints */
div[id^='resp-chart'] > div {
    max-width: 100% !important;
    width: 100% !important;
}

/* Critical: Force ApexCharts wrapper div to respect parent width */
div[id^='resp-chart'] > div > div,
div[id^='resp-chart'] .apexcharts-wrapper {
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Prevent horizontal scroll in chart containers */
.resp-chart-wrapper,
.resp-chart-wrapper * {
    box-sizing: border-box;
}

/* Additional safety: ensure no child of resp-chart-wrapper breaks the layout */
.resp-chart-wrapper > * {
    max-width: 100%;
}

/* ============================================
   Distributed Results
   ============================================ */
.distributed-results {
    max-height: 200px;
    overflow-y: auto;
}

.distributed-result-item {
    border: 1px solid rgba(var(--bs-body-color-rgb, 33, 37, 41), 0.1);
    font-size: 0.85rem;
}

.distributed-result-item:hover {
    background-color: rgba(var(--bs-body-color-rgb, 33, 37, 41), 0.08) !important;
}

/* ============================================
   Modal Overrides
   ============================================ */
#subscriptionModal {
    background: rgba(0, 0, 0, 0.55);
    position: fixed;
    inset: 0;
    display: none;
    overflow-y: auto;
    z-index: 1055;
}

#subscriptionModal .modal-dialog {
    margin: 5rem auto;
    max-width: 500px;
}

#subscriptionModal .modal-content {
    background-color: var(--bs-body-bg, #fff);
    border: 1px solid var(--bs-border-color, rgba(0,0,0,0.175));
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

#subscriptionModal .modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--bs-border-color, rgba(0,0,0,0.175));
}

#subscriptionModal .modal-body {
    padding: 1.25rem;
}

#subscriptionModal .modal-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--bs-border-color, rgba(0,0,0,0.175));
    gap: 0.5rem;
}

#subscriptionModal .modal-title {
    font-weight: 500;
    font-size: 1.25rem;
    color: var(--bs-heading-color, inherit);
}

#subscriptionModal .btn-close {
    background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000'%3e%3cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat;
    border: 0;
    width: 1em;
    height: 1em;
    padding: 0.25em;
    opacity: 0.5;
    cursor: pointer;
}

#subscriptionModal .btn-close:hover {
    opacity: 0.75;
}

/* Frest-style form controls in modal */
#subscriptionModal .form-control,
#subscriptionModal .form-select {
    padding: 0.5rem 0.875rem;
    font-size: 0.9375rem;
    border-radius: 0.375rem;
    border: 1px solid var(--bs-border-color, #d1d5db);
    background-color: var(--bs-body-bg, #fff);
    color: var(--bs-body-color, #212529);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

#subscriptionModal .form-control:focus,
#subscriptionModal .form-select:focus {
    border-color: var(--sp-primary);
    box-shadow: 0 0 0 0.2rem rgba(47, 69, 208, 0.25);
    outline: 0;
}

#subscriptionModal .form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
    color: var(--bs-heading-color, #566a7f);
}

/* Form group spacing and layout */
#subscriptionModal .mb-3 {
    margin-bottom: 1rem;
}

#subscriptionModal .form-control,
#subscriptionModal .form-select {
    display: block;
    width: 100%;
}

/* Helper/validation text styling */
#subscriptionModal .invalid-feedback,
#subscriptionModal .valid-feedback {
    display: none;
    font-size: 0.75rem;
    margin-top: 0.25rem;
    color: #ff4c51;
}

#subscriptionModal .form-control:invalid:not(:placeholder-shown) ~ .invalid-feedback,
#subscriptionModal .form-control.is-invalid ~ .invalid-feedback,
#subscriptionModal .was-validated .form-control:invalid ~ .invalid-feedback {
    display: block;
}

#subscriptionModal .valid-feedback {
    color: #28c76f;
}

#subscriptionModal .form-text,
#subscriptionModal #subscriptionFeedback {
    font-size: 0.75rem;
    color: var(--bs-secondary-color, #697a8d);
    margin-top: 0.25rem;
}

/* Frest-style buttons in modal */
#subscriptionModal .btn {
    padding: 0.5rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: 0.375rem;
    transition: all 0.15s ease-in-out;
    cursor: pointer;
}

#subscriptionModal .btn-primary {
    background-color: var(--sp-primary);
    border-color: var(--sp-primary);
    color: var(--sp-primary-contrast);
    box-shadow: 0 0.125rem 0.25rem rgba(47, 69, 208, 0.4);
}

#subscriptionModal .btn-primary:hover {
    background-color: var(--sp-primary-hover);
    border-color: var(--sp-primary-hover);
    box-shadow: 0 0.25rem 0.5rem rgba(38, 57, 176, 0.5);
    transform: translateY(-1px);
}

#subscriptionModal .btn-secondary {
    background-color: #8592a3;
    border-color: #8592a3;
    color: #fff;
    box-shadow: 0 0.125rem 0.25rem rgba(133, 146, 163, 0.4);
}

#subscriptionModal .btn-secondary:hover {
    background-color: #717d8c;
    border-color: #717d8c;
    box-shadow: 0 0.25rem 0.5rem rgba(133, 146, 163, 0.5);
    transform: translateY(-1px);
}

/* Dark mode modal */
[data-bs-theme="dark"] #subscriptionModal .modal-content,
.dark-style #subscriptionModal .modal-content {
    background-color: var(--bs-body-bg, #2b2c40);
    border-color: var(--bs-border-color, rgba(255,255,255,0.175));
}

[data-bs-theme="dark"] #subscriptionModal .btn-close,
.dark-style #subscriptionModal .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

[data-bs-theme="dark"] #subscriptionModal .form-control,
[data-bs-theme="dark"] #subscriptionModal .form-select,
.dark-style #subscriptionModal .form-control,
.dark-style #subscriptionModal .form-select {
    background-color: var(--bs-body-bg, #2b2c40);
    border-color: var(--bs-border-color, rgba(255,255,255,0.175));
    color: var(--bs-body-color, #a3a4cc);
}

[data-bs-theme="dark"] #subscriptionModal .form-label,
.dark-style #subscriptionModal .form-label {
    color: var(--bs-heading-color, #a3a4cc);
}

/* ============================================
   Custom Tooltip
   ============================================ */
.tooltip-inner {
    max-width: 250px;
    padding: 8px 12px;
    color: #fff;
    text-align: left;
    background-color: rgba(0, 0, 0, 0.85);
    border-radius: 6px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
    font-size: 0.85rem;
    line-height: 1.5;
}

/* ============================================
   Animations
   ============================================ */
@keyframes ok-enter {
    0% { opacity: 0; transform: scale(0.96); }
    60% { opacity: 1; transform: scale(1.03); }
    100% { opacity: 1; transform: scale(1); }
}

.check-ok-illustration.animate-in {
    animation: ok-enter 360ms cubic-bezier(.2, .9, .2, 1) both;
    will-change: opacity, transform;
}

.check-ok-illustration:focus-visible {
    outline: none;
    box-shadow: 0 6px 18px rgba(13, 110, 253, 0.12), 0 0 0 4px rgba(13, 110, 253, 0.08);
    transform: translateY(-3px);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

@media (prefers-reduced-motion: reduce) {
    .check-ok-illustration.animate-in,
    .check-ok-illustration:focus-visible {
        animation: none;
        transition: none;
        transform: none;
        box-shadow: none;
    }
}

/* ============================================
   Dark Theme Overrides
   ============================================ */
[data-bs-theme=dark] {
    color-scheme: dark;
}

[data-bs-theme=dark] body {
    background: #0f1113;
    color: #e3e6e9;
}

[data-bs-theme=dark] .bg-light {
    background: #1e2226 !important;
}

[data-bs-theme=dark] .component-card {
    background: #1c2227;
    color: #d5dadd;
}

[data-bs-theme=dark] .component-card .text-muted {
    color: #9aa3ab !important;
}

/* Dark Theme - Component Groups */
[data-bs-theme=dark] .component-group-card {
    background: transparent;
    border: none;
}

[data-bs-theme=dark] .component-group-card .card-header {
    background-color: transparent !important;
    border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme=dark] .component-group-card .card-header:hover {
    background-color: transparent !important;
}

[data-bs-theme=dark] .component-group-card .card-header[aria-expanded="true"] {
    border-bottom: none;
}

[data-bs-theme=dark] .status-pill,
[data-bs-theme=dark] .status-pill:hover,
[data-bs-theme=dark] .status-pill:focus-visible {
    color: #f8fbf9;
}

[data-bs-theme=dark] .status-pill-operational { background-color: var(--status-operational); }
[data-bs-theme=dark] .status-pill-degraded { background-color: var(--status-degraded); }
[data-bs-theme=dark] .status-pill-partial-outage { background-color: var(--status-partial-outage); }
[data-bs-theme=dark] .status-pill-major-outage { background-color: var(--status-major-outage); }
[data-bs-theme=dark] .status-pill-maintenance { background-color: var(--status-maintenance); }
[data-bs-theme=dark] .status-pill-unknown { background-color: var(--status-unknown); }

[data-bs-theme=dark] .ungrouped-components-wrapper {
    border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme=dark] .group-collapse-icon {
    fill: #9aa3ab;
}

[data-bs-theme=dark] .status-history-legend {
    color: #a3acb3;
}

[data-bs-theme=dark] .status-ticks-months {
    color: #8d96a0;
}

[data-bs-theme=dark] .resp-sparkline-label {
    color: #8d96a0;
}

[data-bs-theme=dark] header.bg-white,
[data-bs-theme=dark] .navbar {
    background: #1e2226 !important;
}

[data-bs-theme=dark] footer {
    background: #1e2226 !important;
}

[data-bs-theme=dark] .tick-week-start {
    box-shadow: -3px 0 0 0 rgba(255, 255, 255, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.08), 0 1px 2px rgba(0, 0, 0, 0.55);
}

[data-bs-theme=dark] .tick {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 1px 2px rgba(0, 0, 0, 0.55);
}

[data-bs-theme=dark] .tick:hover,
[data-bs-theme=dark] .tick:focus-visible {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.75);
}

[data-bs-theme=dark] .update-item.latest-update {
    background: rgba(13, 110, 253, 0.15);
}

[data-bs-theme=dark] .incident-item.resolved .card {
    background: #2d3135;
    border-color: #3a4045;
}

/* ============================================
   Responsive Design
   ============================================ */

/* Tablet & Below */
@media (max-width: 991.98px) {
    .component-90d-strip .day-tick:nth-last-child(n+46),
    .status-ticks .day-tick:nth-last-child(n+46) {
        display: none !important;
    }
    .day-ticks-truncated[data-size="45"] {
        display: inline;
    }
}

/* Mobile Devices */
@media (max-width: 768px) {
    .hourly-uptime-pills {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (max-width: 575.98px) {
    /* Day ticks - show only last 30 */
    .component-90d-strip .day-tick {
        display: none !important;
    }
    .component-90d-strip .day-tick:nth-last-child(-n+30) {
        display: inline-block !important;
    }
    .status-ticks .day-tick {
        display: none !important;
    }
    .status-ticks .day-tick:nth-last-child(-n+30) {
        display: inline-block !important;
    }
    .day-ticks-truncated {
        display: none;
    }
    .day-ticks-truncated[data-size="45"] {
        display: none !important;
    }
    .day-ticks-truncated[data-size="30"] {
        display: inline;
    }

    /* Hourly pills */
    .hourly-uptime-pills {
        grid-template-columns: repeat(4, 1fr);
    }

    /* Incident timeline */
    .incident-updates-timeline {
        padding-left: 16px;
    }
    .incident-updates-timeline > li {
        margin-bottom: 20px;
    }
    .incident-updates-timeline .update-circle {
        left: -16px;
        top: 2px;
        width: 12px;
        height: 12px;
    }
    .incident-updates-timeline .update-item.latest-update .update-circle {
        left: -20px;
    }
    .incident-updates-timeline .update-meta {
        font-size: 0.65rem;
    }
    .incident-updates-timeline .update-body {
        font-size: 0.8rem;
    }
    .update-item.latest-update {
        padding: 0.6rem;
    }

    /* Badges */
    .incident-badge {
        font-size: 0.6rem;
    }

    /* Incident items */
    .incident-item h3 {
        font-size: 1rem;
        gap: 0.25rem;
    }
    .incident-item .card-body p {
        font-size: 0.85rem;
    }
    .incident-main-state-badge {
        font-size: 0.5rem !important;
    }

    /* Postmortem */
    .postmortem-public h4 {
        font-size: 1rem;
        margin-top: 1rem;
    }
    .postmortem-public pre {
        font-size: 0.75rem;
        padding: 8px 10px;
    }
    .pm-toggle {
        --bs-btn-padding-y: 0.25rem;
        --bs-btn-padding-x: 0.5rem;
        --bs-btn-font-size: 0.75rem;
    }

    /* Navigation */
    .breadcrumb {
        font-size: 0.8rem;
    }
    .btn-sm {
        --bs-btn-padding-y: 0.25rem;
        --bs-btn-padding-x: 0.5rem;
        --bs-btn-font-size: 0.75rem;
    }
    .btn-sm .d-none.d-sm-inline,
    .btn-sm .d-none.d-md-inline {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .hourly-uptime-pills {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Desktop - Larger ticks */
@media (min-width: 992px) {
    .status-ticks,
    .status-ticks-months {
        --tick-size: 16px;
    }
}
