/* ══════════════════════════════════════════════════════════════════
   TBMSecure Control Center — Dashboard Styles
   Dark premium NOC-style theme with glassmorphism
   ══════════════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties ── */
:root {
    /* Base palette */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2035;
    --bg-card: rgba(17, 24, 39, 0.85);
    --bg-card-hover: rgba(26, 32, 53, 0.95);
    --bg-glass: rgba(255, 255, 255, 0.03);
    
    /* Borders */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-medium: rgba(255, 255, 255, 0.1);
    --border-accent: rgba(99, 102, 241, 0.3);
    
    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-dim: #475569;
    
    /* Accent colors */
    --accent-blue: #6366f1;
    --accent-blue-glow: rgba(99, 102, 241, 0.15);
    --accent-cyan: #22d3ee;
    --accent-green: #10b981;
    --accent-green-glow: rgba(16, 185, 129, 0.15);
    --accent-yellow: #f59e0b;
    --accent-yellow-glow: rgba(245, 158, 11, 0.15);
    --accent-red: #ef4444;
    --accent-red-glow: rgba(239, 68, 68, 0.2);
    --accent-red-dark: #dc2626;
    --accent-purple: #a855f7;
    
    /* Status colors */
    --status-active: #ef4444;
    --status-escalated: #f59e0b;
    --status-duress: #1e1e1e;
    --status-safe: #10b981;
    --status-updating: #6366f1;
    
    /* Sizing */
    --sidebar-width: 320px;
    --detail-width: 380px;
    --header-height: 56px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --shadow-glow-red: 0 0 20px rgba(239, 68, 68, 0.3);
    --shadow-glow-blue: 0 0 20px rgba(99, 102, 241, 0.3);
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 5px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

/* ══════════════════════════════════════════
   HEADER
   ══════════════════════════════════════════ */
.header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    z-index: 100;
    position: relative;
}

.header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-blue), var(--accent-red), transparent);
    opacity: 0.4;
}

.header__left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header__logo-pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-red);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { 
        box-shadow: 0 0 4px var(--accent-red), 0 0 12px rgba(239, 68, 68, 0.4); 
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 0 8px var(--accent-red), 0 0 24px rgba(239, 68, 68, 0.6); 
        transform: scale(1.15);
    }
}

.header__title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

.header__badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--accent-blue-glow);
    color: var(--accent-blue);
    border: 1px solid rgba(99, 102, 241, 0.2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    vertical-align: middle;
    margin-left: 6px;
}

.header__right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header__live-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.header__live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-yellow);
    transition: background var(--transition-base);
}

.header__live-dot.connected {
    background: var(--accent-green);
    animation: pulse-glow-green 2s ease-in-out infinite;
}

@keyframes pulse-glow-green {
    0%, 100% { box-shadow: 0 0 4px var(--accent-green); }
    50% { box-shadow: 0 0 12px var(--accent-green); }
}

.header__time {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: var(--text-muted);
}

/* ══════════════════════════════════════════
   MAIN LAYOUT (3-panel)
   ══════════════════════════════════════════ */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr var(--detail-width);
    height: calc(100vh - var(--header-height));
    overflow: hidden;
}

/* ══════════════════════════════════════════
   SIDEBAR — Alerts List
   ══════════════════════════════════════════ */
.sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar__title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar__title svg {
    color: var(--accent-red);
}

.sidebar__count {
    font-size: 12px;
    font-weight: 700;
    background: var(--accent-red);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
    transition: all var(--transition-base);
}

.sidebar__count.zero {
    background: var(--text-dim);
}

.sidebar__list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.sidebar__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 8px;
    color: var(--text-muted);
    text-align: center;
}

.sidebar__empty p {
    font-size: 14px;
    font-weight: 500;
}

.sidebar__empty span {
    font-size: 12px;
    color: var(--text-dim);
}

/* Alert Card in sidebar */
.alert-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.alert-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    border-radius: 3px 0 0 3px;
    transition: background var(--transition-base);
}

.alert-card--active::before { background: var(--status-active); }
.alert-card--escalated::before { background: var(--status-escalated); }
.alert-card--duress::before { background: var(--text-primary); box-shadow: var(--shadow-glow-red); }
.alert-card--updating::before { background: var(--status-updating); }

.alert-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-medium);
    transform: translateX(2px);
}

.alert-card.selected {
    border-color: var(--accent-blue);
    background: var(--accent-blue-glow);
}

.alert-card--duress {
    border-color: rgba(239, 68, 68, 0.3);
    animation: duress-pulse 2s ease-in-out infinite;
}

@keyframes duress-pulse {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: inset 0 0 20px rgba(239, 68, 68, 0.08), var(--shadow-glow-red); }
}

.alert-card__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.alert-card__pid {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.alert-card__status {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.alert-card__status--active {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}

.alert-card__status--escalated {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-yellow);
}

.alert-card__status--duress {
    background: rgba(239, 68, 68, 0.25);
    color: #fff;
    animation: duress-text-flash 1.5s ease-in-out infinite;
}

@keyframes duress-text-flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.alert-card__status--updating {
    background: var(--accent-blue-glow);
    color: var(--accent-blue);
}

.alert-card__name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.alert-card__meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

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

/* ══════════════════════════════════════════
   MAP
   ══════════════════════════════════════════ */
.map-container {
    position: relative;
    overflow: hidden;
}

.map {
    width: 100%;
    height: 100%;
}

.map__overlay-stats {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    gap: 8px;
    z-index: 10;
}

.stat-chip {
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 64px;
}

.stat-chip__label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.stat-chip__value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-chip--danger .stat-chip__value { color: var(--accent-red); }
.stat-chip--warning .stat-chip__value { color: var(--accent-yellow); }

/* Custom marker styles */
.marker-pin {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    cursor: pointer;
    transition: transform var(--transition-fast);
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.marker-pin:hover {
    transform: rotate(-45deg) scale(1.15);
}

.marker-pin__inner {
    transform: rotate(45deg);
    font-size: 14px;
    line-height: 1;
}

.marker-pin--active {
    background: var(--accent-red);
    animation: marker-pulse-active 2s ease-in-out infinite;
}

.marker-pin--escalated {
    background: var(--accent-yellow);
}

.marker-pin--duress {
    background: #1a1a1a;
    border: 2px solid var(--accent-red);
    animation: marker-pulse-duress 1s ease-in-out infinite;
}

.marker-pin--safe {
    background: var(--accent-green);
    opacity: 0.6;
}

@keyframes marker-pulse-active {
    0%, 100% { box-shadow: 0 0 4px rgba(239, 68, 68, 0.5); }
    50% { box-shadow: 0 0 16px rgba(239, 68, 68, 0.8), 0 0 32px rgba(239, 68, 68, 0.3); }
}

@keyframes marker-pulse-duress {
    0%, 100% { box-shadow: 0 0 4px rgba(239, 68, 68, 0.8); transform: rotate(-45deg) scale(1); }
    50% { box-shadow: 0 0 24px rgba(239, 68, 68, 1), 0 0 48px rgba(239, 68, 68, 0.4); transform: rotate(-45deg) scale(1.1); }
}

/* ══════════════════════════════════════════
   DETAIL PANEL (Right)
   ══════════════════════════════════════════ */
.detail-panel {
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-subtle);
    overflow-y: auto;
    padding: 16px;
}

.detail-panel__placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 12px;
    color: var(--text-dim);
    text-align: center;
    line-height: 1.6;
    font-size: 14px;
}

.detail-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 12px;
}

.detail-card__header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.detail-card__avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.detail-card__name {
    font-size: 16px;
    font-weight: 600;
}

.detail-card__pid {
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-muted);
}

.detail-card__status-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: auto;
    white-space: nowrap;
}

.detail-card__meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.detail-meta-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.detail-meta-row__icon {
    font-size: 14px;
    width: 20px;
    text-align: center;
}

.detail-card__section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* Telemetry Grid */
.telemetry-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.telemetry-item {
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
}

.telemetry-item__label {
    display: block;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    margin-bottom: 2px;
}

.telemetry-item__value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Battery bar */
.battery-bar {
    width: 100%;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
}

.battery-bar__fill {
    height: 100%;
    border-radius: 2px;
    background: var(--accent-green);
    transition: width var(--transition-base), background var(--transition-base);
}

.battery-bar__fill.low {
    background: var(--accent-red);
}

.battery-bar__fill.medium {
    background: var(--accent-yellow);
}

/* Notes */
.notes-content {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    padding: 8px;
    background: var(--bg-glass);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    min-height: 40px;
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.tag {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--accent-blue-glow);
    color: var(--accent-blue);
    border: 1px solid rgba(99, 102, 241, 0.2);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.tag--danger {
    background: var(--accent-red-glow);
    color: var(--accent-red);
    border-color: rgba(239, 68, 68, 0.2);
}

/* Chart wrapper */
.chart-wrapper {
    margin-bottom: 12px;
    background: var(--bg-glass);
    border-radius: var(--radius-sm);
    padding: 8px;
    border: 1px solid var(--border-subtle);
}

/* ══════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════ */
@media (max-width: 1200px) {
    .layout {
        grid-template-columns: 260px 1fr 320px;
    }
}

@media (max-width: 960px) {
    .layout {
        grid-template-columns: 240px 1fr;
    }
    .detail-panel {
        display: none;
    }
}

@media (max-width: 640px) {
    .layout {
        grid-template-columns: 1fr;
    }
    .sidebar {
        display: none;
    }
}
