/* ==========================================================================
   SilverGrove Core Premium Design System (Vanilla CSS / HSL Based)
   ========================================================================== */

:root {
    --bg-dark: #070a13;
    --card-bg: rgba(15, 23, 42, 0.45);
    --card-inner: rgba(30, 41, 59, 0.35);
    --border-color: rgba(255, 255, 255, 0.07);
    --border-hover: rgba(255, 255, 255, 0.15);
    
    /* Elegant Glowing Tailored HSL Colors */
    --color-text-primary: #f8fafc;
    --color-text-secondary: #94a3b8;
    --color-text-muted: #64748b;
    
    --hsl-primary: 224, 71%, 63%; /* Deep Indigo */
    --hsl-success: 142, 71%, 45%; /* Emerald */
    --hsl-warning: 32, 95%, 44%;  /* Amber */
    --hsl-danger: 350, 89%, 46%;  /* Coral Red */
    --hsl-info: 186, 94%, 43%;    /* Cyan */
    
    --color-primary: hsl(var(--hsl-primary));
    --color-success: hsl(var(--hsl-success));
    --color-warning: hsl(var(--hsl-warning));
    --color-danger: hsl(var(--hsl-danger));
    --color-info: hsl(var(--hsl-info));
}

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

body {
    background-color: var(--bg-dark);
    color: var(--color-text-primary);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    padding: 24px;
}

/* Translucent Background Glows */
.bg-glow {
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(140px);
    opacity: 0.12;
    pointer-events: none;
    z-index: -1;
}

.bg-glow-1 {
    background: radial-gradient(circle, var(--color-primary) 0%, transparent 70%);
    top: -100px;
    left: -100px;
}

.bg-glow-2 {
    background: radial-gradient(circle, var(--color-info) 0%, transparent 70%);
    bottom: -100px;
    right: -100px;
}

/* Premium Typography Headers */
h1, h2, h3, h4 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* Glassmorphic Panel Core Utilities */
.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-panel-inner {
    background: var(--card-inner);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 14px;
    padding: 16px;
    transition: all 0.3s ease;
}

.glass-panel-inner:hover {
    border-color: rgba(255, 255, 255, 0.08);
}

/* Portal Container Structure */
.portal-container {
    max-width: 1680px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* MAIN HEADER */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 30px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-icon {
    font-size: 32px;
    filter: drop-shadow(0 0 10px rgba(74, 222, 128, 0.3));
}

.logo-text h1 {
    font-size: 26px;
    font-weight: 800;
    background: linear-gradient(135deg, #ffffff 30%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text p {
    font-size: 12px;
    color: var(--color-text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(22, 163, 74, 0.1);
    padding: 6px 14px;
    border-radius: 30px;
    border: 1px solid rgba(22, 163, 74, 0.2);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 10px #22c55e;
    animation: pulse 2s infinite;
}

.status-label {
    font-size: 13px;
    font-weight: 600;
    color: #4ade80;
}

/* BUTTONS */
.btn {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 14px;
    padding: 10px 20px;
    border-radius: 12px;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, #3b82f6 100%);
    color: white;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(59, 130, 246, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text-primary);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

/* GRID SETUP */
.dashboard-grid {
    display: grid;
    grid-template-columns: 320px 1fr 340px;
    gap: 24px;
    height: calc(100vh - 150px);
}

/* PANEL & WORKSPACE CARDS */
.panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px;
    overflow-y: auto;
}

.panel-title {
    font-size: 18px;
    color: var(--color-text-primary);
    border-left: 3px solid var(--color-primary);
    padding-left: 10px;
    margin-bottom: 8px;
}

/* RESIDENT LIST */
.residents-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.resident-card {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.resident-card.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.15);
}

.res-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.res-name {
    font-size: 15px;
    font-weight: 600;
}

.res-age {
    font-size: 12px;
    color: var(--color-text-muted);
}

.res-meta {
    font-size: 12px;
    color: var(--color-text-secondary);
}

/* DETAILED PROFILE CARD */
.profile-card {
    margin-top: auto;
    padding: 16px;
}

.profile-title {
    font-size: 16px;
    margin-bottom: 12px;
}

.profile-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    margin-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 10px;
}

.profile-meds h4 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
}

.profile-meds ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.profile-meds li {
    font-size: 12px;
    color: var(--color-text-secondary);
    background: rgba(255, 255, 255, 0.02);
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

/* CENTER WORKSPACE LAYOUT */
.workspace-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: 100%;
}

.vitals-container {
    padding: 24px;
    flex-shrink: 0;
}

.panel-header-with-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

/* VITALS SENSOR GRID */
.vitals-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
}

.vital-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 120px;
    position: relative;
    overflow: hidden;
}

.vital-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.vital-icon {
    font-size: 18px;
}

.vital-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.vital-value {
    font-family: 'Outfit', sans-serif;
    font-size: 26px;
    font-weight: 700;
    margin: 10px 0;
}

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

.vital-footer {
    font-size: 11px;
    color: var(--color-text-muted);
}

.occupancy-val {
    font-size: 18px;
    text-transform: capitalize;
}

/* Glow Anomalies */
#card-bp.anomaly-alert {
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.25);
    background: rgba(239, 68, 68, 0.05);
}

#card-gait.anomaly-alert {
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.25);
    background: rgba(245, 158, 11, 0.05);
}

/* MULTI-AGENT WORKSPACE */
.agents-container {
    padding: 24px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.agents-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    flex-grow: 1;
    overflow: hidden;
}

.agent-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
    overflow: hidden;
}

.agent-badge {
    display: flex;
    align-items: center;
    gap: 10px;
}

.agent-avatar {
    font-size: 24px;
    background: rgba(255, 255, 255, 0.05);
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

.agent-identity h3 {
    font-size: 14px;
}

.agent-identity p {
    font-size: 10px;
    color: var(--color-text-muted);
    text-transform: uppercase;
}

.agent-status-label {
    display: flex;
}

.status-pill {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 20px;
}

.status-waiting {
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text-muted);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.status-running {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
    animation: borderPulse 1.5s infinite;
}

.status-completed {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.status-failed {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.agent-output-box {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    padding: 12px;
    flex-grow: 1;
    overflow-y: auto;
    font-size: 12px;
    line-height: 1.5;
    color: var(--color-text-secondary);
}

.placeholder-text {
    color: var(--color-text-muted);
    font-style: italic;
    text-align: center;
    margin-top: 20px;
}

/* OUTBOUND A2A ALERTS TIMELINE */
.alerts-timeline {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex-grow: 1;
}

.no-alerts-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
    height: 200px;
    color: var(--color-text-muted);
    padding: 20px;
}

.timeline-empty-icon {
    font-size: 32px;
    opacity: 0.4;
}

.no-alerts-placeholder p {
    font-size: 13px;
    line-height: 1.4;
}

.alert-feed-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    border-left-width: 4px;
    animation: fadeIn 0.4s ease;
}

.alert-feed-item.warning {
    border-left: 3px solid var(--color-warning);
}

.alert-feed-item.critical {
    border-left: 3px solid var(--color-danger);
}

.alert-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-item-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--color-text-primary);
}

.alert-item-time {
    font-size: 10px;
    color: var(--color-text-muted);
}

.alert-item-msg {
    font-size: 12px;
    color: var(--color-text-secondary);
    line-height: 1.4;
}

.alert-item-tag {
    align-self: flex-start;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text-muted);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.07);
}

/* ALERT MODAL WINDOW */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: all 0.3s ease;
}

.modal-content {
    width: 600px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 16px;
}

.modal-warning-icon {
    font-size: 36px;
    filter: drop-shadow(0 0 10px var(--color-danger));
}

.modal-header h2 {
    font-size: 22px;
    color: #ff4a4a;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.modal-correlation-box h4,
.modal-actions-box h4 {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--color-text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.05em;
}

.modal-actions-box ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modal-actions-box li {
    background: rgba(22, 163, 74, 0.08);
    border: 1px solid rgba(22, 163, 74, 0.15);
    padding: 8px 12px;
    border-radius: 8px;
    color: #4ade80;
    font-weight: 500;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
}

/* HELPER UTILITIES */
.hidden {
    display: none !hidden !important;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

.loading-spinner {
    text-align: center;
    color: var(--color-text-muted);
    font-style: italic;
    margin: 20px 0;
}

/* KEYFRAMES & ANIMATIONS */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

@keyframes borderPulse {
    0% {
        border-color: rgba(59, 130, 246, 0.3);
    }
    50% {
        border-color: rgba(59, 130, 246, 0.7);
        box-shadow: 0 0 10px rgba(59, 130, 246, 0.15);
    }
    100% {
        border-color: rgba(59, 130, 246, 0.3);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleUp {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}
