/* Edge Case Sentinel — Watchtower Dark Theme */
/* Color scheme from General/Color_Scheme.md */

/* ============================================
   CSS Custom Properties
   ============================================ */
:root {
    /* Typography */
    --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", "IBM Plex Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

    /* Core */
    --bg: #0B1020;
    --surface: #111827;
    --surface-raised: #182235;
    --surface-hover: #1E2A3F;
    --border: #263244;
    --border-strong: #334155;

    /* Text */
    --text: #E5E7EB;
    --text-muted: #94A3B8;
    --text-faint: #64748B;

    /* Accent */
    --primary: #38BDF8;
    --primary-hover: #0EA5E9;
    --secondary: #A78BFA;
    --success: #22C55E;
    --warning: #F59E0B;
    --danger: #EF4444;

    /* Severity */
    --severity-info: #38BDF8;
    --severity-low: #22C55E;
    --severity-medium: #F59E0B;
    --severity-high: #F97316;
    --severity-critical: #EF4444;

    /* Severity Backgrounds */
    --severity-info-bg: rgba(56, 189, 248, 0.12);
    --severity-low-bg: rgba(34, 197, 94, 0.12);
    --severity-medium-bg: rgba(245, 158, 11, 0.12);
    --severity-high-bg: rgba(249, 115, 22, 0.14);
    --severity-critical-bg: rgba(239, 68, 68, 0.16);

    --severity-info-border: rgba(56, 189, 248, 0.35);
    --severity-low-border: rgba(34, 197, 94, 0.35);
    --severity-medium-border: rgba(245, 158, 11, 0.35);
    --severity-high-border: rgba(249, 115, 22, 0.40);
    --severity-critical-border: rgba(239, 68, 68, 0.45);

    /* Charts */
    --chart-blue: #38BDF8;
    --chart-violet: #A78BFA;
    --chart-green: #22C55E;
    --chart-amber: #F59E0B;
    --chart-orange: #F97316;
    --chart-red: #EF4444;
    --chart-slate: #64748B;

    /* Layout */
    --sidebar-width: 250px;
}

/* ============================================
   Reset and Base
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

code, pre, .mono,
.ip-address, .mac-address, .event-id,
.provider-event-id, .file-path, .raw-log,
.json-payload, .timestamp-technical {
    font-family: var(--font-mono);
}

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

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

/* ============================================
   App Layout
   ============================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text);
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
}

.sidebar-title {
    font-size: 16px;
    font-weight: 650;
    color: var(--text);
    line-height: 1.2;
}

.sidebar-subtitle {
    font-size: 11px;
    color: var(--text-faint);
    line-height: 1.3;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item {
    margin: 1px 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

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

.nav-link.active {
    background: var(--severity-info-bg);
    color: #7DD3FC;
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 16px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.sidebar-user-email {
    font-size: 11px;
    color: var(--text-faint);
}

.sidebar-logout-form {
    margin: 0;
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 28px 32px;
    min-height: 100vh;
}

/* ============================================
   Mobile Header and Responsive
   ============================================ */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    z-index: 90;
}

.mobile-menu-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    width: 32px;
    height: 32px;
}

.mobile-menu-btn svg {
    width: 24px;
    height: 24px;
}

.mobile-header-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay.open {
    display: block;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-header {
        display: flex;
    }

    .main-content {
        margin-left: 0;
        padding: 72px 16px 24px;
    }
}

/* ============================================
   Page Structure
   ============================================ */
.page-header {
    margin-bottom: 24px;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

.section-title {
    font-size: 20px;
    font-weight: 650;
    color: var(--text);
    margin-bottom: 16px;
}

.section-divider {
    height: 1px;
    background: var(--border);
    margin: 28px 0;
}

.page-section {
    margin-bottom: 32px;
}

/* ============================================
   Stats Grid (Dashboard)
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: border-color 0.15s ease;
}

.stat-card:hover {
    border-color: var(--border-strong);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 22px;
    height: 22px;
}

.stat-icon-success {
    background: var(--severity-low-bg);
    color: var(--severity-low);
    border: 1px solid var(--severity-low-border);
}

.stat-icon-danger {
    background: var(--severity-critical-bg);
    color: var(--severity-critical);
    border: 1px solid var(--severity-critical-border);
}

.stat-icon-critical {
    background: var(--severity-critical-bg);
    color: var(--severity-critical);
    border: 1px solid var(--severity-critical-border);
}

.stat-icon-high {
    background: var(--severity-high-bg);
    color: var(--severity-high);
    border: 1px solid var(--severity-high-border);
}

.stat-icon-warning {
    background: var(--severity-medium-bg);
    color: var(--severity-medium);
    border: 1px solid var(--severity-medium-border);
}

.stat-icon-medium {
    background: var(--severity-medium-bg);
    color: var(--severity-medium);
    border: 1px solid var(--severity-medium-border);
}

.stat-icon-info {
    background: var(--severity-info-bg);
    color: var(--severity-info);
    border: 1px solid var(--severity-info-border);
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    color: var(--text);
}

.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
}

.card-raised {
    background: var(--surface-raised);
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    padding: 24px;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary {
    background: var(--primary);
    color: #08111F;
    border-color: var(--primary);
}

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

.btn-secondary {
    background: var(--surface-raised);
    color: var(--text);
    border-color: var(--border-strong);
}

.btn-secondary:hover {
    background: var(--surface-hover);
}

.btn-danger {
    background: var(--severity-critical-bg);
    color: #FCA5A5;
    border-color: var(--severity-critical-border);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.24);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
    padding: 8px 12px;
}

.btn-ghost:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-block {
    display: flex;
    width: 100%;
}

/* ============================================
   Forms
   ============================================ */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    background: #0F172A;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.4;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input::placeholder {
    color: var(--text-faint);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
}

/* ============================================
   Auth Layout (Login / Setup)
   ============================================ */
.auth-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    flex-direction: column;
    gap: 16px;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo {
    width: 64px;
    height: 64px;
    border-radius: 14px;
    margin-bottom: 16px;
}

.auth-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.auth-tagline {
    font-size: 13px;
    color: var(--text-muted);
}

.auth-form {
    margin-top: 24px;
}

/* ============================================
   Flash Messages
   ============================================ */
.flash-messages {
    margin-bottom: 20px;
}

.flash {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
}

.flash-error {
    background: var(--severity-critical-bg);
    color: #FCA5A5;
    border: 1px solid var(--severity-critical-border);
}

.flash-success {
    background: var(--severity-low-bg);
    color: #86EFAC;
    border: 1px solid var(--severity-low-border);
}

.flash-info {
    background: var(--severity-info-bg);
    color: #7DD3FC;
    border: 1px solid var(--severity-info-border);
}

.flash-warning {
    background: var(--severity-medium-bg);
    color: #FCD34D;
    border: 1px solid var(--severity-medium-border);
}

/* ============================================
   Empty States
   ============================================ */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.empty-state-icon {
    width: 48px;
    height: 48px;
    color: var(--text-faint);
    margin-bottom: 16px;
}

.empty-state-text {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.empty-state-hint {
    font-size: 13px;
    color: var(--text-faint);
}

/* ============================================
   Severity Badges
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
}

.badge-info {
    background: var(--severity-info-bg);
    border: 1px solid var(--severity-info-border);
    color: #7DD3FC;
}

.badge-low {
    background: var(--severity-low-bg);
    border: 1px solid var(--severity-low-border);
    color: #86EFAC;
}

.badge-medium {
    background: var(--severity-medium-bg);
    border: 1px solid var(--severity-medium-border);
    color: #FCD34D;
}

.badge-high {
    background: var(--severity-high-bg);
    border: 1px solid var(--severity-high-border);
    color: #FDBA74;
}

.badge-critical {
    background: var(--severity-critical-bg);
    border: 1px solid var(--severity-critical-border);
    color: #FCA5A5;
}

/* ============================================
   Tables (foundation for later phases)
   ============================================ */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead th {
    background: #0F172A;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

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

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

/* ============================================
   Status Pills
   ============================================ */
.status-online {
    color: var(--success);
}

.status-offline {
    color: var(--danger);
}

.status-pending {
    color: var(--warning);
}

.status-disabled {
    color: var(--text-faint);
}

/* ============================================
   Utility Classes
   ============================================ */
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.text-mono { font-family: var(--font-mono); }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }

/* ============================================
   Tenant Switcher (super-admin sidebar)
   ============================================ */
.tenant-switcher {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

.tenant-switcher-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.tenant-switcher-btn:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
}

.tenant-switcher-btn.open {
    border-color: var(--primary);
}

.tenant-switcher-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--primary);
}

.tenant-switcher-label {
    flex: 1;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tenant-switcher-chevron {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: var(--text-faint);
    transition: transform 0.15s ease;
}

.tenant-switcher-btn.open .tenant-switcher-chevron {
    transform: rotate(180deg);
}

.tenant-switcher-dropdown {
    display: none;
    margin-top: 6px;
    background: var(--surface-raised);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    padding: 4px;
    max-height: 280px;
    overflow-y: auto;
}

.tenant-switcher-dropdown.open {
    display: block;
}

.tenant-switcher-option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
    text-decoration: none;
}

.tenant-switcher-option:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.tenant-switcher-option.active {
    background: var(--severity-info-bg);
    color: #7DD3FC;
}

.tenant-switcher-option.disabled-tenant {
    opacity: 0.55;
}

.tenant-option-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.tenant-switcher-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 8px;
}

.tenant-manage-link {
    color: var(--primary) !important;
    font-weight: 600;
}

/* Tenant indicator for regular users */
.tenant-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}

.tenant-indicator-icon {
    width: 16px;
    height: 16px;
    color: var(--secondary);
    flex-shrink: 0;
}

.tenant-indicator-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Mobile tenant badge */
.mobile-tenant-badge {
    margin-left: auto;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 6px;
    background: var(--severity-info-bg);
    border: 1px solid var(--severity-info-border);
    color: #7DD3FC;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.mobile-tenant-all {
    background: var(--severity-medium-bg);
    border-color: var(--severity-medium-border);
    color: #FCD34D;
}

/* ============================================
   Form Section Labels and Hints
   ============================================ */
.form-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-faint);
    margin-bottom: 12px;
    margin-top: 20px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.form-section-label:first-child {
    margin-top: 0;
}

.form-hint {
    display: block;
    font-size: 11px;
    color: var(--text-faint);
    margin-top: 4px;
}
