* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-padding-top: 70px; /* Account for sticky nav bar height */
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #0f172a;
    color: #e2e8f0;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid #334155;
}

header h1 {
    font-size: 2.5rem;
    color: #60a5fa;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: #94a3b8;
    font-size: 1rem;
}

.section-nav {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: #1e293b;
    border-radius: 8px;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.section-nav.scrolled {
    background: #000000;
    border-radius: 0;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    padding-left: calc(50vw - 50% + 2rem);
    padding-right: calc(50vw - 50% + 2rem);
    width: 100vw;
}

.section-nav a {
    color: #60a5fa;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
    font-weight: 500;
}

.section-nav a:hover {
    background: #334155;
    color: #93c5fd;
}

.dev-mode-warning {
    background: #854d0e;
    border: 2px solid #fbbf24;
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 2rem;
    text-align: center;
}

.dev-mode-warning strong {
    display: block;
    color: #fbbf24;
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.dev-mode-warning p {
    color: #fde68a;
    margin: 0;
}

.db-status-info {
    background: #1e3a8a;
    border: 2px solid #60a5fa;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 2rem;
    text-align: center;
}

.db-status-info strong {
    display: block;
    color: #60a5fa;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.db-status-info p {
    color: #dbeafe;
    margin: 0;
    font-size: 0.95rem;
}

.db-status-info span {
    font-weight: 600;
    color: #93c5fd;
}

.dashboard-section {
    background: #1e293b;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    border-left: 6px solid #60a5fa;
}

.dashboard-section h2 {
    color: #60a5fa;
    margin-bottom: 1.5rem;
    font-size: 1.75rem;
}

/* Section color variations - brighter colors */
.dashboard-section:nth-of-type(1) {
    border-left-color: #3b82f6; /* Blue - Server Metrics */
}

.dashboard-section:nth-of-type(2) {
    border-left-color: #10b981; /* Green - 10 Minutes */
}

.dashboard-section:nth-of-type(3) {
    border-left-color: #8b5cf6; /* Purple - 1 Day */
}

.dashboard-section:nth-of-type(4) {
    border-left-color: #ec4899; /* Pink - 30 Days */
}

.dashboard-section:nth-of-type(5) {
    border-left-color: #f59e0b; /* Yellow - System Info */
}

.dashboard-section:nth-of-type(6) {
    border-left-color: #ef4444; /* Red - Top Processes */
}

.dashboard-section:nth-of-type(7) {
    border-left-color: #06b6d4; /* Cyan - Docker Containers */
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.metric-card {
    background: #0f172a;
    border-radius: 8px;
    padding: 1.5rem;
    border: 1px solid #334155;
    transition: transform 0.2s, border-color 0.2s;
}

.metric-card:hover {
    transform: translateY(-2px);
    border-color: #60a5fa;
}

.metric-card h3 {
    color: #94a3b8;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.metric-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: #60a5fa;
    line-height: 1;
}

.metric-unit {
    color: #64748b;
    font-size: 1rem;
    margin-top: 0.25rem;
}

.metric-detail {
    color: #94a3b8;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Chart grid layouts - prevent cutoffs with fixed column counts */
.charts-grid {
    display: grid;
    gap: 1.5rem;
}

/* 4 charts: 2x2 grid */
.charts-grid-4 {
    grid-template-columns: repeat(2, 1fr);
}

/* 5 charts: 1 row of 3, 1 row of 2 */
.charts-grid-5 {
    grid-template-columns: repeat(3, 1fr);
}

/* 6 charts: 3x2 grid (perfect!) */
.charts-grid-6 {
    grid-template-columns: repeat(3, 1fr);
}

/* 8 charts: 4x2 grid */
.charts-grid-8 {
    grid-template-columns: repeat(4, 1fr);
}

/* 10 charts: 5x2 grid */
.charts-grid-10 {
    grid-template-columns: repeat(5, 1fr);
}

/* 12 charts: 6x2 grid */
.charts-grid-12 {
    grid-template-columns: repeat(6, 1fr);
}

.chart-container {
    background: #0f172a;
    border-radius: 8px;
    padding: 1.5rem;
    border: 1px solid #334155;
}

.chart-container h3 {
    color: #94a3b8;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.chart-container canvas {
    max-height: 250px;
    width: 100% !important;
    height: auto !important;
}

@media (max-width: 768px) {
    .chart-container canvas {
        max-height: 200px;
    }
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.info-card {
    background: #0f172a;
    border-radius: 8px;
    padding: 1.5rem;
    border: 1px solid #334155;
}

.info-card h3 {
    color: #94a3b8;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.info-value {
    font-size: 1.75rem;
    font-weight: bold;
    color: #60a5fa;
}

.process-count {
    background: #0f172a;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    border: 1px solid #334155;
    text-align: center;
}

.process-count span {
    font-size: 2rem;
    font-weight: bold;
    color: #60a5fa;
}

.process-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.process-item {
    background: #0f172a;
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid #334155;
    transition: border-color 0.2s;
}

.process-item:hover {
    border-color: #60a5fa;
}

.process-header {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 1rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.process-name {
    font-weight: 600;
    color: #e2e8f0;
    font-family: 'Courier New', monospace;
}

.process-cpu, .process-mem {
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: #1e293b;
    color: #94a3b8;
}

.process-details {
    color: #64748b;
    font-size: 0.75rem;
}

.container-count {
    background: #0f172a;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    border: 1px solid #334155;
    text-align: center;
}

.container-count span {
    font-size: 2rem;
    font-weight: bold;
    color: #60a5fa;
}

.containers-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.container-item {
    background: #0f172a;
    border-radius: 8px;
    padding: 1.25rem;
    border: 1px solid #334155;
    transition: border-color 0.2s;
}

.container-item:hover {
    border-color: #60a5fa;
}

.container-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.container-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: #e2e8f0;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-running {
    background: #166534;
    color: #86efac;
}

.status-stopped {
    background: #991b1b;
    color: #fca5a5;
}

.container-details {
    color: #94a3b8;
    font-size: 0.875rem;
}

.container-details div {
    margin-bottom: 0.25rem;
}

.loading {
    text-align: center;
    color: #64748b;
    padding: 2rem;
    font-style: italic;
}

.error {
    background: #991b1b;
    color: #fca5a5;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}

footer {
    text-align: center;
    padding-top: 2rem;
    color: #64748b;
    font-size: 0.875rem;
}

#last-updated {
    color: #94a3b8;
}

/* Database Section Styling */
.databases-section {
    border-left: 6px solid #a855f7; /* Purple color for databases section */
}

.databases-section h2 {
    color: #a855f7;
}

.database-count {
    color: #94a3b8;
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

.database-count span {
    font-weight: 700;
    color: #a78bfa;
    font-size: 1.5rem;
}

.database-item {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.database-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #334155;
}

.database-header h3 {
    color: #a78bfa;
    font-size: 1.5rem;
    margin: 0;
}

.table-count {
    color: #94a3b8;
    font-size: 1rem;
    background: #1e293b;
    padding: 0.5rem 1rem;
    border-radius: 6px;
}

.tables-scroll-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    scrollbar-width: thin;
    scrollbar-color: #475569 #1e293b;
    padding-bottom: 0.5rem;
}

.tables-scroll-wrapper::-webkit-scrollbar {
    height: 8px;
}

.tables-scroll-wrapper::-webkit-scrollbar-track {
    background: #1e293b;
    border-radius: 4px;
}

.tables-scroll-wrapper::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}

.tables-scroll-wrapper::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

.tables-container {
    display: grid;
    /* grid-template-columns and grid-template-rows set dynamically via JavaScript */
    gap: 0.75rem;
    grid-auto-flow: column; /* Force items to flow in columns, creating horizontal layout */
}

.table-card {
    background: #1e293b;
    border: 1px solid #475569;
    border-radius: 6px;
    padding: 0.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
    min-width: 200px; /* Minimum width to ensure scrolling happens */
    width: 250px; /* Fixed width for each card */
    overflow: hidden; /* Prevent overflow */
}

.table-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
    border-color: #8b5cf6;
}

.table-name {
    color: #c4b5fd;
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    padding: 0.3rem 0.35rem;
    border-bottom: 2px solid rgba(139, 92, 246, 0.3);
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    background: rgba(139, 92, 246, 0.05);
}

.table-stats {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.35rem;
    border-bottom: 1px solid rgba(71, 85, 105, 0.3); /* Faint grid line */
    background: linear-gradient(90deg,
        rgba(71, 85, 105, 0.05) 0%,
        rgba(71, 85, 105, 0.05) 50%,
        transparent 50%,
        transparent 100%
    );
    background-size: 100% 100%;
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    color: #94a3b8;
    font-size: 0.8rem;
    cursor: help; /* Show help cursor on hover for labels with tooltips */
    flex-shrink: 0;
}

.stat-label[title] {
    border-bottom: 1px dotted #94a3b8; /* Subtle underline for items with tooltips */
}

.stat-value {
    color: #e2e8f0;
    font-weight: 600;
    font-size: 0.85rem;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Responsive adjustments */
@media (max-width: 1400px) {
    /* Medium screens: 2 columns for all grids */
    .charts-grid-5,
    .charts-grid-6,
    .charts-grid-8,
    .charts-grid-10,
    .charts-grid-12 {
        grid-template-columns: repeat(2, 1fr);
    }

    .tables-container {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    .container {
        padding: 0.5rem;
        max-width: 100%;
    }

    header {
        padding-bottom: 1rem;
        margin-bottom: 1.5rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.85rem;
    }

    /* Navigation bar improvements for mobile */
    .section-nav {
        gap: 0.25rem;
        padding: 0.5rem;
        justify-content: center;
        flex-wrap: wrap;
    }

    .section-nav a {
        padding: 0.35rem 0.6rem;
        font-size: 0.85rem;
    }

    .section-nav.scrolled {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Mobile: 1 column for all charts */
    .charts-grid-4,
    .charts-grid-5,
    .charts-grid-6,
    .charts-grid-8,
    .charts-grid-10,
    .charts-grid-12 {
        grid-template-columns: 1fr;
    }

    .chart-container {
        padding: 0.75rem;
    }

    .chart-container h3 {
        font-size: 0.8rem;
        margin-bottom: 0.75rem;
    }

    .dashboard-section {
        padding: 1rem;
        border-radius: 8px;
        border-left-width: 4px;
    }

    .dashboard-section h2 {
        font-size: 1.4rem;
    }

    /* Process list improvements */
    .process-header {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .process-name {
        font-size: 0.9rem;
    }

    .process-item {
        padding: 0.75rem;
    }

    /* Container improvements */
    .container-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .container-item {
        padding: 1rem;
    }

    .container-name {
        font-size: 1rem;
    }

    /* Database tables on mobile */
    .tables-container {
        grid-template-columns: 1fr;
    }

    .database-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .database-item {
        padding: 1rem;
    }

    .table-card {
        padding: 0.75rem;
    }

    .table-name {
        font-size: 1rem;
    }

    /* Improve readability of metrics on mobile */
    .metric-value {
        font-size: 1.75rem;
    }

    .metric-card {
        padding: 1rem;
    }

    .info-value {
        font-size: 1.25rem;
    }

    .info-card {
        padding: 1rem;
    }

    .info-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}
