:root {
    --bg-main: #f8fafc;          /* Clean off-white slate background */
    --bg-card: #ffffff;          /* Crisp white cards */
    --border-color: #e2e8f0;     /* Soft modern light border */
    --text-main: #0f172a;        /* Deep slate for high-contrast readability */
    --text-muted: #64748b;       /* Balanced muted secondary text */
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-brand: #2563eb;      /* Vibrant blue accent */
    --ms-blue: #0078d4;
    --ms-blue-dark: #005a9e;
    --ms-blue-light: #deecf9;
    --healthy-bg: #dff6dd;
    --healthy-text: #107c10;
    --healthy-border: #bad80a;
    --degraded-bg: #fff4ce;
    --degraded-text: #835c00;
    --degraded-border: #ffd335;
    --outage-bg: #fde7e9;
    --outage-text: #a4262c;
    --outage-border: #d13438;
}

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;

    /* Ambient Opacity Big Color Dots across different background coordinates */
    background-image: 
        radial-gradient(circle at 10% 15%, rgba(59, 130, 246, 0.12) 0%, transparent 35%),
        radial-gradient(circle at 85% 20%, rgba(236, 72, 153, 0.10) 0%, transparent 40%),
        radial-gradient(circle at 50% 60%, rgba(16, 185, 129, 0.08) 0%, transparent 45%),
        radial-gradient(circle at 20% 85%, rgba(245, 158, 11, 0.09) 0%, transparent 35%),
        radial-gradient(circle at 90% 90%, rgba(139, 92, 246, 0.10) 0%, transparent 40%);
    background-attachment: fixed;
}

.container {
    display: grid;
    grid-template-columns: 260px 1fr; /* 1st col fixed sidebar, 2nd col takes remaining space */
    height: 100vh;
    transition: grid-template-columns 0.3s ease;
}

/* When the sidebar is collapsed, shrink grid column down */
.container.sidebar-collapsed {
    grid-template-columns: 60px 1fr;
}

iframe {
    width: 100%;
    max-height: 70dvh;
    height: 400px;
    border: none;
    background-color: #ffffff;
}

#incidents-container {
    display: none;
    flex-direction: column;
    height: calc(100vh - 40px);
}

#incident {
    width: 100%;
    flex: 1;
    border: none;
    background-color: #ffffff;
    display: block;
    height: calc(100vh - 40px);
    max-height: calc(100vh - 40px);
}

/* --- Left Sidebar UI --- */
aside {
    position: relative;
    background-color: var(--bg-card);
    border-right: 1px solid var(--border-color);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: padding 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.02);
}

aside.collapsed {
    padding: 30px 8px;
}

aside h2 { 
    font-size: 0.95rem; 
    text-transform: uppercase; 
    letter-spacing: 0.1em; 
    margin: 0 0 35px 15px; 
    color: var(--color-brand);
    font-weight: 800;
}

aside.collapsed .sidebar-title,
aside.collapsed .menu-item {
    font-size: 0;
    padding: 12px 0;
    text-align: center;
    text-indent: -9999px;
}

.collapse-btn {
    position: absolute;
    top: 5px;
    right: 15px;
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 0.8rem;
    transition: transform 0.3s ease, background 0.2s ease;
    z-index: 10;
}

.collapse-btn:hover {
    background: #e2e8f0;
    color: var(--text-main);
}

aside.collapsed .collapse-btn {
    right: 0;
    left: 0;
    margin: 0 auto;
    width: fit-content;
    transform: rotate(180deg);
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    border-radius: 8px;
    transition: all 0.2s ease;
    cursor: pointer;
    color: var(--text-muted);
}

.menu-item i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.menu-item.active { 
    background-color: rgba(37, 99, 235, 0.1); 
    color: var(--color-brand); 
    font-weight: 600;
    border-left: 3px solid var(--color-brand);
}

.menu-item:hover:not(.active) { 
    background-color: #f1f5f9; 
    color: var(--text-main); 
}

.view-as-wrapper {
    padding: 12px 18px;
    font-size: 0.8rem;
    transition: padding 0.3s ease;
}

.view-as-wrapper a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    text-decoration: none;
}

/* Collapsed States */
.container.sidebar-collapsed aside {
    padding: 30px 8px;
}

.container.sidebar-collapsed .menu-item {
    padding: 12px 0;
    justify-content: center;
}

.container.sidebar-collapsed .view-as-wrapper {
    padding: 12px 0;
    display: flex;
    justify-content: center;
}

.container.sidebar-collapsed .menu-text {
    display: none !important;
}

/* --- Center Window Layout --- */
main {
    padding: 5px;
    overflow-y: auto;
    display: grid;
    grid-template-rows: auto auto 1fr;
    gap: 25px;
    align-content: start;
}

.header-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 5px;
}

header, .top-header-container {
    position: relative;
}

.header-date {
    position: absolute;
    top: 16px;
    right: 18px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.02em;
    margin: 0;
}

.header-panel h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 6px 0;
    letter-spacing: -0.02em;
    color: var(--text-main);
}

.grid-top {
    display: grid;
    grid-template-columns: 2fr 2fr;
    grid-template-rows: auto;
    gap: 15px;
    align-items: start;
}

/* Card Structures */
.card, .card2, .card3 {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
}

.card h3 {
    font-size: 1.1rem;
    margin: 0 0 20px 0;
    font-weight: 600;
    color: var(--text-main);
}

/* Global Circular Badge & Banner */
.global-banner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 140px;
}

.global-banner h3 { 
    font-size: 1.3rem; 
    margin: 10px 0; 
}

.global-status-indicator {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-top: 15px;
    text-transform: uppercase;
}

/* Fleet Metrics Styling */
.service-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color);
}

.service-row:last-child { 
    border-bottom: none; 
}

.service-name { 
    font-weight: 500; 
    font-size: 0.95rem; 
    color: var(--text-main);
}

.service-latency { 
    font-size: 0.8rem; 
    color: var(--text-muted); 
    margin-left: 8px; 
}

/* Status Badges */
.bg-success { 
    background-color: #d1fae5; 
    color: #065f46; 
    border: 1px solid #a7f3d0; 
}

.bg-warning { 
    background-color: #fef3c7; 
    color: #92400e; 
    border: 1px solid #fde68a; 
}

.bg-danger { 
    background-color: #fee2e2; 
    color: #991b1b; 
    border: 1px solid #fca5a5; 
}

/* Incident Panels */
.incident-alert {
    background: #f8fafc;
    padding: 20px;
    margin-top: 15px;
    border-radius: 4px 12px 12px 4px;
    border-left: 4px solid #94a3b8;
    border-top: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.incident-alert.investigating { border-left-color: #8b5cf6; }
.incident-alert.identified    { border-left-color: #d97706; }
.incident-alert.monitoring    { border-left-color: #f97316; }
.incident-alert.resolved      { border-left-color: #10b981; }

.incident-alert i.fa {
    margin-right: 8px;
    font-size: 1.1em;
}

/* Base Badge Rules */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 700; /* Increased font weight for crispness */
    line-height: 1;
    letter-spacing: 0.02em;
    text-transform: capitalize;
}

/* Category Badge (Replaces the faded light blue/white combo) */
.bg-danger {
    background-color: #fee2e2 !important; /* Soft light red background */
    color: #991b1b !important;            /* Deep bold red text */
    border: 1px solid #fca5a5;            /* Crisp border frame */
}

/* Base Priority Badge */
.badge-priority {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 0.03em;
}

/* URGENT: Soft pink background, red border, dark red text */
.priority-urgent {
    background-color: #fde8e8;
    color: #881337;
    border: 1px solid #f87171;
}

/* HIGH: Very light blush background, light red border, dark red text */
.priority-high {
    background-color: #fff1f2;
    color: #9f1239;
    border: 1px solid #fda4af;
}

/* MEDIUM: Light cyan background, bright cyan border, dark teal text */
.priority-medium {
    background-color: #ecfeff;
    color: #0e7490;
    border: 1px solid #22d3ee;
}

/* LOW: Soft light green background, bright green border, dark green text */
.priority-low {
    background-color: #f0fdf4;
    color: #15803d;
    border: 1px solid #4ade80;
}

/* 10DAYS & 2WEEKS: Solid royal blue background, no border, bold white text */
.priority-10days,
.priority-2weeks {
    background-color: #2563eb;
    color: #ffffff;
    border: none;
}

/* WEB: Light cream/yellow background, tan border, dark brownish-red text */
.priority-web {
    background-color: #fefce8;
    color: #713f12;
    border: 1px solid #fde047;
}

/* --- Right Chat Stream Panel --- */
.chat-panel {
    background-color: var(--bg-card);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.02);
}

.chat-header { 
    padding: 24px; 
    border-bottom: 1px solid var(--border-color); 
}

.chat-header h3 { 
    font-size: 1.1rem; 
    margin: 0 0 4px 0; 
    font-weight: 600; 
    color: var(--text-main);
}

.chat-messages { 
    flex: 1; 
    padding: 24px; 
    overflow-y: auto; 
    display: flex; 
    flex-direction: column; 
    gap: 16px; 
}

.msg-bubble { 
    background: #f8fafc; 
    padding: 14px; 
    border-radius: 8px; 
    border: 1px solid var(--border-color); 
}

.msg-user { 
    font-weight: 600; 
    font-size: 0.85rem; 
    color: var(--color-brand); 
    margin-bottom: 6px; 
}

.msg-text { 
    font-size: 0.9rem; 
    line-height: 1.4; 
    color: #334155; 
}

.chat-footer { 
    padding: 24px; 
    border-top: 1px solid var(--border-color); 
    background: #f8fafc; 
}

.chat-footer input[type="text"] {
    width: 100%;
    padding: 12px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    box-sizing: border-box;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.chat-footer input[type="text"]:focus { 
    border-color: var(--color-brand); 
    outline: none; 
}

.chat-footer button {
    width: 100%;
    padding: 12px;
    background: var(--color-brand);
    border: none;
    color: white;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-footer button:hover { 
    background: #1d4ed8; 
}

/* Status Indicators */
.status-good { color: var(--color-success); }
.status-warn { color: var(--color-warning); }
.status-bad  { color: var(--color-danger); }

/* Admin Buttons */
.admin-resolve-btn {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.admin-resolve-btn:hover {
    background-color: var(--color-success);
    color: #ffffff;
    border-color: var(--color-success);
}

.admin-revert-btn {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.admin-revert-btn:hover {
    background-color: var(--color-warning);
    color: #ffffff;
    border-color: var(--color-warning);
}

/* Floating Helpdesk Action Button */
.btn-floating-helpdesk {
    position: fixed;
    top: 20px;
    right: 350px;
    z-index: 9999;
    
    display: inline-flex;
    align-items: center;
    gap: 8px;
    
    padding: 10px 16px;
    background: #15803d;
    color: #ffffff;
    font-weight: 600;
    font-size: 0.85rem;
    text-decoration: none;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease-in-out;
}

.btn-floating-helpdesk:hover {
    background: #166534;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
    color: #ffffff;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto 1fr;
        height: auto;
    }
    
    aside {
        flex-direction: row;
        padding: 10px;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        white-space: nowrap;
        gap: 8px;
    }
    
    .collapse-btn {
        display: none !important;
    }
    
    .menu-item {
        margin-bottom: 0;
        padding: 8px 14px;
        font-size: 0.85rem;
    }
    
    main {
        padding: 1px;
        gap: 15px;
    }
    
    .grid-top {
        grid-template-columns: 1fr !important;
    }
    
    .header-panel {
        flex-direction: column;
        align-items: start;
        gap: 8px;
    }
    
    .header-panel h1 {
        font-size: 1.4rem;
    }
    
    .service-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .service-status-block {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .incident-header-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .incident-actions {
        width: 100%;
        justify-content: space-between;
    }

    .btn-floating-helpdesk {
        top: auto;
        bottom: 20px;
        right: 20px;
    }
}
/* Fancy Ticket Description Box */
.ticket-description {
    background-color: #f8fafc;
    border-left: 0px solid var(--color-brand, #2563eb);
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #334155;
    margin-top: 8px;
    word-break: break-word; /* Prevents long URLs or strings from breaking card layouts */
}

/* Styled Auto-Detected Links */
.ticket-description .ticket-link {
    color: #2563eb;
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px solid rgba(37, 99, 235, 0.3);
    transition: all 0.2s ease-in-out;
    padding-bottom: 1px;
}

.ticket-description .ticket-link:hover {
    color: #1d4ed8;
    border-bottom-color: #1d4ed8;
    background-color: rgba(37, 99, 235, 0.08);
    border-radius: 2px;
}

.ticket-description .ticket-link i {
    font-size: 0.75em;
    margin-left: 2px;
}
/* Desktop Defaults: Hide mobile topbar & overlay */
.mobile-topbar,
.mobile-overlay {
    display: none;
}

/* ==========================================
   MOBILE MEDIA QUERY (<= 768px)
   ========================================== */
@media (max-width: 768px) {
    /* Hide Desktop Collapse Button on Mobile */
    #sidebar-collapse-btn {
        display: none !important;
    }

    /* Mobile Top Header Bar */
    .mobile-topbar {
        display: flex;
        align-items: center;
        height: 50px;
        background-color: var(--bg-sidebar, #0f172a);
        padding: 0 15px;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 9998;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .hamburger-btn {
        background: transparent;
        border: none;
        color: #ffffff;
        font-size: 1.3rem;
        cursor: pointer;
        padding: 5px 10px;
    }

    .mobile-title {
        color: #ffffff;
        font-weight: 600;
        margin-left: 10px;
        font-size: 1rem;
    }

    /* Backdrop Blur/Overlay when Menu Opens */
    .mobile-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        z-index: 9998;
    }

    .mobile-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Convert Sidebar to Slide-Out Drawer */
    #sidebar {
        position: fixed;
        top: 0;
        left: -260px; /* Hide off-screen by default */
        width: 250px !important;
        height: 100vh;
        z-index: 9999;
        transition: transform 0.3s ease-in-out;
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.4);
        padding-top: 15px;
    }

    /* Active Class to Slide Menu In */
    #sidebar.mobile-open {
        transform: translateX(260px);
    }

    /* Shift main content down so mobile topbar doesn't obscure it */
    body, .container {
        padding-top: 55px !important;
    }
}
@media (max-width: 768px) {

    /* Slide-out drawer container */
    #sidebar {
        position: fixed;
        top: 0;
        left: -260px;
        width: 250px !important;
        height: 100vh;
        background-color: var(--bg-sidebar, #0f172a);
        z-index: 9999;
        transition: transform 0.3s ease-in-out;
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.4);
        
        /* Flex column to stack items from top to bottom */
        display: flex !important;
        flex-direction: column !important;
        padding: 60px 15px 20px 15px; /* Top padding clears the topbar */
        box-sizing: border-box;
    }

    /* Open state */
    #sidebar.mobile-open {
        transform: translateX(260px);
    }

    /* Individual menu rows */
    #sidebar .menu-item {
        display: flex !important;
        flex-direction: row !important; /* Icon and text side-by-side */
        align-items: center !important;
        justify-content: flex-start !important;
        width: 100% !important;
        padding: 12px 15px !important;
        margin-bottom: 8px !important;
        border-radius: 8px;
        box-sizing: border-box;
    }

    /* Fix menu icon & text alignment inside each row */
    #sidebar .menu-item i {
        font-size: 1.2rem;
        width: 25px; /* Fixed width keeps text vertically aligned across rows */
        text-align: center;
        margin-right: 12px;
    }

    #sidebar .menu-text {
        display: inline-block !important;
        font-size: 0.95rem;
        margin: 0 !important;
    }

    /* View As footer stays at the bottom of the drawer */
    #sidebar .view-as-wrapper {
        margin-top: auto !important;
        padding-top: 15px;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        width: 100%;
    }

    #sidebar .view-as-wrapper a {
        display: flex;
        align-items: center;
        padding: 10px 15px;
    }
}

/* Base Desktop Styling */
.fleet-metrics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.fleet-toggle-icon {
    display: none; /* Hide toggle arrow on desktop */
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

/* ==========================================
   MOBILE MEDIA QUERY (<= 768px)
   ========================================== */
@media (max-width: 768px) {
    .fleet-metrics-header {
        cursor: pointer;
        user-select: none;
        padding: 5px 0;
    }

    /* Show arrow indicator on mobile */
    .fleet-toggle-icon {
        display: inline-block;
    }

    /* Collapse content by default on mobile */
    .fleet-metrics-body {
        display: none;
        margin-top: 10px;
    }

    /* Expanded class states toggled by JS */
    .fleet-metrics-body.is-expanded {
        display: block !important;
    }

    .fleet-metrics-header.is-expanded .fleet-toggle-icon {
        transform: rotate(180deg);
    }
}

/* Base Desktop Styles */
.clock-desktop {
    display: inline;
}

.clock-mobile {
    display: none; /* Hide compact time on desktop */
}

/* ==========================================
   MOBILE MEDIA QUERY (<= 768px)
   ========================================== */
@media (max-width: 768px) {
    .clock-desktop {
        display: none !important; /* Hide full date string on mobile */
    }

    .clock-mobile {
        display: inline !important; /* Show compact time on mobile */
        font-size: 0.85rem;
        font-weight: 600;
        white-space: nowrap;
    }
}