/* ================================================================
   HEALTH PANEL — Health Environmental Monitoring MVP styles
   ================================================================
   Layout: slide-in right panel, 480px width, responsive.
   Alert levels: green, yellow, red, critical.

   Must NOT define: .btn-* base, .modal-* base, .form-* base
   ================================================================ */

/* ----------------------------------------------------------------
   PANEL SHELL
   ---------------------------------------------------------------- */

.health-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 480px;
    max-width: 100vw;
    height: 100vh;
    background: var(--panel-bg, #091522);
    border-left: 1px solid var(--border-color, #2b3c56);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    font-family: inherit;
    color: var(--text-primary, #e2e8f0);
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.35);
}

/* ----------------------------------------------------------------
   HEADER
   ---------------------------------------------------------------- */

.health-panel-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color, #2b3c56);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--panel-header-bg, #0d1b2a);
}

.health-panel-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary, #e2e8f0);
}

.health-panel-close {
    background: transparent;
    border: none;
    color: var(--text-secondary, #94a3b8);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

.health-panel-close:hover {
    color: var(--text-primary, #e2e8f0);
    background: var(--neutral-700, #334155);
}

/* ----------------------------------------------------------------
   TABS
   ---------------------------------------------------------------- */

.health-panel-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color, #2b3c56);
    background: var(--panel-header-bg, #0d1b2a);
    overflow-x: auto;
}

.health-tab-btn {
    flex: 1;
    min-width: 80px;
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-secondary, #94a3b8);
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.health-tab-btn:hover {
    color: var(--text-primary, #e2e8f0);
    background: var(--neutral-700, #334155);
}

.health-tab-btn.active {
    color: var(--accent, #3b6bff);
    background: rgba(59, 107, 255, 0.12);
    border-color: var(--accent, #3b6bff);
}

/* ----------------------------------------------------------------
   BODY & SECTIONS
   ---------------------------------------------------------------- */

.health-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}

.health-section {
    margin-bottom: 16px;
}

.health-section-header {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary, #e2e8f0);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color, #2b3c56);
}

.health-section-content {
    min-height: 120px;
}

/* ----------------------------------------------------------------
   EMPTY STATE
   ---------------------------------------------------------------- */

.health-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    text-align: center;
    color: var(--text-secondary, #94a3b8);
}

.health-empty-icon {
    font-size: 24px;
    margin-bottom: 10px;
    opacity: 0.5;
}

.health-empty-title {
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--text-primary, #e2e8f0);
}

.health-empty-subtitle {
    font-size: 12px;
    opacity: 0.8;
}

/* ----------------------------------------------------------------
   ALERT LEGEND
   ---------------------------------------------------------------- */

.health-alert-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 0;
    margin-bottom: 8px;
}

.health-alert-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary, #94a3b8);
}

.health-alert-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.health-alert-label {
    white-space: nowrap;
}

/* ----------------------------------------------------------------
   RESPONSIVE
   ---------------------------------------------------------------- */

@media (max-width: 640px) {
    .health-panel {
        width: 100vw;
    }

    .health-panel-tabs {
        padding: 6px 8px;
    }

    .health-tab-btn {
        min-width: 64px;
        padding: 6px 8px;
        font-size: 11px;
    }

    .health-panel-body {
        padding: 10px 12px;
    }
}

/* ----------------------------------------------------------------
   PHASE 2 — Workers + Readings tabs
   ---------------------------------------------------------------- */

.health-tab-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.health-search-input,
.health-filter-select {
    flex: 1;
    min-width: 120px;
    padding: 6px 10px;
    background: var(--panel-bg, #091522);
    border: 1px solid var(--border-color, #2b3c56);
    border-radius: 4px;
    color: var(--text-primary, #e2e8f0);
    font-size: 13px;
}

.health-btn-primary {
    padding: 6px 14px;
    background: var(--accent, #3b82f6);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
}

.health-btn-primary:hover { background: var(--accent-hover, #2563eb); }

.health-btn-secondary {
    padding: 6px 12px;
    background: transparent;
    color: var(--text-secondary, #94a3b8);
    border: 1px solid var(--border-color, #2b3c56);
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.health-btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary, #94a3b8);
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    border-radius: 4px;
}

.health-btn-icon:hover { color: var(--text-primary, #e2e8f0); }

/* Worker cards */

.health-workers-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.health-worker-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--panel-header-bg, #0d1b2a);
    border: 1px solid var(--border-color, #2b3c56);
    border-radius: 6px;
}

.health-worker-pseudonym {
    font-weight: 600;
    font-size: 13px;
}

.health-worker-role {
    font-size: 11px;
    color: var(--text-secondary, #94a3b8);
    margin-top: 2px;
}

.health-worker-readings-count {
    font-size: 11px;
    color: var(--text-muted, #64748b);
    margin-top: 2px;
}

.health-worker-card-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.health-status-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
}

.health-status-unknown {
    color: var(--text-muted, #64748b);
}

/* Readings table */

.health-readings-table-wrap {
    overflow-x: auto;
}

.health-readings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.health-readings-table th {
    padding: 8px 10px;
    background: var(--panel-header-bg, #0d1b2a);
    border-bottom: 1px solid var(--border-color, #2b3c56);
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary, #94a3b8);
    white-space: nowrap;
}

.health-readings-table td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--border-color, #2b3c56);
}

.health-empty-row {
    text-align: center;
    color: var(--text-muted, #64748b);
    padding: 24px !important;
}

/* Add forms */

.health-add-form {
    margin-top: 12px;
    border: 1px solid var(--border-color, #2b3c56);
    border-radius: 6px;
    padding: 12px;
    background: var(--panel-header-bg, #0d1b2a);
}

.health-form-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

.health-form-row label {
    font-size: 12px;
    color: var(--text-secondary, #94a3b8);
}

.health-form-row input,
.health-form-row select {
    padding: 6px 10px;
    background: var(--panel-bg, #091522);
    border: 1px solid var(--border-color, #2b3c56);
    border-radius: 4px;
    color: var(--text-primary, #e2e8f0);
    font-size: 13px;
}

.health-form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 12px;
}

/* Dashboard */

.health-kpi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.health-kpi-card {
    padding: 12px;
    background: var(--panel-header-bg, #0d1b2a);
    border: 1px solid var(--border-color, #2b3c56);
    border-radius: 6px;
    text-align: center;
}

.health-kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary, #e2e8f0);
}

.health-kpi-label {
    font-size: 11px;
    color: var(--text-secondary, #94a3b8);
    margin-top: 4px;
}

.health-kpi-green .health-kpi-value { color: #22c55e; }
.health-kpi-yellow .health-kpi-value { color: #f59e0b; }

.health-critical-banner {
    padding: 10px 12px;
    background: #fce7f3;
    border: 1px solid #fbcfe8;
    border-radius: 6px;
    font-size: 13px;
    color: #9d174d;
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Rules table */

.health-rules-note {
    font-size: 12px;
    color: var(--text-secondary, #94a3b8);
    margin-bottom: 10px;
}

.health-rules-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.health-rules-table th {
    padding: 7px 8px;
    background: var(--panel-header-bg, #0d1b2a);
    border-bottom: 1px solid var(--border-color, #2b3c56);
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary, #94a3b8);
}

.health-rules-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border-color, #2b3c56);
}
