:root {
    /* Light mode variables */
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --online: #10b981;
    --offline: #ef4444;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --section-bg: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --divider: #f1f5f9;
    --hover-bg: #f8fafc;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --toggle-bg: #e2e8f0;
    --toggle-circle: #ffffff;
    --header-bg: #ffffff;
    --timeline-bg: #f1f5f9;
    --incident-bg: rgba(239, 68, 68, 0.05);
}

[data-theme="dark"] {
    --primary: #60a5fa;
    --primary-hover: #93c5fd;
    --online: #22c55e;
    --offline: #ef4444;
    --warning: #f59e0b;
    --bg: #1a1a1a;
    --section-bg: #2a2a2a;
    --text: #ffffff;
    --text-secondary: #a1a1aa;
    --border: #404040;
    --divider: #333333;
    --hover-bg: #333333;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --toggle-bg: #404040;
    --toggle-circle: #ffffff;
    --header-bg: #2a2a2a;
    --timeline-bg: #333333;
    --incident-bg: rgba(239, 68, 68, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Inter", sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

/* Header styles */
header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 32px;
    position: relative;
    padding: 24px;
    background-color: var(--header-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

h1 {
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 2rem;
    letter-spacing: -0.025em;
}

.subtitle {
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 1rem;
}

/* Status grid */
.status-grid {
    display: grid;
    gap: 12px;
}

.service-card {
    background-color: var(--section-bg);
    border-radius: 8px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: all 0.2s ease;
}

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

[data-theme="dark"] .service-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

.service-header {
    padding: 16px 20px;
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 16px;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.service-header:hover {
    background-color: var(--hover-bg);
}

.service-info {
    display: flex;
    align-items: center;
    min-width: 0;
}

.service-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 12px;
    flex-shrink: 0;
}

.service-indicator.online {
    background-color: var(--online);
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.service-indicator.offline {
    background-color: var(--offline);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

.service-name {
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.service-metrics {
    display: flex;
    align-items: center;
    gap: 16px;
}

.metric {
    text-align: center;
    min-width: 60px;
}

.metric-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.metric-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.status-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid;
}

.status-badge.online {
    background-color: rgba(34, 197, 94, 0.1);
    color: var(--online);
    border-color: rgba(34, 197, 94, 0.3);
}

.status-badge.offline {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--offline);
    border-color: rgba(239, 68, 68, 0.3);
}

/* Expand/Collapse indicator */
.expand-indicator {
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: transform 0.3s ease;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.expand-indicator:hover {
    background-color: var(--hover-bg);
    color: var(--text);
}

.service-card.expanded .expand-indicator {
    transform: rotate(180deg);
}

/* 30-Day Timeline (Status Page Style) */
.timeline-container {
    padding: 16px 20px;
    border-top: 1px solid var(--divider);
    background-color: var(--timeline-bg);
}

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

.timeline-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.timeline-legend {
    display: flex;
    gap: 12px;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.legend-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.legend-dot.online {
    background-color: var(--online);
}

.legend-dot.offline {
    background-color: var(--offline);
}

.legend-dot.partial {
    background-color: var(--warning);
}

.timeline {
    display: flex;
    gap: 2px;
    height: 40px;
    align-items: flex-end;
    padding: 0 4px;
    background-color: var(--section-bg);
    border-radius: 4px;
    border: 1px solid var(--border);
    width: 100%; /* Ensure it fills the parent */
}

.timeline-day {
    flex: 1 1 0;
    min-width: 8px;    /* Increased for better visibility */
    max-width: 32px;   /* Allow it to grow if fewer days */
    border-radius: 1px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.timeline-day.online {
    background-color: var(--online);
    height: 32px;
}

.timeline-day.offline {
    background-color: var(--offline);
    height: 32px;
}

.timeline-day.partial {
    background-color: var(--warning);
    height: 24px;
}

.timeline-day.no-data {
    background-color: var(--text-secondary);
    height: 8px;
    opacity: 0.3;
}

.timeline-day:hover {
    transform: scaleY(1.1);
    z-index: 1;
    filter: brightness(1.1);
}

.timeline-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--text);
    color: var(--section-bg);
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 20;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .timeline-tooltip {
    background-color: #ffffff;
    color: #1a1a1a;
}

.timeline-day:hover .timeline-tooltip {
    opacity: 1;
}

.timeline-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--text);
}

[data-theme="dark"] .timeline-tooltip::after {
    border-top-color: #ffffff;
}

/* Details panel */
.service-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.service-card.expanded .service-details {
    max-height: 300px;
}

.details-content {
    padding: 16px 20px;
    border-top: 1px solid var(--divider);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

.detail-item {
    text-align: center;
}

.detail-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
}

.detail-value a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

.detail-value a:hover {
    color: var(--primary-hover);
}

/* Incidents section */
.incidents-section {
    padding: 16px 20px;
    border-top: 1px solid var(--divider);
    background-color: var(--incident-bg);
}

.incidents-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.incident-item {
    padding: 8px 12px;
    background-color: var(--section-bg);
    border-radius: 6px;
    border-left: 3px solid var(--offline);
    margin-bottom: 8px;
}

.incident-item:last-child {
    margin-bottom: 0;
}

.incident-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.incident-duration {
    font-size: 0.75rem;
    color: var(--offline);
    font-weight: 600;
}

.incident-error {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Footer */
.last-updated {
    margin-top: 24px;
    padding: 12px 16px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    background-color: var(--section-bg);
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* Dark mode toggle */
.theme-toggle-wrapper {
    position: absolute;
    top: 24px;
    right: 24px;
}

.theme-toggle {
    background-color: var(--toggle-bg);
    border-radius: 20px;
    padding: 3px;
    width: 48px;
    height: 24px;
    display: flex;
    align-items: center;
    cursor: pointer;
    position: relative;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    transform: scale(1.05);
}

.toggle-circle {
    background-color: var(--toggle-circle);
    border-radius: 50%;
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
    transform: translateX(0);
    position: absolute;
    left: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

[data-theme="dark"] .toggle-circle {
    transform: translateX(24px);
}

.theme-icon {
    width: 12px;
    height: 12px;
    transition: all 0.3s ease;
}

.sun-icon {
    color: #f59e0b;
}

.moon-icon {
    color: #64748b;
}

[data-theme="dark"] .sun-icon {
    opacity: 0;
    transform: rotate(180deg);
}

[data-theme="light"] .moon-icon {
    opacity: 0;
    transform: rotate(-180deg);
}

/* Error message */
.error-message {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--offline);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid rgba(239, 68, 68, 0.3);
    margin-bottom: 20px;
}

/* Responsive */
@media (max-width: 768px) {
    .service-header {
        grid-template-columns: 1fr auto;
        gap: 12px;
    }

    .service-metrics {
        grid-column: 1 / -1;
        justify-content: space-around;
        margin-top: 8px;
        padding-top: 8px;
        border-top: 1px solid var(--divider);
    }

    .metric {
        min-width: auto;
    }

    .container {
        padding: 12px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .timeline-legend {
        display: none;
    }

    .details-content {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .timeline-day {
        min-width: 1px;
        max-width: 3px;
    }

    .theme-toggle-wrapper {
        top: 12px;
        right: 12px;
    }
}

@media (max-width: 480px) {
    .service-header {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .service-info {
        justify-self: start;
    }

    .service-metrics {
        margin-top: 12px;
        gap: 12px;
    }

    .details-content {
        grid-template-columns: 1fr;
    }
}
