/* =============================================
   Custom Properties
   ============================================= */
:root {
    --bg: #f0f4f2;
    --fg: #17261e;
    --card: #ffffff;
    --border: rgba(23, 38, 30, 0.12);
    --muted: #5a6e62;
    --secondary: #e8eeea;
    --accent: #d4e0d8;
    --radius: 12px;
    --emerald-400: #34d399;
    --emerald-500: #10b981;
    --emerald-600: #059669;
    --yellow-400: #facc15;
    --yellow-500: #eab308;
    --yellow-600: #ca8a04;
    --orange-400: #fb923c;
    --orange-500: #f97316;
    --orange-600: #ea580c;
    --red-400: #f87171;
    --red-500: #ef4444;
    --red-600: #dc2626;
    --blue-400: #60a5fa;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --violet-600: #7c3aed;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--fg);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1 { font-size: 1.5rem; font-weight: 500; }
h2 { font-size: 1.25rem; font-weight: 500; }
h3 { font-size: 1.125rem; font-weight: 500; }
h4 { font-size: 1rem; font-weight: 500; }
button { font-family: inherit; font-size: 1rem; font-weight: 500; }

/* =============================================
   Animations
   ============================================= */
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInLeft {
    from { opacity: 0; transform: translateX(-16px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes scaleInY {
    from { transform: scaleY(0); }
    to { transform: scaleY(1); }
}

@keyframes ping {
    75%, 100% { transform: scale(2); opacity: 0; }
}

@keyframes slideDown {
    from { height: 0; opacity: 0; }
    to { height: var(--target-height); opacity: 1; }
}

@keyframes slideUp {
    from { height: var(--current-height); opacity: 1; }
    to { height: 0; opacity: 0; }
}

@keyframes refreshPulse {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* =============================================
   Header
   ============================================= */
.header {
    position: relative;
    overflow: hidden;
    animation: fadeInDown 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

.header__gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom right, #17261e, #1e3328, #17261e);
}

.header__radial1 {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at top right, rgba(52, 211, 153, 0.12), transparent 60%);
}

.header__radial2 {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at bottom left, rgba(52, 211, 153, 0.08), transparent 50%);
}

.header__content {
    position: relative;
    max-width: 72rem;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.header__badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    animation: fadeIn 0.5s 0.2s both;
}

.header__icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    background: rgba(16, 185, 129, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.header__icon svg { color: var(--emerald-400); }

.header__badge span {
    color: rgba(52, 211, 153, 0.8);
    font-size: 0.875rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.header__title {
    color: #fff;
    margin-bottom: 0.5rem;
    animation: fadeInUp 0.5s 0.3s both;
}

.header__subtitle {
    color: rgba(167, 243, 208, 0.6);
    font-size: 0.875rem;
    animation: fadeIn 0.5s 0.4s both;
}

/* Stat Cards */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-top: 2rem;
    animation: fadeInUp 0.5s 0.5s both;
}

.stat-card {
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(8px);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-card__label {
    font-size: 0.6875rem;
    color: rgba(110, 231, 183, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-card__value {
    color: #fff;
    font-size: 1.375rem;
    margin-top: 0.125rem;
}

.stat-card__sub {
    font-size: 0.6875rem;
    color: rgba(255, 255, 255, 0.4);
}

/* =============================================
   Main Content
   ============================================= */
.main {
    max-width: 72rem;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* =============================================
   Legend
   ============================================= */
.legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 1.25rem 1.25rem;
    margin-bottom: 1.5rem;
    animation: fadeIn 0.4s 0.5s both;
}

.legend__item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.legend__dot {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 3px;
}

.legend__dot--operational { background: var(--emerald-500); }
.legend__dot--degraded { background: var(--yellow-500); }
.legend__dot--partial { background: var(--orange-500); }
.legend__dot--major { background: var(--red-500); }
.legend__dot--maintenance { background: var(--blue-400); }

.legend__item span {
    font-size: 0.75rem;
    color: var(--muted);
}

/* =============================================
   Services Grid
   ============================================= */
.services-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

/* =============================================
   Service Card
   ============================================= */
.service-card {
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1.25rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.3s, transform 0.2s;
    animation: fadeInUp 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
    animation-delay: calc(var(--i) * 60ms);
}

.service-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.service-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.service-card__info {
    flex: 1;
    min-width: 0;
}

.service-card__title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.service-card__title-row h3 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.service-card__desc {
    font-size: 0.8125rem;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Pulse Dot */
.pulse-dot {
    position: relative;
    display: flex;
    width: 0.625rem;
    height: 0.625rem;
    flex-shrink: 0;
}

.pulse-dot__ping {
    position: absolute;
    display: inline-flex;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    opacity: 0.75;
    animation: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.pulse-dot__core {
    position: relative;
    display: inline-flex;
    border-radius: 50%;
    width: 0.625rem;
    height: 0.625rem;
}

.pulse-dot--yellow .pulse-dot__ping { background: var(--yellow-400); }
.pulse-dot--yellow .pulse-dot__core { background: var(--yellow-500); }
.pulse-dot--orange .pulse-dot__ping { background: var(--orange-400); }
.pulse-dot--orange .pulse-dot__core { background: var(--orange-500); }
.pulse-dot--red .pulse-dot__ping { background: var(--red-400); }
.pulse-dot--red .pulse-dot__core { background: var(--red-500); }

/* Status Badge */
.service-card__badge {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    flex-shrink: 0;
    margin-left: 0.75rem;
}

.service-card__badge span { font-size: 0.75rem; }

.service-card__badge--operational { background: rgba(16, 185, 129, 0.1); }
.service-card__badge--operational span { color: var(--emerald-600); }
.service-card__badge--degraded { background: rgba(234, 179, 8, 0.1); }
.service-card__badge--degraded span { color: var(--yellow-600); }
.service-card__badge--partial_outage { background: rgba(249, 115, 22, 0.1); }
.service-card__badge--partial_outage span { color: var(--orange-600); }
.service-card__badge--major_outage { background: rgba(239, 68, 68, 0.1); }
.service-card__badge--major_outage span { color: var(--red-600); }
.service-card__badge--maintenance { background: rgba(59, 130, 246, 0.1); }
.service-card__badge--maintenance span { color: var(--blue-600); }

/* Service Stats */
.service-card__stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.service-card__stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.service-card__stat-icon {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.service-card__stat-icon--uptime { background: rgba(16, 185, 129, 0.1); }
.service-card__stat-icon--uptime svg { color: var(--emerald-600); }
.service-card__stat-icon--response { background: rgba(59, 130, 246, 0.1); }
.service-card__stat-icon--response svg { color: var(--blue-600); }
.service-card__stat-icon--checked { background: rgba(139, 92, 246, 0.1); }
.service-card__stat-icon--checked svg { color: var(--violet-600); }

.service-card__stat-label {
    font-size: 0.6875rem;
    color: var(--muted);
}

.service-card__stat-value {
    font-size: 0.8125rem;
    color: var(--fg);
}

/* =============================================
   Uptime Bar
   ============================================= */
.uptime-bar {
    width: 100%;
    animation: fadeInUp 0.4s both;
    animation-delay: calc(var(--i) * 40ms);
}

.uptime-bar__bars {
    display: flex;
    gap: 2px;
    align-items: flex-end;
    position: relative;
}

.uptime-bar__day {
    flex: 1;
    position: relative;
    cursor: pointer;
}

.uptime-bar__bar {
    height: 2rem;
    border-radius: 2px;
    opacity: 0.85;
    transition: opacity 0.15s, transform 0.15s, box-shadow 0.15s;
    transform-origin: bottom;
    animation: scaleInY 0.3s ease-out both;
    animation-delay: calc(var(--i) * 4ms + var(--d) * 5ms);
}

.uptime-bar__day:hover .uptime-bar__bar {
    opacity: 1;
    transform: scaleY(1.1);
    box-shadow: 0 0 0 2px rgba(23, 38, 30, 0.3);
}

.uptime-bar__bar--operational { background: var(--emerald-500); }
.uptime-bar__bar--degraded { background: var(--yellow-500); }
.uptime-bar__bar--partial { background: var(--orange-500); }
.uptime-bar__bar--major { background: var(--red-500); }
.uptime-bar__bar--maintenance { background: var(--blue-400); }

.uptime-bar__labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.375rem;
}

.uptime-bar__labels span {
    font-size: 0.6875rem;
    color: var(--muted);
}

/* =============================================
   Tooltip (global, positioned by JS)
   ============================================= */
.tooltip {
    position: fixed;
    z-index: 1000;
    background: #17261e;
    color: #fff;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}

.tooltip.visible { opacity: 1; }

.tooltip__date {
    font-size: 0.6875rem;
    color: rgb(110, 231, 183);
    margin-bottom: 0.125rem;
}

.tooltip__status { font-size: 0.75rem; }
.tooltip__uptime { font-size: 0.6875rem; color: rgba(255, 255, 255, 0.7); }
.tooltip__response { font-size: 0.6875rem; color: rgba(255, 255, 255, 0.7); }

.tooltip__incidents {
    font-size: 0.6875rem;
    color: #fdba74;
}

.tooltip__arrow {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #17261e;
}

/* =============================================
   Incidents Section
   ============================================= */
.incidents-section {
    margin-top: 3rem;
    animation: fadeIn 0.5s 0.8s both;
}

.incidents-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--fg);
    padding: 0;
}

.incidents-toggle__icon {
    margin-left: 0.25rem;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 0.375rem;
    background: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.incidents-toggle:hover .incidents-toggle__icon { background: var(--accent); }

.incidents-toggle__icon svg { color: var(--muted); }

.incidents-toggle__count {
    font-size: 0.8125rem;
    color: var(--muted);
    margin-left: 0.25rem;
}

.incidents-list {
    overflow: hidden;
    transition: height 0.3s ease;
}

.incidents-list__inner { max-width: 42rem; }

/* =============================================
   Incident Card
   ============================================= */
.incident-card {
    position: relative;
    padding-left: 1.5rem;
    padding-bottom: 1.5rem;
    animation: fadeInLeft 0.4s ease-out both;
    animation-delay: calc(var(--i) * 80ms + 0.8s);
}

.incident-card:last-child { padding-bottom: 0; }

.incident-card__timeline {
    position: absolute;
    left: 7px;
    top: 0.75rem;
    bottom: 0;
    width: 1px;
    background: var(--border);
}

.incident-card:last-child .incident-card__timeline { display: none; }

.incident-card__dot {
    position: absolute;
    left: 0;
    top: 0.5rem;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 2px solid var(--card);
}

.incident-card__dot--resolved { background: var(--emerald-500); }
.incident-card__dot--monitoring { background: var(--yellow-500); }
.incident-card__dot--investigating { background: var(--orange-500); }
.incident-card__dot--identified { background: var(--red-500); }

.incident-card__content {
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.3s;
}

.incident-card__content:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.incident-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.incident-card__badge {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.incident-card__badge span { font-size: 0.6875rem; }

.incident-card__badge--resolved { background: rgba(16, 185, 129, 0.1); }
.incident-card__badge--resolved span { color: var(--emerald-600); }
.incident-card__badge--monitoring { background: rgba(234, 179, 8, 0.1); }
.incident-card__badge--monitoring span { color: var(--yellow-600); }
.incident-card__badge--investigating { background: rgba(249, 115, 22, 0.1); }
.incident-card__badge--investigating span { color: var(--orange-600); }
.incident-card__badge--identified { background: rgba(239, 68, 68, 0.1); }
.incident-card__badge--identified span { color: var(--red-600); }

.incident-card__desc {
    font-size: 0.8125rem;
    color: var(--muted);
    margin-bottom: 0.75rem;
}

.incident-card__meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--muted);
    flex-wrap: wrap;
}

.incident-card__service {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    border-radius: 0.375rem;
    background: var(--secondary);
}

/* =============================================
   Footer
   ============================================= */
.footer {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    text-align: center;
    animation: fadeIn 0.5s 1s both;
}

.footer__main {
    font-size: 0.8125rem;
    color: var(--muted);
}

.footer__sub {
    font-size: 0.6875rem;
    color: rgba(90, 110, 98, 0.6);
    margin-top: 0.25rem;
}

.footer__refresh {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.refresh-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--emerald-500);
    animation: ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

/* Refreshing flash */
.service-card--refreshing {
    animation: refreshPulse 0.4s ease;
}

/* =============================================
   Responsive
   ============================================= */
@media (min-width: 640px) {
    .header__content { padding: 3rem 1.5rem; }
    .main { padding: 2rem 1.5rem; }
    .stat-cards { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1024px) {
    .services-grid { grid-template-columns: repeat(2, 1fr); }
}
