/* =========================================================================
   Resollect Monitor — Dark Theme Dashboard
   ========================================================================= */

/* ---------------------------------------------------------------------------
   CSS Variables
   --------------------------------------------------------------------------- */

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #1c2128;
    --bg-card: #1c2128;
    --bg-hover: #252c35;
    --bg-input: #21262d;

    --text-primary: #e0e0e0;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;

    --accent: #4ecdc4;
    --accent-hover: #3dbdb5;

    --border: #30363d;
    --border-light: #21262d;

    /* Status colors */
    --color-healthy: #2ecc71;
    --color-warning: #f39c12;
    --color-critical: #e74c3c;
    --color-offline: #6e7681;

    /* Chart colors */
    --chart-cpu: #f39c12;
    --chart-ram: #4ecdc4;
    --chart-disk: #e74c3c;

    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);

    --nav-height: 56px;
    --font-mono: "SF Mono", "Cascadia Code", "Fira Code", Menlo, monospace;
}


/* ---------------------------------------------------------------------------
   Reset & Base
   --------------------------------------------------------------------------- */

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

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-hover);
}

code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}


/* ---------------------------------------------------------------------------
   Top Navigation
   --------------------------------------------------------------------------- */

.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    z-index: 100;
}

.nav-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.nav-brand:hover {
    color: var(--accent);
}

.brand-icon {
    color: var(--accent);
    font-size: 1.4rem;
}

.brand-icon-lg {
    font-size: 2.5rem;
}

.nav-links {
    display: flex;
    gap: 0.25rem;
    flex: 1;
}

.nav-link {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: color 0.15s, background-color 0.15s;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-link.active {
    color: var(--accent);
    background: rgba(78, 205, 196, 0.1);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    white-space: nowrap;
}

.nav-username {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.nav-role-badge {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--bg-hover);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.nav-logout {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.nav-logout:hover {
    color: var(--color-critical);
}


/* ---------------------------------------------------------------------------
   Main Content
   --------------------------------------------------------------------------- */

.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: calc(var(--nav-height) + 1.5rem) 1.5rem 2rem;
}


/* ---------------------------------------------------------------------------
   Page Header
   --------------------------------------------------------------------------- */

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.page-header-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.breadcrumb {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.breadcrumb a {
    color: var(--text-secondary);
}

.breadcrumb a:hover {
    color: var(--accent);
}

.breadcrumb-sep {
    margin: 0 0.5rem;
    color: var(--text-muted);
}


/* ---------------------------------------------------------------------------
   Messages
   --------------------------------------------------------------------------- */

.messages {
    margin-bottom: 1rem;
}

.message {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.message-success { background: rgba(46, 204, 113, 0.15); color: var(--color-healthy); border: 1px solid rgba(46, 204, 113, 0.3); }
.message-error   { background: rgba(231, 76, 60, 0.15); color: var(--color-critical); border: 1px solid rgba(231, 76, 60, 0.3); }
.message-warning { background: rgba(243, 156, 18, 0.15); color: var(--color-warning); border: 1px solid rgba(243, 156, 18, 0.3); }
.message-info    { background: rgba(78, 205, 196, 0.15); color: var(--accent); border: 1px solid rgba(78, 205, 196, 0.3); }


/* ---------------------------------------------------------------------------
   Summary Cards
   --------------------------------------------------------------------------- */

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
}

.summary-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.summary-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

.card-healthy .summary-value  { color: var(--color-healthy); }
.card-healthy                 { border-color: rgba(46, 204, 113, 0.3); }
.card-warning .summary-value  { color: var(--color-warning); }
.card-warning                 { border-color: rgba(243, 156, 18, 0.3); }
.card-critical .summary-value { color: var(--color-critical); }
.card-critical                { border-color: rgba(231, 76, 60, 0.3); }


/* ---------------------------------------------------------------------------
   Tables
   --------------------------------------------------------------------------- */

.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--bg-tertiary);
}

.data-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
    white-space: nowrap;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

.clickable-row {
    cursor: pointer;
}

.cell-name {
    font-weight: 500;
}

.cell-muted {
    color: var(--text-muted);
}

.cell-message {
    white-space: normal;
    max-width: 300px;
}

.cell-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem 1rem;
}

.cell-actions {
    display: flex;
    gap: 0.5rem;
}


/* ---------------------------------------------------------------------------
   Text Colors (metric values)
   --------------------------------------------------------------------------- */

.text-healthy  { color: var(--color-healthy); }
.text-warning  { color: var(--color-warning); }
.text-critical { color: var(--color-critical); }
.text-muted    { color: var(--text-muted); }


/* ---------------------------------------------------------------------------
   Status Dot & Badge
   --------------------------------------------------------------------------- */

.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    vertical-align: middle;
}

.status-dot.status-healthy  { background: var(--color-healthy); box-shadow: 0 0 6px rgba(46, 204, 113, 0.5); }
.status-dot.status-warning  { background: var(--color-warning); box-shadow: 0 0 6px rgba(243, 156, 18, 0.5); }
.status-dot.status-critical { background: var(--color-critical); box-shadow: 0 0 6px rgba(231, 76, 60, 0.5); }
.status-dot.status-offline  { background: var(--color-offline); }

.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.status-badge.status-healthy  { background: rgba(46, 204, 113, 0.15); color: var(--color-healthy); }
.status-badge.status-warning  { background: rgba(243, 156, 18, 0.15); color: var(--color-warning); }
.status-badge.status-critical { background: rgba(231, 76, 60, 0.15); color: var(--color-critical); }
.status-badge.status-offline  { background: rgba(110, 118, 129, 0.15); color: var(--color-offline); }


/* ---------------------------------------------------------------------------
   Severity (alert rows)
   --------------------------------------------------------------------------- */

.severity-icon {
    font-size: 1rem;
    margin-right: 0.25rem;
}

.severity-icon.severity-critical { color: var(--color-critical); }
.severity-icon.severity-warning  { color: var(--color-warning); }

.alert-row.severity-critical { border-left: 3px solid var(--color-critical); }
.alert-row.severity-warning  { border-left: 3px solid var(--color-warning); }


/* ---------------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.btn:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

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

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

.btn-secondary {
    background: var(--bg-input);
    border-color: var(--border);
}

.btn-danger {
    background: rgba(231, 76, 60, 0.15);
    color: var(--color-critical);
    border-color: rgba(231, 76, 60, 0.3);
}

.btn-danger:hover {
    background: rgba(231, 76, 60, 0.25);
}

.btn-ack {
    background: rgba(243, 156, 18, 0.15);
    color: var(--color-warning);
    border-color: rgba(243, 156, 18, 0.3);
}

.btn-ack:hover {
    background: rgba(243, 156, 18, 0.25);
}

.btn-range {
    min-width: 40px;
}

.btn-range.active {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}


/* ---------------------------------------------------------------------------
   Cards & Sections
   --------------------------------------------------------------------------- */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

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

.card-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.section-subtitle {
    font-size: 0.9rem;
    font-weight: 500;
    margin: 1rem 0 0.75rem;
    color: var(--text-secondary);
}

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

.section-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.gauge-section,
.container-section,
.health-section {
    margin-bottom: 2rem;
}


/* ---------------------------------------------------------------------------
   Gauges / Progress Bars
   --------------------------------------------------------------------------- */

.gauge-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.gauge-grid-wide {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

.gauge-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

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

.gauge-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.gauge-value {
    font-size: 1.1rem;
    font-weight: 600;
}

.gauge-detail {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.progress-bar {
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.progress-fill-cpu { background: var(--chart-cpu); }
.progress-fill-ram { background: var(--chart-ram); }
.progress-fill-disk { background: var(--chart-disk); }

.text-healthy-bg  { background: var(--color-healthy); }
.text-warning-bg  { background: var(--color-warning); }
.text-critical-bg { background: var(--color-critical); }


/* ---------------------------------------------------------------------------
   Container Grid
   --------------------------------------------------------------------------- */

.container-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}

.container-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

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

.container-name {
    font-weight: 500;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 160px;
}

.container-metrics {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.container-metric {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
}

.metric-label {
    color: var(--text-muted);
}

.metric-value {
    font-weight: 500;
}


/* ---------------------------------------------------------------------------
   Health Cards
   --------------------------------------------------------------------------- */

.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.health-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.health-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.health-value {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.health-detail {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.queue-tag {
    display: inline-block;
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-family: var(--font-mono);
    margin-right: 0.25rem;
    margin-top: 0.25rem;
}


/* ---------------------------------------------------------------------------
   Chart
   --------------------------------------------------------------------------- */

.chart-wrapper {
    position: relative;
    width: 100%;
    height: 300px;
}

.chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

.time-range-buttons {
    display: flex;
    gap: 0.25rem;
}


/* ---------------------------------------------------------------------------
   Filter Bar
   --------------------------------------------------------------------------- */

.filter-bar {
    margin-bottom: 1.5rem;
}

.filter-bar form {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-group label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-group select {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    min-width: 160px;
    cursor: pointer;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--accent);
}


/* ---------------------------------------------------------------------------
   Tabs
   --------------------------------------------------------------------------- */

.tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.tab-btn {
    padding: 0.75rem 1.25rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}


/* ---------------------------------------------------------------------------
   Role Badge
   --------------------------------------------------------------------------- */

.role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.role-badge.role-admin    { background: rgba(78, 205, 196, 0.15); color: var(--accent); }
.role-badge.role-operator { background: rgba(243, 156, 18, 0.15); color: var(--color-warning); }
.role-badge.role-viewer   { background: rgba(110, 118, 129, 0.15); color: var(--color-offline); }


/* ---------------------------------------------------------------------------
   Key Prefix (settings)
   --------------------------------------------------------------------------- */

.key-prefix {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
}


/* ---------------------------------------------------------------------------
   Empty State
   --------------------------------------------------------------------------- */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state p {
    font-size: 0.95rem;
}


/* ---------------------------------------------------------------------------
   Login Page
   --------------------------------------------------------------------------- */

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 1.5rem;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 0.75rem;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.login-error {
    background: rgba(231, 76, 60, 0.15);
    color: var(--color-critical);
    border: 1px solid rgba(231, 76, 60, 0.3);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
    text-align: center;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.form-input {
    width: 100%;
    padding: 0.65rem 0.75rem;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    transition: border-color 0.15s;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(78, 205, 196, 0.15);
}

.btn-login {
    width: 100%;
    padding: 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
}


/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */

@media (max-width: 768px) {
    .nav-inner {
        padding: 0 1rem;
        gap: 1rem;
    }

    .nav-links {
        gap: 0;
    }

    .nav-user {
        gap: 0.5rem;
    }

    .nav-username,
    .nav-role-badge {
        display: none;
    }

    .main-content {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .gauge-grid {
        grid-template-columns: 1fr;
    }

    .container-grid {
        grid-template-columns: 1fr;
    }

    .health-grid {
        grid-template-columns: 1fr;
    }

    .filter-bar form {
        flex-direction: column;
    }

    .filter-group select {
        min-width: auto;
        width: 100%;
    }

    .data-table th,
    .data-table td {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .summary-cards {
        grid-template-columns: 1fr;
    }

    .page-header h1 {
        font-size: 1.25rem;
    }
}
