@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --card-hover-border: #cbd5e1;
    
    --text-main: #475569;      /* Slate-600 */
    --text-bright: #0f172a;    /* Slate-900 */
    --text-white: #ffffff;
    
    --primary: #E31E24;        /* YourERPCoach Crimson Red */
    --primary-hover: #c1171c;
    --primary-glow: rgba(227, 30, 36, 0.15);
    
    --secondary: #0A192F;      /* YourERPCoach Dark Navy */
    --secondary-hover: #112240;
    
    /* Light Mode Status Colors */
    --status-green: #15803d;
    --status-green-glow: rgba(21, 128, 61, 0.25);
    --status-green-bg: #f0fdf4;
    --status-green-border: #bbf7d0;
    
    --status-blue: #1d4ed8;
    --status-blue-glow: rgba(29, 78, 216, 0.25);
    --status-blue-bg: #eff6ff;
    --status-blue-border: #bfdbfe;
    
    --status-yellow: #b45309;
    --status-yellow-glow: rgba(180, 83, 9, 0.25);
    --status-yellow-bg: #fffbeb;
    --status-yellow-border: #fef3c7;
    
    --status-red: #b91c1c;
    --status-red-glow: rgba(185, 28, 28, 0.25);
    --status-red-bg: #fef2f2;
    --status-red-border: #fee2e2;
    
    --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, rgba(227, 30, 36, 0.02) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(10, 25, 47, 0.03) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    height: 100vh;
    overflow: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   Header Section & Global Banner
   ========================================================================== */

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

.brand {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.main-title {
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--secondary);
    position: relative;
    display: inline-block;
}

.main-title::after {
    content: '';
    display: block;
    width: 30px;
    height: 2.5px;
    background: var(--primary);
    border-radius: 2px;
    margin-top: 2px;
}

.subtitle {
    font-size: 0.78rem;
    color: var(--text-main);
    font-weight: 500;
}

.live-time-badge {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.pulse-dot {
    width: 6px;
    height: 6px;
    background-color: var(--status-green);
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 0 var(--status-green-glow);
    animation: pulse 2s infinite;
}

/* Global Announcement Banner */
.global-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 8px;
    padding: 6px 12px;
    margin-bottom: 12px;
    transition: all 0.3s ease;
    border: 1px solid var(--card-border);
    border-left-width: 4px;
    box-shadow: 0 2px 8px rgba(10, 25, 47, 0.03);
}

.global-banner.operational {
    background: #f0fdf4;
    border-color: var(--status-green-border);
    border-left-color: var(--status-green);
    color: var(--status-green);
}

.global-banner.checking {
    background: #f8fafc;
    border-color: var(--card-border);
    border-left-color: var(--text-main);
    color: var(--text-main);
}

.global-banner.degraded {
    background: #fffbeb;
    border-color: var(--status-yellow-border);
    border-left-color: var(--status-yellow);
    color: var(--status-yellow);
}

.global-banner.outage {
    background: #fef2f2;
    border-color: var(--status-red-border);
    border-left-color: var(--status-red);
    color: var(--status-red);
}

.banner-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.banner-icon {
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
    border: 1px solid currentColor;
}

.banner-text h3 {
    font-size: 0.82rem;
    font-weight: 750;
    color: var(--text-bright);
    margin-bottom: 1px;
}

.banner-text p {
    font-size: 0.72rem;
    color: var(--text-main);
}

/* ==========================================================================
   Status Sections & List Containers
   ========================================================================== */

#dashboard-sections {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    align-items: start;
}

/* 3-Column Layout placements with explicit rows to fix vertical misalignment */
.status-section:nth-child(1) {
    grid-column: 1;
    grid-row: 1 / span 2;
}
.status-section:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
}
.status-section:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
    margin-top: 12px; /* Spacing between stacked sections in Column 2 */
}
.status-section:nth-child(4) {
    grid-column: 3;
    grid-row: 1 / span 2;
}

@media (max-width: 1024px) {
    #dashboard-sections {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .status-section:nth-child(1) { grid-column: auto; grid-row: auto; }
    .status-section:nth-child(2) { grid-column: auto; grid-row: auto; }
    .status-section:nth-child(3) { grid-column: auto; grid-row: auto; margin-top: 0; }
    .status-section:nth-child(4) { grid-column: auto; grid-row: auto; }
}

@media (max-width: 768px) {
    #dashboard-sections {
        grid-template-columns: 1fr;
    }
}

.status-section {
    margin-bottom: 0px;
}

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

.section-title {
    font-size: 0.98rem;
    font-weight: 750;
    color: var(--secondary);
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.section-title::before {
    content: '';
    display: inline-block;
    width: 3.5px;
    height: 14px;
    background: var(--primary);
    border-radius: 1.5px;
}

.services-list {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 4px 15px rgba(10, 25, 47, 0.02);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.services-list:hover {
    border-color: var(--card-hover-border);
    box-shadow: 0 8px 25px rgba(10, 25, 47, 0.05);
}

/* Service Row Layout */
.service-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    border-bottom: 1px solid var(--card-border);
    transition: background-color 0.2s ease;
}

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

.service-item:hover {
    background-color: rgba(10, 25, 47, 0.008);
}

/* Left Metadata area */
.service-meta {
    display: flex;
    align-items: center;
    gap: 16px;
}

.service-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: #f1f5f9;       /* Slate-100 */
    border: 1px solid #cbd5e1;  /* Slate-300 */
    border-radius: 10px;
    transition: all 0.2s;
}

.service-item:hover .service-icon-wrapper {
    border-color: var(--primary-hover);
    background: var(--primary-glow);
}

.service-info {
    display: flex;
    flex-direction: column;
    gap: 0px;
    min-width: 0; /* Enable flex-child text-overflow truncation */
    flex: 1;
}

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

.service-url {
    font-size: 0.65rem;
    color: var(--primary);
    opacity: 0.85;
    font-family: monospace;
    cursor: pointer;
    text-decoration: underline;
    transition: opacity 0.2s, color 0.2s;
    width: fit-content;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 100%;
}

.service-url:hover {
    opacity: 1;
    color: var(--primary-hover);
}

/* Right Status Area */
.service-status-area {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* Latency Badge */
.latency-badge {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-main);
    font-family: monospace;
}

/* Status Code Badge */
.status-code-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 600;
    font-family: monospace;
    border: 1px solid transparent;
}

.status-code-badge.code-success {
    background-color: var(--status-green-bg);
    border-color: var(--status-green-border);
    color: var(--status-green);
}

.status-code-badge.code-client-error {
    background-color: var(--status-yellow-bg);
    border-color: var(--status-yellow-border);
    color: var(--status-yellow);
}

.status-code-badge.code-server-error {
    background-color: var(--status-red-bg);
    border-color: var(--status-red-border);
    color: var(--status-red);
}

/* Service Status Badge */
.service-status {
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    border: 1px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
}

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

/* Status variants */
.status-operational {
    color: var(--status-green);
    background-color: var(--status-green-bg);
    border-color: var(--status-green-border);
}

.status-maintenance {
    color: var(--status-blue);
    background-color: var(--status-blue-bg);
    border-color: var(--status-blue-border);
}

.status-degraded {
    color: var(--status-yellow);
    background-color: var(--status-yellow-bg);
    border-color: var(--status-yellow-border);
}

.status-outage {
    color: var(--status-red);
    background-color: var(--status-red-bg);
    border-color: var(--status-red-border);
}

.status-checking {
    color: var(--text-main);
    background-color: #f1f5f9;
    border-color: var(--card-border);
}

.status-unavailable {
    color: var(--text-main);
    background-color: #f1f5f9;
    border-color: var(--card-border);
}

/* Custom status dots */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.dot-operational {
    background-color: var(--status-green);
    box-shadow: 0 0 0 0 var(--status-green-glow);
    animation: pulse-green 2s infinite;
}

.status-dot.dot-degraded {
    background-color: var(--status-yellow);
    box-shadow: 0 0 0 0 var(--status-yellow-glow);
    animation: pulse-yellow 2s infinite;
}

.status-dot.dot-outage {
    background-color: var(--status-red);
    box-shadow: 0 0 0 0 var(--status-red-glow);
    animation: pulse-red 2s infinite;
}

.status-dot.dot-maintenance {
    background-color: var(--status-blue);
    box-shadow: 0 0 0 0 var(--status-blue-glow);
    animation: pulse-blue 2s infinite;
}

.status-dot.dot-checking {
    background-color: #94a3b8;
    box-shadow: 0 0 0 0 rgba(148, 163, 184, 0.25);
    animation: pulse-gray 1.5s infinite;
}

.status-dot.dot-unavailable {
    background-color: #64748b;
    box-shadow: 0 0 0 0 rgba(100, 116, 139, 0.25);
}

/* Dynamic CSS Spinners */
.status-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(15, 23, 42, 0.1);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   Legend Card & Details
   ========================================================================== */

.legend-card {
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
    border: none;
    padding: 0;
    margin-top: auto;
    margin-bottom: 8px;
    box-shadow: none;
}

.legend-title {
    display: none; /* Hide title to save vertical space */
}

.legend-grid {
    display: flex;
    justify-content: center;
    gap: 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-main);
    font-weight: 700;
}

.legend-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.legend-indicator.status-operational {
    background-color: var(--status-green);
    box-shadow: 0 0 4px var(--status-green-glow);
}

.legend-indicator.status-degraded {
    background-color: var(--status-yellow);
    box-shadow: 0 0 4px var(--status-yellow-glow);
}

.legend-indicator.status-outage {
    background-color: var(--status-red);
    box-shadow: 0 0 4px var(--status-red-glow);
}

.legend-indicator.status-maintenance {
    background-color: var(--status-blue);
    box-shadow: 0 0 4px var(--status-blue-glow);
}

/* ==========================================================================
   Footer Section (Navy Background matching brand footer)
   ========================================================================== */

.footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0px;
    padding: 8px 16px;
    background-color: var(--secondary);
    border-radius: 8px;
    font-size: 0.72rem;
    color: #94a3b8;            /* Slate-400 */
    flex-wrap: wrap;
    gap: 12px;
    box-shadow: 0 2px 10px rgba(10, 25, 47, 0.1);
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 6px;
}

.footer-brand span {
    color: #94a3b8;
}

.footer-brand a {
    color: var(--text-white);
    text-decoration: none;
    font-weight: 700;
    transition: color 0.2s;
}

.footer-brand a:hover {
    color: var(--primary);
}

.footer-links {
    display: flex;
    gap: 24px;
}

.footer-links a {
    color: #cbd5e1;            /* Slate-200 */
    text-decoration: none;
    transition: color 0.2s;
    font-weight: 600;
}

.footer-links a:hover {
    color: var(--text-white);
}

.coming-soon {
    cursor: not-allowed;
    opacity: 0.5;
}

.coming-soon:hover {
    color: #cbd5e1 !important;
}

/* ==========================================================================
   Keyframes & Animations
   ========================================================================== */

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(21, 128, 61, 0.4);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(21, 128, 61, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(21, 128, 61, 0);
    }
}

@keyframes pulse-green {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(21, 128, 61, 0.4); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(21, 128, 61, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(21, 128, 61, 0); }
}

@keyframes pulse-yellow {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(180, 83, 9, 0.4); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(180, 83, 9, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(180, 83, 9, 0); }
}

@keyframes pulse-red {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(185, 28, 28, 0.4); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(185, 28, 28, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(185, 28, 28, 0); }
}

@keyframes pulse-blue {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(29, 78, 216, 0.4); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(29, 78, 216, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(29, 78, 216, 0); }
}

@keyframes pulse-gray {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(148, 163, 184, 0.3); }
    70% { transform: scale(1); box-shadow: 0 0 0 5px rgba(148, 163, 184, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(148, 163, 184, 0); }
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    body {
        height: auto;
        overflow: auto;
    }
    
    .container {
        padding: 16px 12px;
        height: auto;
    }
    
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .service-item {
        padding: 8px 12px;
        flex-direction: row;
        align-items: center;
        gap: 12px;
    }
    
    .service-status-area {
        align-self: auto;
    }
    
    .footer {
        flex-direction: column;
        align-items: flex-start;
        padding: 16px 16px;
        gap: 12px;
    }
}