/* ====== XPNK HUB DASHBOARD - PROFESSIONAL EDITION ====== */
/* Modern, clean, and serious design inspired by enterprise monitoring tools */

/* CSS Variables for consistent theming */
:root {
    /* Primary Colors */
    --primary-bg: #0a0e1a;
    --secondary-bg: #141925;
    --tertiary-bg: #1e2433;
    --card-bg: #1a1f2e;

    /* Accent Colors */
    --primary-accent: #2563eb;
    --secondary-accent: #3b82f6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --info-color: #06b6d4;

    /* Text Colors */
    --primary-text: #f8fafc;
    --secondary-text: #cbd5e1;
    --tertiary-text: #94a3b8;
    --muted-text: #64748b;

    /* Borders & Shadows */
    --border-color: #334155;
    --border-light: #475569;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;

    /* Typography */
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--primary-bg);
    color: var(--primary-text);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Background Pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(circle at 25% 25%, rgba(37, 99, 235, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(6, 182, 212, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* Header Styles */
.header {
    background: linear-gradient(135deg, var(--secondary-bg) 0%, var(--tertiary-bg) 100%);
    border-bottom: 1px solid var(--border-color);
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(10px);
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-left: 24px;
    flex: 1;
    min-width: 0;
}

.logo {
    font-size: 24px;
    filter: drop-shadow(0 2px 8px rgba(37, 99, 235, 0.3));
    animation: logo-pulse 3s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes logo-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.logo-text {
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-text);
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.subtitle {
    font-size: 10px;
    color: var(--tertiary-text);
    font-weight: 400;
    margin-top: 1px;
}

.status-section {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-right: 24px;
    flex-shrink: 0;
}

.refresh-btn {
    background: linear-gradient(135deg, var(--primary-accent) 0%, var(--secondary-accent) 100%);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
    height: 32px;
    min-width: 32px;
    justify-content: center;
    flex-shrink: 0;
}

.refresh-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    background: linear-gradient(135deg, var(--secondary-accent) 0%, var(--primary-accent) 100%);
}

.refresh-btn:active {
    transform: translateY(0);
}

.refresh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.auto-refresh {
    background: linear-gradient(135deg, var(--card-bg) 0%, var(--secondary-bg) 100%);
    border: 1px solid var(--border-light);
    color: var(--secondary-text);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-family: var(--font-mono);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    height: 32px;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.auto-refresh:hover {
    border-color: var(--primary-accent);
    color: var(--primary-text);
}

.last-updated {
    background: linear-gradient(135deg, var(--card-bg) 0%, var(--secondary-bg) 100%);
    border: 1px solid var(--border-light);
    color: var(--secondary-text);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-family: var(--font-mono);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    height: 32px;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.last-updated:hover {
    border-color: var(--primary-accent);
    color: var(--primary-text);
}


.stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-icon {
    font-size: 12px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

/* Main Content - Full Width */
.main-content {
    margin-top: 64px;
    padding: 32px;
    width: 100%;
    position: relative;
    z-index: 1;
}

/* Loading State */
#loading {
    text-align: center;
    padding: 80px 20px;
    color: var(--tertiary-text);
    font-size: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Error State */
#error-container {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error-color);
    color: var(--error-color);
    padding: 12px 20px;
    border-radius: 8px;
    margin: 16px 0;
    display: none;
    align-items: center;
    gap: 8px;
}

/* Dashboard Grid - 4 Row Layout Full Width */
.dashboard-grid {
    display: grid;
    grid-template-rows: auto auto auto auto;
    gap: 24px;
    align-items: start;
    width: 100%;
}

/* Category Sections - Horizontal Layout for Row-based Design */
.category-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
}

.category-section:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-light);
}

.category-header {
    background: linear-gradient(135deg, var(--secondary-bg) 0%, var(--tertiary-bg) 100%);
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.category-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-text);
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.category-stats {
    display: flex;
    gap: 16px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 600;
}

.stat-item.healthy {
    color: var(--success-color);
}

.stat-item.unhealthy {
    color: var(--error-color);
}

/* System Monitoring Section */
.system-monitoring-section {
    margin-bottom: 32px;
}

.system-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    padding: 20px;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.metric-card {
    background: var(--secondary-bg);
    border-radius: 8px;
    padding: 20px;
    border: 1px solid var(--border-light);
    transition: var(--transition-normal);
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-accent);
}

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

.metric-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-text);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.metric-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary-accent);
    font-family: var(--font-mono);
}

.progress-container {
    width: 100%;
    height: 8px;
    background: var(--tertiary-bg);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 16px;
}

.progress-bar {
    height: 100%;
    background: var(--success-color);
    border-radius: 4px;
    transition: width 0.5s ease-in-out, background-color 0.3s ease;
    min-width: 2px;
}

.metric-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.metric-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}

.metric-label {
    font-size: 12px;
    color: var(--tertiary-text);
    font-weight: 500;
}

.metric-info span:last-child {
    font-size: 12px;
    color: var(--secondary-text);
    font-family: var(--font-mono);
    font-weight: 600;
}

/* Stat Badge Styles */
.stat-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--secondary-bg);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--secondary-text);
    transition: var(--transition-normal);
}

.stat-badge:hover {
    border-color: var(--primary-accent);
    color: var(--primary-text);
}

/* Services Grid - Horizontal Layout for Row-based Design */
.services-grid {
    display: grid;
    grid-auto-columns: minmax(280px, 1fr);
    grid-auto-flow: column;
    gap: 16px;
    padding: 16px 24px;
    overflow-x: auto;
}

/* Service Cards - Compact Horizontal Layout */
.service-card {
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    min-width: 280px;
    min-height: 100px;
}

.service-card:hover {
    border-color: var(--primary-accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.service-card.status-healthy {
    border-left: 4px solid var(--success-color);
}

.service-card.status-unhealthy {
    border-left: 4px solid var(--error-color);
}

.service-card.status-unknown {
    border-left: 4px solid var(--warning-color);
}

.service-card.updated {
    animation: card-update 1s ease;
}

@keyframes card-update {
    0% { background-color: var(--primary-accent); }
    100% { background-color: var(--secondary-bg); }
}

.service-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}

.service-icon {
    font-size: 28px;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

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

.service-title h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-text);
    margin: 0 0 4px 0;
    line-height: 1.3;
}

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

.status-indicator {
    font-size: 12px;
}

.status-text {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.service-content {
    margin-bottom: 16px;
}

.service-description {
    color: var(--tertiary-text);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 12px;
}

.service-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

/* Single Row Metrics Layout */
.service-metrics-single-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.service-metrics-single-row .metric-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all var(--transition-fast);
    flex: 1;
    justify-content: center;
}

.service-metrics-single-row .metric-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.12);
}

.metric {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.metric-label {
    font-size: 10px;
    color: var(--muted-text);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 600;
}

.service-metrics-single-row .metric-value {
    font-size: 11px;
    color: var(--secondary-text);
    font-family: var(--font-mono);
    font-weight: 600;
}

.service-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.error-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.error-message {
    font-size: 12px;
    color: var(--error-color);
    font-family: var(--font-mono);
}

.service-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.action-btn {
    background: var(--tertiary-bg);
    border: 1px solid var(--border-color);
    color: var(--secondary-text);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-mono);
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    transition: all var(--transition-fast);
    flex: 1;
    justify-content: center;
}

.action-btn:hover:not(:disabled) {
    background: var(--primary-accent);
    color: white;
    border-color: var(--primary-accent);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-btn.primary {
    background: var(--primary-accent);
    color: white;
    border-color: var(--primary-accent);
}

.action-btn.primary:hover {
    background: var(--secondary-accent);
    border-color: var(--secondary-accent);
}

/* Responsive Design for 4 Row Layout */
@media (max-width: 1600px) {
    .main-content {
        padding: 24px;
    }
}

@media (max-width: 1400px) {
    .dashboard-grid {
        gap: 20px;
    }

    .main-content {
        padding: 20px;
    }
}

@media (max-width: 768px) {
    .dashboard-grid {
        gap: 16px;
    }

    .services-grid {
        grid-auto-columns: minmax(250px, 1fr);
        padding: 12px 16px;
    }

    .main-content {
        padding: 16px;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 20px 16px;
        margin-top: 56px;
    }

    /* Reduce header height for mobile */
    .header {
        height: 56px;
        flex-wrap: nowrap;
        padding: 0;
        overflow: hidden;
    }

    .logo-section {
        padding-left: 12px;
        gap: 6px;
        flex: 1;
        min-width: 0; /* Allow to shrink */
        overflow: hidden;
    }

    .logo {
        font-size: 20px;
    }

    .logo-text {
        font-size: 14px;
    }

    .subtitle {
        font-size: 9px;
        display: none; /* Hide subtitle on mobile to save space */
    }

    .status-section {
        padding-right: 12px;
        gap: 4px;
        flex-wrap: nowrap;
        justify-content: flex-end;
        flex-shrink: 0;
        min-width: fit-content;
    }

    .refresh-btn,
    .auto-refresh,
    .last-updated {
        font-size: 10px;
        padding: 5px 8px;
        min-width: auto;
        white-space: nowrap;
    }

    .refresh-btn span:last-child,
    .auto-refresh span:last-child {
        display: none; /* Hide text labels, keep only icons */
    }

    .system-stats {
        display: none; /* Hide detailed system stats on mobile */
    }

    /* Mobile System Monitoring */
    .system-metrics-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 16px;
    }

    .metric-card {
        padding: 16px;
    }

    .metric-header h3 {
        font-size: 14px;
    }

    .metric-value {
        font-size: 12px;
    }

    /* Create compact mobile layout */
    .header::after {
        content: '';
        display: none;
    }
}

    .category-header {
        padding: 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .category-header h2 {
        font-size: 18px;
    }

    .services-grid {
        gap: 12px;
        padding: 16px;
    }

    .service-card {
        padding: 16px;
    }

    .service-metrics {
        grid-template-columns: 1fr;
    }

    .service-metrics-single-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .service-metrics-single-row .metric-item {
        padding: 6px 8px;
    }

    .service-metrics-single-row .metric-label {
        font-size: 9px;
    }

    .service-metrics-single-row .metric-value {
        font-size: 10px;
    }

    .system-stats {
        flex-direction: column;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 16px 12px;
        margin-top: 48px;
    }

    .dashboard-grid {
        gap: 16px;
    }

    .service-actions {
        flex-direction: column;
    }

    .category-stats {
        width: 100%;
        justify-content: space-between;
    }

    /* Even more compact header for very small screens */
    .header {
        height: 48px;
    }

    .logo {
        font-size: 18px;
    }

    .logo-text {
        font-size: 12px;
    }

    .status-section {
        gap: 4px;
    }

    .refresh-btn span:first-child,
    .auto-refresh span:first-child {
        font-size: 12px;
    }

    .refresh-btn span:last-child,
    .auto-refresh span:last-child {
        display: none; /* Hide text on very small screens */
    }

    /* Make buttons more touch-friendly but compact */
    .refresh-btn,
    .auto-refresh {
        padding: 6px;
        border-radius: 6px;
        min-width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Extra small screens (320px and below) */
@media (max-width: 320px) {
    .header {
        height: 44px;
    }

    .logo-section {
        gap: 6px;
        padding-left: 8px;
    }

    .logo {
        font-size: 16px;
    }

    .logo-text {
        font-size: 11px;
    }

    .status-section {
        padding-right: 8px;
        gap: 3px;
    }

    .main-content {
        padding: 12px 8px;
        margin-top: 44px;
    }

    .service-card {
        padding: 12px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print Styles */
@media print {
    .header,
    .service-actions,
    .refresh-btn,
    .auto-refresh {
        display: none;
    }

    .main-content {
        margin-top: 0;
        padding: 0;
    }

    body {
        background: white;
        color: black;
    }

    .service-card {
        border: 1px solid #ccc;
        break-inside: avoid;
        page-break-inside: avoid;
    }
}