/* ═══════════════════════════════════════════════════════════════
   SafeSky Status Page — Styles
   Inspired by githubstatus.com / status.stripe.com / slack-status.com
   ═══════════════════════════════════════════════════════════════ */

/* ── Reset & base ─────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #0b1120;
    --bg-card: #111827;
    --bg-card-hover: #1e293b;
    --bg-banner-ok: #064e3b;
    --bg-banner-degraded: #7c2d12;
    --bg-banner-outage: #7f1d1d;
    --border: #1e293b;
    --border-light: #334155;
    --text: #f1f5f9;
    --text-dim: #94a3b8;
    --text-muted: #64748b;
    --green: #22c55e;
    --green-light: #4ade80;
    --orange: #f97316;
    --red: #ef4444;
    --grey: #334155;
    --grey-light: #475569;
    --blue: #3b82f6;
    --radius: 12px;
    --radius-sm: 6px;
    --radius-lg: 16px;
    --max-w: 860px;
}

html {
    font-size: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* ── Header ───────────────────────────────────────────────────── */
.header {
    width: 100%;
    background: #0d1a2e;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    flex-shrink: 0;
}

.logo {
    height: 36px;
    width: auto;
}

.brand-name {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.last-updated {
    font-size: 13px;
    color: var(--text-muted);
}

.btn-contact {
    display: inline-block;
    font-size: 14px;
    font-weight: 600;
    color: #0d1a2e;
    background: #00cfff;
    padding: 9px 22px;
    border-radius: 8px;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s;
}

.btn-contact:hover {
    background: #33d9ff;
}

@media (max-width: 600px) {
    .last-updated {
        display: none;
    }

    .header-inner {
        padding: 0 16px;
    }

    .brand-name {
        font-size: 15px;
    }
}

/* ── Overall status banner (Stripe-style) ─────────────────────── */
.overall-banner {
    max-width: var(--max-w);
    width: 100%;
    margin: 28px auto 0;
    padding: 0 24px;
}

.overall-banner-inner {
    background: var(--bg-banner-ok);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: background 0.5s;
}

.overall-banner-inner.degraded {
    background: var(--bg-banner-degraded);
}

.overall-banner-inner.outage {
    background: var(--bg-banner-outage);
}

.overall-banner-inner.unknown {
    background: var(--grey);
}

.overall-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--green-light);
    flex-shrink: 0;
    transition: background 0.4s;
}

.overall-icon.operational {
    background: var(--green-light);
}

.overall-icon.degraded {
    background: var(--orange);
}

.overall-icon.outage {
    background: var(--red);
}

.overall-icon.unknown {
    background: var(--grey-light);
}

.overall-banner h1 {
    font-size: 1.15rem;
    font-weight: 600;
    color: #fff;
}

/* ── Uptime summary section (GitHub-style big number) ─────────── */
.uptime-summary {
    max-width: var(--max-w);
    width: 100%;
    margin: 32px auto 0;
    padding: 0 24px;
    text-align: center;
}

.uptime-big-number {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 2px;
}

.uptime-value {
    font-size: 3.5rem;
    font-weight: 700;
    letter-spacing: -1px;
    color: var(--text);
    line-height: 1;
}

.uptime-value.green {
    color: var(--green-light);
}

.uptime-value.orange {
    color: var(--orange);
}

.uptime-value.red {
    color: var(--red);
}

.uptime-symbol {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-dim);
}

.uptime-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.overall-timeline-container {
    margin-top: 28px;
}

/* ── Section heading ──────────────────────────────────────────── */
.section-heading {
    max-width: var(--max-w);
    width: 100%;
    margin: 40px auto 0;
    padding: 0 24px;
}

.section-heading h2 {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}

/* ── Service cards (Slack-style rows) ─────────────────────────── */
.services {
    max-width: var(--max-w);
    width: 100%;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.service-card {
    border-bottom: 1px solid var(--border);
    padding: 24px 0;
    transition: background 0.15s;
}

.service-card:last-child {
    border-bottom: none;
}

.service-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.service-name {
    font-size: 0.95rem;
    font-weight: 600;
}

.service-uptime-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
}

.service-uptime-label.green {
    color: var(--green);
}

.service-uptime-label.orange {
    color: var(--orange);
}

.service-uptime-label.red {
    color: var(--red);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-badge.operational {
    color: var(--green);
    background: rgba(34, 197, 94, .1);
}

.status-badge.degraded {
    color: var(--orange);
    background: rgba(249, 115, 22, .1);
}

.status-badge.outage {
    color: var(--red);
    background: rgba(239, 68, 68, .1);
}

.status-badge.unknown {
    color: var(--grey-light);
    background: rgba(71, 85, 105, .15);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}

.status-badge.operational .status-dot {
    background: var(--green);
}

.status-badge.degraded .status-dot {
    background: var(--orange);
}

.status-badge.outage .status-dot {
    background: var(--red);
}

.status-badge.unknown .status-dot {
    background: var(--grey-light);
}

/* ── Timeline bar (shared by overall + per-service) ───────────── */
.timeline-bar {
    display: flex;
    gap: 1.5px;
    height: 32px;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.service-card .timeline-bar {
    height: 24px;
}

.timeline-segment {
    flex: 1;
    min-width: 0;
    border-radius: 2px;
    transition: opacity 0.15s;
    position: relative;
    cursor: pointer;
}

.timeline-segment:hover {
    opacity: 0.7;
}

.timeline-segment.seg-green {
    background: var(--green);
}

.timeline-segment.seg-orange {
    background: var(--orange);
}

.timeline-segment.seg-red {
    background: var(--red);
}

.timeline-segment.seg-grey {
    background: var(--grey);
}

/* Tooltip */
.timeline-segment::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #0f172a;
    color: var(--text);
    font-size: 11px;
    white-space: nowrap;
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-light);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 10;
}

.timeline-segment:hover::after {
    opacity: 1;
}

.timeline-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 5px;
}

.timeline-footer {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-top: 6px;
}

.tl-label {
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Tab bar ───────────────────────────────────────────────────── */
.tab-bar {
    width: 100%;
    border-bottom: 1px solid var(--border);
    margin-top: 24px;
}

.tab-bar-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
}

.tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    padding: 12px 20px;
    margin-bottom: -1px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    color: var(--text);
    border-bottom-color: var(--blue);
    font-weight: 600;
}

/* ── View visibility ───────────────────────────────────────────── */
.hidden {
    display: none !important;
}

/* ── Uptime History view ───────────────────────────────────────── */
.view-uptime {
    max-width: var(--max-w);
    width: 100%;
    margin: 32px auto 48px;
    padding: 0 24px;
}

.uh-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 36px;
    flex-wrap: wrap;
    gap: 16px;
}

.uh-select {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 8px 36px 8px 14px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: border-color 0.15s;
}

.uh-select:focus {
    outline: none;
    border-color: var(--blue);
}

.uh-select option {
    background: var(--bg-card);
}

.uh-nav {
    display: flex;
    align-items: center;
    gap: 18px;
}

.uh-nav-btn {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    width: 32px;
    height: 32px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}

.uh-nav-btn:hover:not(:disabled) {
    background: var(--bg-card-hover);
}

.uh-nav-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

#uh-range-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dim);
    min-width: 196px;
    text-align: center;
}

/* ── Month grid ────────────────────────────────────────────────── */
.uh-months-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
}

.uh-loading {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    padding: 48px 0;
    font-size: 14px;
}

.uh-month-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 10px;
}

.uh-month-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.uh-month-pct {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.uh-month-pct.green {
    color: var(--green);
}

.uh-month-pct.orange {
    color: var(--orange);
}

.uh-month-pct.red {
    color: var(--red);
}

/* ── Weekday header row ────────────────────────────────────────── */
.uh-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
    margin-bottom: 3px;
}

.uh-weekdays span {
    font-size: 9px;
    font-weight: 700;
    color: var(--text-muted);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Calendar day cells ────────────────────────────────────────── */
.uh-calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

.cal-day,
.cal-empty {
    aspect-ratio: 1;
    border-radius: 3px;
}

.cal-day {
    cursor: default;
    position: relative;
    transition: opacity 0.15s;
}

.cal-day:hover {
    opacity: 0.72;
}

.cal-day.green {
    background: var(--green);
}

.cal-day.orange {
    background: var(--orange);
}

.cal-day.red {
    background: var(--red);
}

.cal-day.no-data {
    background: var(--grey);
}

.cal-day.future {
    background: var(--border);
}

/* Tooltip */
.cal-day[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #0f172a;
    color: var(--text);
    font-size: 11px;
    white-space: nowrap;
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-light);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 20;
}

.cal-day[data-tooltip]:hover::after {
    opacity: 1;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .uh-months-grid {
        grid-template-columns: 1fr;
        gap: 28px;
    }
}

@media (max-width: 600px) {
    .view-uptime {
        padding: 0 16px;
    }

    .tab-bar-inner {
        padding: 0 16px;
    }

    .uh-controls {
        flex-direction: column;
        align-items: flex-start;
    }

    #uh-range-label {
        min-width: auto;
    }
}

/* ── Footer ───────────────────────────────────────────────────── */
.footer {
    max-width: var(--max-w);
    width: 100%;
    margin: 48px auto 0;
    padding: 24px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 600px) {
    .header {
        padding: 20px 16px 0;
    }

    .overall-banner {
        padding: 0 16px;
    }

    .overall-banner-inner {
        padding: 22px 20px;
    }

    .uptime-summary {
        padding: 0 16px;
    }

    .uptime-value {
        font-size: 2.8rem;
    }

    .section-heading {
        padding: 0 16px;
    }

    .services {
        padding: 0 16px;
    }

    .service-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .timeline-bar {
        height: 20px;
    }

    .service-card .timeline-bar {
        height: 18px;
    }
}

/* ── Pulse animation ──────────────────────────────────────────── */
@keyframes pulse-green {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, .5);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(34, 197, 94, 0);
    }
}

.overall-icon.operational {
    animation: pulse-green 2.5s ease-in-out infinite;
}

/* ── Service error hint (inline on degraded/outage) ──────────── */
.service-error-hint {
    font-size: 12px;
    color: var(--orange);
    background: rgba(249, 115, 22, .08);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    margin-bottom: 10px;
    line-height: 1.5;
}

.service-error-hint .error-icon {
    margin-right: 4px;
}

/* ── Check log toggle button ─────────────────────────────────── */
.check-log-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    padding: 6px 0 0;
    transition: color 0.15s;
}

.check-log-toggle:hover {
    color: var(--text-dim);
}

/* ── Check log panel ─────────────────────────────────────────── */
.check-log-panel {
    margin-top: 10px;
    overflow-x: auto;
}

.check-log-panel .log-loading,
.check-log-panel .log-empty {
    font-size: 12px;
    color: var(--text-muted);
    padding: 12px 0;
}

.check-log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.check-log-table th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 600;
    padding: 4px 10px 6px 0;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.4px;
}

.check-log-table td {
    padding: 5px 10px 5px 0;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    color: var(--text-dim);
    white-space: nowrap;
}

.check-log-table td.log-reason {
    white-space: normal;
    word-break: break-word;
    max-width: 280px;
    color: var(--orange);
}

.log-ok {
    color: var(--green);
    font-weight: 700;
}

.log-fail {
    color: var(--red);
    font-weight: 700;
}