:root {
    --color-operational: #10b981;
    --color-degraded: #eab308;
    --color-partial-outage: #ea580c;
    --color-major-outage: #dc2626;
    --color-maintenance: #3b82f6;
    
    --color-text-primary: #111827;
    --color-text-secondary: #6b7280;
    
    --bg-light: #f8fafc;
    --border-color: #e5e7eb;
    --border-hover: #d1d5db;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
    color: #374151;
    background-color: #ffffff;
    min-height: 100vh;
}

/* Header */
.header {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.header-nav {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--color-text-secondary);
    transition: color 0.2s ease;
}

.mobile-menu-btn:hover {
    color: #374151;
}

.mobile-menu-btn svg {
    width: 24px;
    height: 24px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.mobile-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    padding: 1rem 2rem;
    display: none;
    flex-direction: column;
    gap: 1rem;
}

.mobile-nav.active {
    display: flex;
}

.mobile-nav .nav-link {
    padding: 0.5rem 0;
}

.mobile-nav .subscribe-modal-btn {
    align-self: flex-start;
    margin-top: 0.5rem;
}

.nav-link {
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.2s ease;
}

.nav-link:hover {
    color: #374151;
}

.nav-link.current {
    color: var(--color-maintenance);
    font-weight: 600;
}

.subscribe-modal-btn {
    padding: 0.5rem 1rem;
    background: var(--bg-light);
    color: #374151;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.subscribe-modal-btn:hover {
    background: #f1f5f9;
    border-color: var(--border-hover);
}

/* Main Content */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem 3rem 2rem;
}

/* Status Bar */
.status-hero {
    padding: 2rem 0;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 2rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    font-weight: 600;
    font-size: 1.125rem;
    justify-content: center;
    width: 100%;
}

.status-indicator.operational { background: var(--color-operational); color: white; }
.status-indicator.degraded { background: var(--color-degraded); color: white; }
.status-indicator.partial_outage { background: var(--color-partial-outage); color: white; }
.status-indicator.major_outage { background: var(--color-major-outage); color: white; }
.status-indicator.maintenance { background: var(--color-maintenance); color: white; }

.status-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.status-icon svg {
    width: 14px;
    height: 14px;
    color: white;
}

.status-text {
    margin: 0;
}

/* Section Titles */
.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 2rem 0 1.5rem 0;
}

/* Active Issues Cards */
.active-issues, .active-maintenance, .history-section {
    margin-bottom: 3rem;
}

.issue-card {
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    background: #ffffff;
    /* Removed cursor: pointer from base class */
    text-decoration: none;
    color: inherit;
    display: block;
}

/* Specific styles for clickable link cards (Index & History pages) */
a.issue-card {
    cursor: pointer;
}

a.issue-card:hover {
    border-color: var(--border-hover);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    text-decoration: none;
    color: inherit;
}

.issue-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 1rem;
}

/* Specific larger title for Incident Details page */
.issue-card .issue-title-large {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 1rem;
}

.issue-description {
    color: var(--color-text-secondary);
    margin: 0 0 1rem 0;
}

/* Component Status in Issues */
.component-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.component-operational { color: #16a34a; }
.component-degraded { color: var(--color-degraded); }
.component-partial_outage { color: var(--color-partial-outage); }
.component-major_outage { color: var(--color-major-outage); }
.component-maintenance { color: var(--color-maintenance); }

/* Timeline Updates */
.updates-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #f3f4f6;
}

.updates-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 1rem;
}

.timeline-container {
    position: relative;
}

/* Hide the old static line */
.timeline-line {
    display: none;
}

.timeline-update {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
    position: relative;
    z-index: 0;
}

.timeline-update:last-child {
    margin-bottom: 0;
}

/* Draw connector line for each item except the last one */
.timeline-update:not(:last-child)::after {
    content: '';
    position: absolute;
    /* Center of the badge: Badge is 120px wide (60px center), Height ~28px (14px center) */
    top: 14px;
    left: 59px; /* 60px center - 1px half-width */
    width: 2px;
    /* Extend past the bottom margin to connect to the next item */
    bottom: -2rem; 
    background: var(--border-color);
    z-index: -1;
}

.timeline-status {
    width: 120px;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
    text-align: center;
    background: var(--bg-light);
    color: #374151;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
    position: relative;
    z-index: 1; /* Sit on top of the connector line */
}

.timeline-status.recent {
    background: #4b5563;
    color: white;
    border-color: #4b5563;
}

.timeline-details {
    flex: 1;
    min-width: 0;
}

.timeline-date {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.timeline-message {
    color: #374151;
    line-height: 1.5;
    font-size: 0.9rem;
}

/* Components Section */
.components-section {
    margin-bottom: 3rem;
}

.component-group {
    margin-bottom: 1.5rem;
}

.group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.group-header:hover {
    background: #f1f5f9;
    border-color: var(--border-hover);
}

.group-header.collapsed {
    border-radius: 8px;
    margin-bottom: 0;
}

.group-header.expanded {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom: none;
    margin-bottom: 0;
}

.group-title {
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    margin: 0;
}

.group-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

.group-status {
    font-weight: 500;
}

.group-toggle-icon {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}

.group-toggle-icon.expanded {
    transform: rotate(180deg);
}

.group-components {
    border: 1px solid var(--border-color);
    border-top: none;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    background: #ffffff;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.group-components.collapsed {
    max-height: 0;
    border: none;
}

.group-components.expanded {
    max-height: none;
}

.group-components .component-item {
    border: none;
    border-bottom: 1px solid #f3f4f6;
    border-radius: 0;
    margin: 0;
}

.group-components .component-item:last-child {
    border-bottom: none;
}

.ungrouped-components {
    display: grid;
    gap: 1rem;
}

.component-item {
    display: flex;
    align-items: flex-start;
    padding: 1rem 1.5rem;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: border-color 0.2s ease;
}

.ungrouped-components .component-item:hover {
    border-color: var(--border-color);
}

.component-name {
    font-weight: 500;
    color: var(--color-text-primary);
}

/* History Section */
.history-btn, .back-btn {
    padding: 0.75rem 1.5rem;
    background: var(--bg-light);
    color: #374151;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.back-btn {
    margin: 2rem 0;
}

.history-btn:hover, .back-btn:hover {
    background: #f1f5f9;
    border-color: var(--border-hover);
    color: #374151;
    text-decoration: none;
}

/* Postmortem Styles (Incident Page) */
.postmortem-section {
    margin-top: 4rem;
    margin-bottom: 3rem;
}

.postmortem-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
}

.postmortem-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 1rem;
}

.postmortem-summary {
    color: var(--color-text-secondary);
    margin-bottom: 2rem;
    font-size: 1rem;
    line-height: 1.6;
}

.postmortem-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 0.75rem;
    margin-top: 1.5rem;
}

.postmortem-section-title:first-of-type {
    margin-top: 0;
}

.postmortem-content {
    color: #374151;
    line-height: 1.6;
    white-space: pre-wrap;
}

.postmortem-meta {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #f3f4f6;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

.components-description {
    color: var(--color-text-secondary);
    margin: 0 0 2rem 0;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95) translateY(-20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 1.5rem 0 1.5rem;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: #374151;
}

.modal-body {
    padding: 1.5rem;
}

.modal-description {
    color: var(--color-text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.modal-subscription-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
}

.form-input {
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-maintenance);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.btn-primary {
    padding: 0.75rem 1.5rem;
    background: var(--color-maintenance);
    color: white;
    border: 1px solid var(--color-maintenance);
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.btn-primary:hover {
    background: #2563eb;
    border-color: #2563eb;
}

.btn-primary:disabled {
    background: #9ca3af;
    border-color: #9ca3af;
    cursor: not-allowed;
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    background: var(--bg-light);
    color: #374151;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.btn-secondary:hover {
    background: #f1f5f9;
    border-color: var(--border-hover);
}

.modal-message {
    margin-top: 1rem;
}

.message {
    padding: 1rem;
    border-radius: 6px;
    margin-top: 1rem;
    font-size: 0.875rem;
}

.message-success {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.message-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.error-message {
    padding: 2rem;
    text-align: center;
    color: #dc2626;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    margin: 2rem 0;
}

/* Uptime Bar Styles */
.service-uptime {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.uptime-main {
    display: flex;
    align-items: center;
    gap: 12px;
}

.uptime-bar-container {
    flex: 1;
    height: 32px;
    background-color: #fafbfc;
    border-radius: 3px;
    overflow: visible;
    display: flex;
    gap: 2px;
    position: relative;
}

.uptime-day {
    flex: 1;
    background-color: var(--color-operational);
    transition: opacity 0.2s ease;
    cursor: pointer;
    position: relative;
}

.uptime-day:hover {
    opacity: 0.8;
}

.uptime-day.partial { background-color: var(--color-partial-outage); }
.uptime-day.down { background-color: var(--color-major-outage); }
.uptime-day.maintenance { background-color: var(--color-maintenance); }
.uptime-day.no-data { background-color: var(--border-color); }

.uptime-tooltip {
    position: fixed;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px 16px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 10000;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    white-space: normal;
    max-width: 280px;
}

.uptime-tooltip.visible {
    opacity: 1;
    pointer-events: auto;
}

.uptime-tooltip-date {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-primary);
    margin-bottom: 6px;
}

.uptime-tooltip-status {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
    line-height: 1.4;
}

.uptime-tooltip-link {
    display: inline-block;
    font-size: 13px;
    color: var(--color-maintenance);
    text-decoration: none;
    font-weight: 500;
    transition: text-decoration 0.2s ease;
    padding: 2px 0;
}

.uptime-tooltip-link:hover {
    text-decoration: underline;
}

.uptime-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: #97a0af;
    gap: 16px;
    position: relative;
}

.uptime-label-left, .uptime-label-right {
    white-space: nowrap;
}

.uptime-percentage-label {
    font-size: 12px;
    font-weight: 400;
    color: #97a0af;
    white-space: nowrap;
    position: relative;
    flex: 1;
    text-align: center;
}

.uptime-percentage-label::before,
.uptime-percentage-label::after {
    content: '';
    position: absolute;
    top: 50%;
    height: 1px;
    background-color: #dfe1e6;
}

.uptime-percentage-label::before {
    right: calc(50% + 60px);
    left: 0;
}

.uptime-percentage-label::after {
    left: calc(50% + 60px);
    right: 0;
}

/* Loading States */
.loading {
    padding: 2rem;
    text-align: center;
    color: var(--color-text-secondary);
}

/* Skeleton Loading */
@keyframes skeleton-loading {
    0% { background-color: #f3f4f6; }
    50% { background-color: #e5e7eb; }
    100% { background-color: #f3f4f6; }
}

.skeleton {
    animation: skeleton-loading 1.5s infinite;
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
}

.skeleton-status-bar { height: 60px; border-radius: 8px; margin-bottom: 2rem; }
.skeleton-section-title { height: 28px; width: 200px; border-radius: 4px; margin-bottom: 1.5rem; }
.skeleton-issue-card { border: 1px solid var(--border-color); border-radius: 8px; padding: 1.5rem; margin-bottom: 1rem; }
.skeleton-issue-title { height: 24px; width: 60%; border-radius: 4px; margin-bottom: 1rem; animation: skeleton-loading 1.5s infinite; }
.skeleton-issue-description { height: 16px; width: 100%; border-radius: 4px; margin-bottom: 0.5rem; animation: skeleton-loading 1.5s infinite; }
.skeleton-issue-description:last-child { width: 80%; margin-bottom: 0; }
.skeleton-component-item { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.5rem; background: #ffffff; border: 1px solid var(--border-color); border-radius: 8px; margin-bottom: 1rem; }
.skeleton-component-name { height: 20px; width: 150px; border-radius: 4px; animation: skeleton-loading 1.5s infinite; }
.skeleton-component-status { height: 20px; width: 120px; border-radius: 4px; animation: skeleton-loading 1.5s infinite; }
.skeleton-group-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.5rem; background: var(--bg-light); border: 1px solid var(--border-color); border-radius: 8px; margin-bottom: 1.5rem; }
.skeleton-group-title { height: 20px; width: 150px; border-radius: 4px; animation: skeleton-loading 1.5s infinite; }
.skeleton-group-status { height: 20px; width: 100px; border-radius: 4px; animation: skeleton-loading 1.5s infinite; }

/* Skeleton Helpers for Detail Pages */
.skeleton-card { border-radius: 8px; padding: 1.5rem; margin-bottom: 1rem; border: 1px solid var(--border-color); background: #ffffff; }
.skeleton-title { height: 2rem; background-color: #f3f4f6; border-radius: 4px; margin-bottom: 1rem; width: 70%; animation: skeleton-loading 1.5s infinite; }
.skeleton-text { height: 1rem; background-color: #f3f4f6; border-radius: 4px; margin-bottom: 0.75rem; animation: skeleton-loading 1.5s infinite; }
.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 60%; }
.skeleton-text.long { width: 100%; }
.skeleton-components { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.skeleton-component { height: 1.5rem; width: 120px; background-color: #f3f4f6; border-radius: 4px; animation: skeleton-loading 1.5s infinite; }
.skeleton-timeline { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid #f3f4f6; }
.skeleton-timeline-title { height: 1rem; background-color: #f3f4f6; border-radius: 4px; margin-bottom: 1rem; width: 100px; animation: skeleton-loading 1.5s infinite; }
.skeleton-update { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1.5rem; }
.skeleton-status { width: 120px; height: 1.5rem; background-color: #f3f4f6; border-radius: 4px; flex-shrink: 0; animation: skeleton-loading 1.5s infinite; }
.skeleton-update-content { flex: 1; }
.skeleton-update-date { height: 0.875rem; background-color: #f3f4f6; border-radius: 4px; margin-bottom: 0.5rem; width: 150px; animation: skeleton-loading 1.5s infinite; }
.skeleton-update-text { height: 1rem; background-color: #f3f4f6; border-radius: 4px; margin-bottom: 0.5rem; width: 100%; animation: skeleton-loading 1.5s infinite; }
.skeleton-update-text:last-child { width: 85%; margin-bottom: 0; }
.skeleton-postmortem-title { height: 1.5rem; background-color: #f3f4f6; border-radius: 4px; margin-bottom: 1rem; width: 50%; animation: skeleton-loading 1.5s infinite; }
.skeleton-postmortem-summary { height: 1rem; background-color: #f3f4f6; border-radius: 4px; margin-bottom: 0.75rem; width: 100%; animation: skeleton-loading 1.5s infinite; }
.skeleton-postmortem-summary:last-of-type { width: 95%; margin-bottom: 2rem; }

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .header-container { padding: 0 1rem; position: relative; }
    .nav-links { display: none; }
    .mobile-menu-btn { display: block; }
    .main-content { padding: 0 1rem 3rem 1rem; }
    .status-hero { padding: 2rem 0; }
    .status-indicator { font-size: 1rem; padding: 1rem 1.5rem; }
    .component-item { padding: 1rem; }
    .timeline-line { left: 60px; }
    .uptime-bar-container { height: 28px; }
    .uptime-labels { font-size: 10px; }
    .uptime-percentage-label { font-size: 11px; }
    .issue-card .issue-title-large { font-size: 1.125rem; }
    .postmortem-card { padding: 1rem; }
}
