/* ============================================================================
   DAT Platform - System Health Dashboard
   Dark theme with balanced 2-row layout
   ============================================================================ */

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

.health-page {
    min-height: 100vh;
    background: #0a0a10;
    color: #e2e8f0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    position: relative;
    overflow-x: hidden;
}

/* Decorative background elements */
.health-page::before {
    content: '';
    position: fixed;
    top: 80px;
    left: -150px;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.06), transparent 70%);
    border-radius: 50%;
    z-index: 0;
    pointer-events: none;
}

.health-page::after {
    content: '';
    position: fixed;
    bottom: -50px;
    right: -80px;
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, rgba(34, 197, 94, 0.05), transparent 70%);
    border-radius: 50%;
    z-index: 0;
    pointer-events: none;
}

/* Navigation inherited from style.css — no overrides needed */

/* Main Content */
.health-main {
    padding: 120px 24px 40px;
    max-width: 1500px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* Header */
.health-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.health-title h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
}

.health-title p {
    color: #64748b;
    font-size: 0.85rem;
}

.health-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.8rem;
    color: #94a3b8;
}

.update-time {
    font-family: 'JetBrains Mono', monospace;
    color: #a5b4fc;
    font-weight: 500;
}

/* Status Banner */
.status-banner {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 12px;
    padding: 12px 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.status-banner .status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-banner.operational {
    background: rgba(34, 197, 94, 0.08);
    border-color: rgba(34, 197, 94, 0.2);
}

.status-banner.degraded {
    background: rgba(234, 179, 8, 0.08);
    border-color: rgba(234, 179, 8, 0.2);
}

.status-banner .status-text {
    font-size: 0.875rem;
    font-weight: 600;
    color: #e2e8f0;
}

/* Status Dot */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.checking {
    background: #6366f1;
    animation: pulse 1.5s infinite;
}
.status-dot.healthy, .status-dot.operational {
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}
.status-dot.warning, .status-dot.degraded {
    background: #eab308;
    box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.15);
}
.status-dot.error, .status-dot.down {
    background: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

/* ============================================================================
   Row 1: Core Services (wide, 2-col grid) + Security sidebar
   ============================================================================ */
.health-row-1 {
    display: grid;
    grid-template-columns: 1fr 240px;
    gap: 16px;
    margin-bottom: 16px;
}

.health-sidebar-right {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ============================================================================
   Row 1.5: Platform Services + Gateways
   ============================================================================ */
.health-row-1-5 {
    display: grid;
    grid-template-columns: 1fr 240px;
    gap: 16px;
    margin-bottom: 16px;
}

/* Platform card accent */
.card-platform {
    border-color: rgba(59, 130, 246, 0.12);
}
.card-platform:hover {
    border-color: rgba(59, 130, 246, 0.25);
}
.card-platform h2 svg {
    color: #60a5fa;
}

/* Platform icon accent */
.service-item .icon.icon-platform {
    background: rgba(59, 130, 246, 0.12);
}
.service-item .icon.icon-platform svg {
    color: #93c5fd;
}

/* Gateway card accent */
.card-gateways {
    border-color: rgba(34, 211, 238, 0.12);
}
.card-gateways:hover {
    border-color: rgba(34, 211, 238, 0.25);
}
.card-gateways h2 svg {
    color: #67e8f9;
}

/* Gateway icon accent */
.service-item .icon.icon-gateway {
    background: rgba(34, 211, 238, 0.12);
}
.service-item .icon.icon-gateway svg {
    color: #a5f3fc;
}

/* Gateway detail text */
.gw-detail {
    font-size: 0.6rem;
    color: #475569;
    display: block;
    margin-top: 1px;
}

/* ============================================================================
   Row 2: Trust (wide) + Infrastructure + SDKs
   ============================================================================ */
.health-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

/* ============================================================================
   Card Styles
   ============================================================================ */
.health-card {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 18px;
    position: relative;
    z-index: 1;
    backdrop-filter: blur(10px);
    transition: border-color 0.3s;
}

.health-card:hover {
    border-color: rgba(99, 102, 241, 0.2);
}

.health-card h2 {
    font-size: 0.65rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.health-card h2 svg {
    width: 14px;
    height: 14px;
    color: #6366f1;
}

/* Trust card accent */
.card-trust {
    border-color: rgba(139, 92, 246, 0.12);
}
.card-trust:hover {
    border-color: rgba(139, 92, 246, 0.25);
}
.card-trust h2 svg {
    color: #a78bfa;
}

/* ============================================================================
   Service Grid (2-col for core services)
   ============================================================================ */
.service-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

/* 2-col variant for trust infrastructure */
.service-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

/* Service List (single column, for infrastructure) */
.service-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ============================================================================
   Service Items
   ============================================================================ */
.service-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    transition: all 0.2s;
}

.service-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.1);
}

.service-item.healthy {
    border-left: 3px solid rgba(34, 197, 94, 0.6);
}
.service-item.error {
    border-left: 3px solid rgba(239, 68, 68, 0.6);
}

.service-item .icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.service-item .icon svg {
    width: 16px;
    height: 16px;
    color: #a5b4fc;
}

/* Trust infrastructure icon accent */
.service-item .icon.icon-trust {
    background: rgba(139, 92, 246, 0.12);
}
.service-item .icon.icon-trust svg {
    color: #c4b5fd;
}

/* Infrastructure icon accent */
.service-item .icon.icon-infra {
    background: rgba(34, 197, 94, 0.1);
}
.service-item .icon.icon-infra svg {
    color: #86efac;
}

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

.service-item .name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #e2e8f0;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.service-item .port {
    font-size: 0.65rem;
    color: #475569;
    font-family: 'JetBrains Mono', monospace;
}

.service-item .status {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.service-item .latency {
    font-size: 0.55rem;
    color: #64748b;
    font-family: 'JetBrains Mono', monospace;
    opacity: 0.7;
    padding: 1px 4px;
    border-radius: 3px;
}

/* ============================================================================
   Security Grid
   ============================================================================ */
.security-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
}

.security-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    transition: all 0.2s;
}

.security-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.security-item.passed {
    background: rgba(34, 197, 94, 0.08);
    border-color: rgba(34, 197, 94, 0.15);
}
.security-item.passed .icon {
    background: rgba(34, 197, 94, 0.15);
}
.security-item.passed .icon svg {
    color: #22c55e;
}

.security-item .icon {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: rgba(99, 102, 241, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.security-item .icon svg {
    width: 12px;
    height: 12px;
    color: #a5b4fc;
}

.security-item .name {
    font-size: 0.7rem;
    font-weight: 500;
    color: #94a3b8;
    flex: 1;
}

/* ============================================================================
   SDK Items
   ============================================================================ */
.sdk-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sdk-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    transition: all 0.2s;
}

.sdk-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.sdk-item .icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sdk-item .icon.python {
    background: linear-gradient(135deg, #3b82f6, #fbbf24);
}
.sdk-item .icon.javascript {
    background: #fbbf24;
}

.sdk-item .icon svg {
    width: 16px;
    height: 16px;
}

.sdk-item .icon.python svg { color: #fff; }
.sdk-item .icon.javascript svg { color: #1e293b; }

.sdk-item .info {
    flex: 1;
}

.sdk-item .name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #e2e8f0;
    display: block;
}

.sdk-item .version {
    font-size: 0.65rem;
    color: #475569;
    font-family: 'JetBrains Mono', monospace;
}

/* ============================================================================
   Incidents
   ============================================================================ */
.incidents-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.15);
    border-radius: 10px;
    color: #22c55e;
    font-size: 0.8rem;
    font-weight: 500;
}

.incidents-empty svg {
    width: 18px;
    height: 18px;
}

/* ============================================================================
   Footer
   ============================================================================ */
.health-footer {
    margin-top: 28px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    color: #475569;
}

.health-footer a {
    color: #64748b;
    text-decoration: none;
    margin-left: 20px;
    transition: color 0.2s;
}

.health-footer a:hover {
    color: #6366f1;
}

/* ============================================================================
   Buttons
   ============================================================================ */
.health-main .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.health-main .btn-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.health-main .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.health-main .btn-outline {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
}

.health-main .btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
}

/* ============================================================================
   2-Column Layout: Status (left) + E2E (right)
   ============================================================================ */
.health-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 16px;
    align-items: start;
}

.health-left {
    min-width: 0; /* prevent grid blowout */
}

.health-right {
    position: sticky;
    top: 76px;
    max-height: calc(100vh - 96px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(99, 102, 241, 0.3) transparent;
}

.health-right::-webkit-scrollbar {
    width: 4px;
}
.health-right::-webkit-scrollbar-track {
    background: transparent;
}
.health-right::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 2px;
}

/* ============================================================================
   E2E Test Results
   ============================================================================ */
.health-row-3 {
    margin-top: 16px;
}

.card-e2e {
    border-color: rgba(59, 130, 246, 0.12);
}
.card-e2e:hover {
    border-color: rgba(59, 130, 246, 0.25);
}
.card-e2e h2 svg {
    color: #60a5fa;
}

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

.e2e-header h2 {
    margin-bottom: 0;
}

.e2e-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.e2e-last-run {
    font-size: 0.7rem;
    color: #64748b;
    font-family: 'JetBrains Mono', monospace;
}

.health-main .btn-sm {
    padding: 5px 10px;
    font-size: 0.72rem;
}

.health-main .btn-sm svg {
    width: 12px;
    height: 12px;
}

/* E2E Summary Bar */
.e2e-summary {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.e2e-summary-stat {
    text-align: center;
    min-width: 60px;
}

.e2e-stat-value {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    color: #e2e8f0;
    font-family: 'JetBrains Mono', monospace;
}

.e2e-summary-stat.passed .e2e-stat-value {
    color: #22c55e;
}
.e2e-summary-stat.failed .e2e-stat-value {
    color: #ef4444;
}

.e2e-stat-label {
    display: block;
    font-size: 0.6rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.e2e-progress-bar {
    flex: 1;
    min-width: 120px;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
}

.e2e-progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease, background 0.3s ease;
    width: 0%;
}

.e2e-progress-fill.perfect {
    background: linear-gradient(90deg, #22c55e, #4ade80);
}
.e2e-progress-fill.good {
    background: linear-gradient(90deg, #eab308, #facc15);
}
.e2e-progress-fill.poor {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

/* E2E Placeholder */
.e2e-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 32px 16px;
    color: #475569;
    font-size: 0.85rem;
    text-align: center;
}

.e2e-placeholder svg {
    color: #334155;
}

.e2e-placeholder-sub {
    font-size: 0.7rem;
    color: #334155;
    max-width: 420px;
}

/* E2E Phases */
.e2e-phases {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.e2e-phase {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.e2e-phase.passed {
    border-left: 3px solid rgba(34, 197, 94, 0.5);
}
.e2e-phase.failed {
    border-left: 3px solid rgba(239, 68, 68, 0.5);
}
.e2e-phase.running {
    border-left: 3px solid rgba(99, 102, 241, 0.5);
}

.e2e-phase-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.e2e-phase-header:hover {
    background: rgba(255, 255, 255, 0.03);
}

.e2e-phase-icon {
    font-size: 0.85rem;
    flex-shrink: 0;
}

.e2e-phase-name {
    flex: 1;
    font-size: 0.8rem;
    font-weight: 600;
    color: #e2e8f0;
}

.e2e-phase-count {
    font-size: 0.7rem;
    color: #64748b;
    font-family: 'JetBrains Mono', monospace;
}

.e2e-phase-status {
    flex-shrink: 0;
}

.e2e-phase-chevron {
    color: #475569;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.e2e-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    font-family: 'JetBrains Mono', monospace;
}

.e2e-badge.passed {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}
.e2e-badge.failed {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* E2E Test Items */
.e2e-phase-tests {
    padding: 0 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.e2e-test-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
}

.e2e-test-item.passed {
    background: rgba(34, 197, 94, 0.05);
}
.e2e-test-item.failed {
    background: rgba(239, 68, 68, 0.05);
}

.e2e-test-icon {
    font-weight: 700;
    font-size: 0.75rem;
    flex-shrink: 0;
    width: 14px;
    text-align: center;
}

.e2e-test-item.passed .e2e-test-icon {
    color: #22c55e;
}
.e2e-test-item.failed .e2e-test-icon {
    color: #ef4444;
}

.e2e-test-name {
    flex: 1;
    color: #cbd5e1;
    font-weight: 500;
}

.e2e-test-detail {
    color: #64748b;
    font-size: 0.65rem;
    font-family: 'JetBrains Mono', monospace;
}

.e2e-test-time {
    color: #475569;
    font-size: 0.6rem;
    font-family: 'JetBrains Mono', monospace;
    min-width: 40px;
    text-align: right;
}

/* Spinner animation */
@keyframes e2e-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spin {
    animation: e2e-spin 0.8s linear infinite;
}

/* ============================================================================
   Responsive
   ============================================================================ */
@media (max-width: 1400px) {
    .health-layout {
        grid-template-columns: 1fr 360px;
    }
}

@media (max-width: 1200px) {
    .health-layout {
        grid-template-columns: 1fr;
    }
    .health-right {
        position: static;
        max-height: none;
        overflow-y: visible;
    }
    .health-row-1 {
        grid-template-columns: 1fr;
    }
    .health-row-1-5 {
        grid-template-columns: 1fr;
    }
    .health-sidebar-right {
        flex-direction: row;
    }
    .health-sidebar-right .health-card {
        flex: 1;
    }
    .health-row-2 {
        grid-template-columns: 1fr 1fr;
    }
    .card-sdks {
        grid-column: 1 / -1;
    }
}

@media (max-width: 900px) {
    .service-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .health-layout {
        grid-template-columns: 1fr;
    }
    .health-right {
        position: static;
        max-height: none;
        overflow-y: visible;
    }
    .health-row-1 {
        grid-template-columns: 1fr;
    }
    .health-row-1-5 {
        grid-template-columns: 1fr;
    }
    .health-sidebar-right {
        flex-direction: column;
    }
    .health-row-2 {
        grid-template-columns: 1fr;
    }
    .card-sdks {
        grid-column: auto;
    }
    .service-grid {
        grid-template-columns: 1fr;
    }
    .service-grid-2 {
        grid-template-columns: 1fr;
    }
    .nav-links {
        display: none;
    }
    .health-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .health-page::before,
    .health-page::after {
        display: none;
    }
}
