:root {
    --primary: #dc2626;
    --primary-dark: #991b1b;
    --primary-light: #f87171;
    --secondary: #ef4444;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --info: #0284c7;
    --dark: #1e293b;
    --light: #f8fafc;
    --border: #e2e8f0;
    --text: #64748b;
    --text-dark: #0f172a;
    --card-bg: #ffffff;
    --header-height: 72px;
}

body {
    background-color: #f1f5f9;
    color: var(--text-dark);
}

.monitor-container {
    padding: 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
}

/* Status Banner */
.status-banner {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-left: 6px solid var(--success);
}

.status-banner.warning {
    border-left-color: var(--warning);
}

.status-banner.error {
    border-left-color: var(--danger);
}

.status-info h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.status-info p {
    color: var(--text);
    margin: 0;
}

.status-indicator-large {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #f0fdf4;
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    color: var(--success);
    font-weight: 600;
}

.status-indicator-ring {
    height: 12px;
    width: 12px;
    background-color: var(--success);
    border-radius: 50%;
    position: relative;
}

.status-indicator-ring::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    background-color: var(--success);
    border-radius: 50%;
    opacity: 0.3;
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.3;
        transform: scale(1);
    }

    50% {
        opacity: 0.1;
        transform: scale(1.5);
    }
}

/* Endpoint Cards Grid */
.endpoint-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.endpoint-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.endpoint-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.endpoint-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.endpoint-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: #f1f5f9;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.endpoint-status {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
}

.status-active {
    background: #dcfce7;
    color: #166534;
}

.status-slow {
    background: #fef9c3;
    color: #854d0e;
}

.status-down {
    background: #fee2e2;
    color: #991b1b;
}

.endpoint-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 0.25rem;
}

.endpoint-url {
    font-size: 0.875rem;
    color: var(--text);
    font-family: monospace;
    background: #f8fafc;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.endpoint-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.metric-item {
    display: flex;
    flex-direction: column;
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text);
    margin-bottom: 0.25rem;
}

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

.metric-value.latency-good {
    color: var(--success);
}

.metric-value.latency-ok {
    color: var(--warning);
}

.metric-value.latency-bad {
    color: var(--danger);
}

/* Live Requests Section */
.live-monitor-section {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

.monitor-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    height: 100%;
}

.monitor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.monitor-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.log-container {
    background: #1e293b;
    border-radius: 8px;
    padding: 1rem;
    height: 300px;
    overflow-y: auto;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    color: #e2e8f0;
}

.log-entry {
    margin-bottom: 0.5rem;
    display: flex;
    gap: 1rem;
    opacity: 0;
    animation: fadeIn 0.3s forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

.log-time {
    color: #94a3b8;
    min-width: 80px;
}

.log-method {
    color: #f59e0b;
    font-weight: 600;
    min-width: 50px;
}

.log-status {
    color: #22c55e;
    min-width: 40px;
}

.log-status.error {
    color: #ef4444;
}

.log-path {
    color: #38bdf8;
}

/* Chart Area */
.chart-container-wrapper {
    position: relative;
    height: 250px;
    width: 100%;
}

/* Response Time Sparkline */
.latency-sparkline {
    height: 40px;
    display: flex;
    align-items: flex-end;
    gap: 2px;
    margin-top: 10px;
}

.spark-bar {
    flex: 1;
    background: var(--primary-light);
    border-radius: 2px 2px 0 0;
    opacity: 0.5;
    transition: height 0.3s, background 0.3s;
}

.spark-bar:hover {
    opacity: 1;
    background: var(--primary);
}

@media (max-width: 992px) {
    .live-monitor-section {
        grid-template-columns: 1fr;
    }
}

/* Custom Dropdown Styles */
.filter-box {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
    z-index: 1000;
}

.filter-box:has(.custom-dropdown.active) {
    z-index: 10001;
}

.filter-label {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.95rem;
    margin: 0;
}

.custom-dropdown {
    position: relative;
    width: 100%;
    z-index: 1;
    min-width: 250px;
}

.custom-dropdown.active {
    z-index: 10001 !important;
    position: relative;
}

.custom-dropdown.active .custom-dropdown-menu {
    z-index: 10001 !important;
}

.custom-dropdown-btn {
    width: 100%;
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    background: white;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    color: var(--text-dark);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
}

.custom-dropdown-btn:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.15);
}

.custom-dropdown-btn:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.15);
    background: white;
}

.custom-dropdown-btn:disabled {
    background: var(--light);
    color: var(--text);
    cursor: not-allowed;
    opacity: 0.7;
}

.custom-dropdown-btn i {
    font-size: 0.75rem;
    transition: transform 0.3s ease;
    color: var(--text);
}

.custom-dropdown.active .custom-dropdown-btn i {
    transform: rotate(180deg);
}

.custom-dropdown-menu {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background: white !important;
    border: 2px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(220, 38, 38, 0.2);
    z-index: 10001 !important;
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
    display: none;
}

.custom-dropdown.active .custom-dropdown-menu {
    display: block;
}

.custom-dropdown-items {
    max-height: 300px;
    overflow-y: auto;
    background: white !important;
}

.custom-dropdown-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--border);
    color: var(--text-dark);
    font-weight: 500;
    background: white !important;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.custom-dropdown-item i {
    width: 20px;
    text-align: center;
    color: var(--text);
}

.custom-dropdown-item:hover i,
.custom-dropdown-item.selected i {
    color: var(--primary);
}

.custom-dropdown-btn span i {
    margin-right: 0.5rem;
}

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

.custom-dropdown-item:hover {
    background: var(--light) !important;
    color: var(--primary);
}

/* Button Design 5: Neumorphic Soft */
.btn-neumorphic {
    background-color: #f1f5f9;
    color: #475569;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 5px 5px 10px #cbd5e1, -5px -5px 10px #ffffff;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    text-decoration: none;
    /* Ensure link looks like button */
}

.btn-neumorphic:hover {
    transform: translateY(-1px);
    color: #2563eb;
    text-decoration: none;
}

.btn-neumorphic:active {
    box-shadow: inset 5px 5px 10px #cbd5e1, inset -5px -5px 10px #ffffff;
    transform: translateY(1px);
}

/* Loading Overlay */
.page-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.page-loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    color: #333;
}

.logo-container {
    margin-bottom: 3rem;
}

.logo-container img {
    max-width: 200px;
    height: auto;
}

/* Modern Spinner */
.modern-spinner {
    position: relative;
    width: 60px;
    height: 60px;
    margin: 0 auto 2rem auto;
}

.spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-top: 3px solid #dc3545;
    border-radius: 50%;
    animation: spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.spinner-ring:nth-child(1) {
    animation-delay: -0.45s;
    border-top-color: #dc3545;
}

.spinner-ring:nth-child(2) {
    animation-delay: -0.3s;
    border-top-color: #28a745;
    width: 80%;
    height: 80%;
    top: 10%;
    left: 10%;
}

.spinner-ring:nth-child(3) {
    animation-delay: -0.15s;
    border-top-color: #007bff;
    width: 60%;
    height: 60%;
    top: 20%;
    left: 20%;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading-content h4 {
    font-size: 1.5rem;
    color: #333;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

/* User Profile Dropdown Styles (Synced with admin-analytics) */
.user-profile {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    cursor: pointer;
    padding: 0.5rem 0.875rem;
    border-radius: 12px;
    transition: all 0.3s ease;
    position: relative;
}

.user-profile:hover {
    background: #f8fafc;
    /* using var(--light) equivalent if variable not guaranteed */
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, #ef4444 100%);
    /* using var(--secondary) fallback */
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    border: 2px solid white;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.2);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.user-role {
    font-size: 0.7rem;
    color: var(--text);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 0.75rem);
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.05);
    min-width: 220px;
    padding: 0.5rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    border: 2px solid var(--border);
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 1rem;
    border-bottom: 2px solid var(--border);
    margin-bottom: 0.5rem;
    background: transparent;
    text-align: left;
    border-radius: 0;
}

.dropdown-user-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-dark);
    margin-bottom: 0.25rem;
}

.dropdown-user-email {
    font-size: 0.8rem;
    color: var(--text);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    color: var(--text-dark);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    background: transparent !important;
    border-bottom: none;
}

.dropdown-item:last-child {
    border-radius: 8px;
    /* Override previous last-child styling */
}

.dropdown-item:hover {
    background: #f8fafc !important;
    /* var(--light) */
    color: var(--primary);
}

.dropdown-item.logout {
    color: var(--danger);
    margin-top: 0.5rem;
    border-top: 2px solid var(--border);
    padding-top: 1rem;
    border-radius: 0 0 8px 8px;
    /* Visual separation */
}

.dropdown-item.logout:hover {
    background: #fff1f2 !important;
    color: var(--danger);
}

.dropdown-item i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    color: inherit;
}