/**
 * Abide AI Governance Dashboard - UI/UX Enhancement Suite v3.0
 * 
 * This stylesheet implements four key improvements:
 * 1. Interactive Drill-Down Metric Cards
 * 2. Consolidated User Profile Dropdown
 * 3. Elevated "Human In Command" Hub
 * 4. Enhanced Table Scannability with Status Dots
 */

/* ===== CSS CUSTOM PROPERTIES ===== */
:root {
    /* Core Colors */
    --midnight: #0B0F19;
    --navy-900: #111827;
    --navy-800: #1F2937;
    --navy-700: #374151;
    --navy-600: #4B5563;
    
    /* Brand Colors */
    --teal: #3EBDC4;
    --teal-muted: rgba(62, 189, 196, 0.15);
    --teal-glow: rgba(62, 189, 196, 0.4);
    
    /* Status Colors */
    --green: #10B981;
    --green-muted: rgba(16, 185, 129, 0.15);
    --red: #EF4444;
    --red-muted: rgba(239, 68, 68, 0.15);
    --amber: #F59E0B;
    --amber-muted: rgba(245, 158, 11, 0.15);
    --purple: #8B5CF6;
    --purple-muted: rgba(139, 92, 246, 0.15);
    
    /* Text Colors */
    --text-1: #F9FAFB;
    --text-2: #E5E7EB;
    --text-3: #9CA3AF;
    --text-muted: #6B7280;
    
    /* Surface Colors */
    --surface-1: rgba(31, 41, 55, 0.95);
    --surface-2: rgba(17, 24, 39, 0.98);
    --border: rgba(75, 85, 99, 0.5);
    --border-hover: rgba(62, 189, 196, 0.5);
    
    /* Fonts */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    
    /* Command Hub - Elevated styling */
    --command-primary: #10B981;
    --command-glow: rgba(16, 185, 129, 0.5);
    --command-bg: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(6, 95, 70, 0.12));
    --command-border: rgba(16, 185, 129, 0.6);
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px var(--teal-glow);
}

/* ===== LIGHT THEME ===== */
[data-theme="light"] {
    --midnight: #F8FAFC;
    --navy-900: #F1F5F9;
    --navy-800: #E2E8F0;
    --navy-700: #CBD5E1;
    --navy-600: #94A3B8;
    
    --teal: #0D9488;
    --teal-muted: rgba(13, 148, 136, 0.12);
    --teal-glow: rgba(13, 148, 136, 0.3);
    
    --green: #059669;
    --green-muted: rgba(5, 150, 105, 0.12);
    --red: #DC2626;
    --red-muted: rgba(220, 38, 38, 0.12);
    --amber: #D97706;
    --amber-muted: rgba(217, 119, 6, 0.12);
    --purple: #7C3AED;
    --purple-muted: rgba(124, 58, 237, 0.12);
    
    --text-1: #0F172A;
    --text-2: #334155;
    --text-3: #475569;
    --text-muted: #64748B;
    
    --surface-1: #FFFFFF;
    --surface-2: #F8FAFC;
    --border: rgba(15, 23, 42, 0.12);
    --border-hover: rgba(13, 148, 136, 0.5);
    
    --command-primary: #059669;
    --command-glow: rgba(5, 150, 105, 0.35);
    --command-bg: linear-gradient(135deg, rgba(5, 150, 105, 0.08), rgba(6, 95, 70, 0.06));
    --command-border: rgba(5, 150, 105, 0.5);
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* ============================================================================
   1. INTERACTIVE DRILL-DOWN METRIC CARDS
   ============================================================================ */

.metric-card {
    position: relative;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all var(--transition-base);
    overflow: hidden;
}

/* Hover glow effect */
.metric-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 0%, var(--teal-muted) 100%);
    opacity: 0;
    transition: opacity var(--transition-base);
    pointer-events: none;
}

.metric-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-lg), 0 0 24px var(--teal-glow);
}

.metric-card:hover::before {
    opacity: 1;
}

.metric-card:active {
    transform: translateY(-2px);
}

/* Card inner structure */
.metric-card .metric-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.metric-card .metric-title {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-card .metric-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.metric-card .metric-icon.teal { background: var(--teal-muted); }
.metric-card .metric-icon.red { background: var(--red-muted); }
.metric-card .metric-icon.amber { background: var(--amber-muted); }
.metric-card .metric-icon.green { background: var(--green-muted); }

.metric-card .metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-1);
    margin-bottom: 8px;
    font-family: var(--font-mono);
}

.metric-card .metric-trend {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.metric-card .metric-trend.positive { color: var(--green); }
.metric-card .metric-trend.negative { color: var(--red); }

/* Drill-down hint - appears on hover */
.metric-card .drill-down-hint {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    opacity: 0;
    transform: translateY(8px);
    transition: all var(--transition-base);
}

.metric-card:hover .drill-down-hint {
    opacity: 1;
    transform: translateY(0);
    color: var(--teal);
}

.metric-card .drill-down-hint .chevron {
    font-size: 1rem;
    transition: transform var(--transition-fast);
}

.metric-card:hover .drill-down-hint .chevron {
    transform: translateX(4px);
}

/* Click ripple effect */
.metric-card .ripple {
    position: absolute;
    border-radius: 50%;
    background: var(--teal-glow);
    transform: scale(0);
    animation: metricRipple 0.6s ease-out;
    pointer-events: none;
}

@keyframes metricRipple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Keyboard focus state */
.metric-card:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 2px;
}

/* ============================================================================
   2. CONSOLIDATED USER PROFILE DROPDOWN
   ============================================================================ */

.user-profile-container {
    position: relative;
}

.user-profile-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 6px 6px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 100px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.user-profile-trigger:hover {
    background: var(--navy-700);
    border-color: var(--border-hover);
}

.user-profile-trigger .avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--purple), var(--teal));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}

.user-profile-trigger .user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
}

.user-profile-trigger .user-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-1);
}

.user-profile-trigger .user-role {
    font-size: 0.6875rem;
    color: var(--text-muted);
}

.user-profile-trigger .dropdown-icon {
    font-size: 0.625rem;
    color: var(--text-muted);
    transition: transform var(--transition-fast);
    margin-left: 4px;
}

.user-profile-trigger[aria-expanded="true"] .dropdown-icon {
    transform: rotate(180deg);
}

/* Profile Dropdown Menu */
.user-profile-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 280px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.98);
    transition: all var(--transition-base);
    z-index: 1000;
    overflow: hidden;
}

.user-profile-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.user-profile-menu .menu-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}

.user-profile-menu .menu-header .avatar-lg {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--purple), var(--teal));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    font-weight: 600;
    color: white;
}

.user-profile-menu .menu-header .user-details .name {
    font-weight: 600;
    color: var(--text-1);
    font-size: 0.9375rem;
}

.user-profile-menu .menu-header .user-details .email {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Menu Sections */
.user-profile-menu .menu-section {
    padding: 8px;
}

.user-profile-menu .menu-section-label {
    padding: 8px 12px 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.user-profile-menu .menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    background: none;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text-2);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
    text-decoration: none;
}

.user-profile-menu .menu-item:hover {
    background: var(--navy-700);
    color: var(--text-1);
}

.user-profile-menu .menu-item .icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.user-profile-menu .menu-item .label {
    flex: 1;
}

.user-profile-menu .menu-item .shortcut {
    font-size: 0.6875rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.user-profile-menu .menu-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 8px;
}

.user-profile-menu .menu-item.danger {
    color: var(--red);
}

.user-profile-menu .menu-item.danger:hover {
    background: var(--red-muted);
}

/* Theme Toggle Row */
.theme-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 8px;
}

.theme-toggle-row:hover {
    background: var(--navy-700);
}

.theme-toggle-row .label-group {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-2);
    font-size: 0.875rem;
}

.theme-toggle-row .label-group .icon {
    font-size: 1rem;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--navy-600);
    border-radius: 12px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.toggle-switch.active {
    background: var(--teal);
}

.toggle-switch.active::after {
    transform: translateX(20px);
}

/* ============================================================================
   3. ELEVATED "HUMAN IN COMMAND" HUB
   ============================================================================ */

.command-hub {
    position: relative;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    background: var(--command-bg);
    border: 2px solid var(--command-border);
    border-radius: 16px;
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    transition: all var(--transition-base);
    box-shadow: 
        0 0 0 1px rgba(16, 185, 129, 0.1),
        0 4px 20px rgba(16, 185, 129, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Animated shimmer effect */
.command-hub::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(16, 185, 129, 0.15) 50%,
        transparent 100%
    );
    transform: translateX(-100%);
    animation: commandShimmer 3s ease-in-out infinite;
}

@keyframes commandShimmer {
    0% { transform: translateX(-100%); }
    50%, 100% { transform: translateX(100%); }
}

.command-hub:hover {
    border-color: var(--command-primary);
    transform: translateY(-2px);
    box-shadow: 
        0 0 0 2px rgba(16, 185, 129, 0.2),
        0 8px 32px rgba(16, 185, 129, 0.25),
        0 0 40px var(--command-glow),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Status Indicator with pulse */
.command-hub .status-beacon {
    position: relative;
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, var(--command-primary), #065F46);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.command-hub .status-beacon .icon {
    font-size: 1.5rem;
    position: relative;
    z-index: 1;
}

/* Live indicator dot */
.command-hub .status-beacon::after {
    content: '';
    position: absolute;
    top: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    background: var(--command-primary);
    border: 3px solid var(--surface-1);
    border-radius: 50%;
    animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {
    0%, 100% {
        box-shadow: 0 0 0 0 var(--command-glow);
        opacity: 1;
    }
    50% {
        box-shadow: 0 0 0 8px transparent;
        opacity: 0.8;
    }
}

/* Command Info Text */
.command-hub .command-content {
    flex: 1;
    min-width: 0;
}

.command-hub .command-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-1);
    margin-bottom: 4px;
}

.command-hub .command-title .live-badge {
    padding: 3px 10px;
    background: var(--command-primary);
    color: white;
    font-size: 0.625rem;
    font-weight: 700;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.command-hub .command-subtitle {
    font-size: 0.8125rem;
    color: var(--text-3);
}

.command-hub .command-arrow {
    font-size: 1.375rem;
    color: var(--command-primary);
    transition: transform var(--transition-fast);
    flex-shrink: 0;
}

.command-hub:hover .command-arrow {
    transform: translateX(6px);
}

/* Responsive adjustments */
@media (max-width: 1100px) {
    .command-hub {
        padding: 12px 16px;
    }
    
    .command-hub .status-beacon {
        width: 44px;
        height: 44px;
    }
    
    .command-hub .command-title {
        font-size: 0.9375rem;
    }
    
    .command-hub .command-subtitle {
        display: none;
    }
}

@media (max-width: 900px) {
    .command-hub .command-content {
        display: none;
    }
    
    .command-hub {
        padding: 10px 14px;
    }
}

/* ============================================================================
   4. ENHANCED TABLE SCANNABILITY
   ============================================================================ */

/* Status Dot Indicator */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
}

/* Glow effect for dots */
.status-dot::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    opacity: 0.4;
    animation: dotGlow 2s ease-in-out infinite;
}

@keyframes dotGlow {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.15); }
}

/* Status-specific colors */
.status-dot.approved,
.status-dot.allowed {
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
}
.status-dot.approved::after,
.status-dot.allowed::after {
    background: var(--green);
}

.status-dot.blocked,
.status-dot.denied {
    background: var(--red);
    box-shadow: 0 0 8px var(--red);
}
.status-dot.blocked::after,
.status-dot.denied::after {
    background: var(--red);
}

.status-dot.pending,
.status-dot.escalated {
    background: var(--amber);
    box-shadow: 0 0 8px var(--amber);
    animation: pendingPulse 1.5s ease-in-out infinite;
}
.status-dot.pending::after,
.status-dot.escalated::after {
    background: var(--amber);
}

@keyframes pendingPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Enhanced Decision Badge */
.decision-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border: 1px solid transparent;
}

.decision-badge.allowed {
    background: var(--green-muted);
    color: var(--green);
    border-color: rgba(16, 185, 129, 0.3);
}

.decision-badge.blocked {
    background: var(--red-muted);
    color: var(--red);
    border-color: rgba(239, 68, 68, 0.3);
}

.decision-badge.pending {
    background: var(--amber-muted);
    color: var(--amber);
    border-color: rgba(245, 158, 11, 0.3);
}

.decision-badge.escalated {
    background: var(--purple-muted);
    color: var(--purple);
    border-color: rgba(139, 92, 246, 0.3);
}

/* Relative Time Display */
.time-relative {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
}

.time-relative.recent {
    color: var(--teal);
    font-weight: 600;
}

.time-relative.today {
    color: var(--text-2);
}

.time-relative.older {
    color: var(--text-muted);
}

/* Enhanced Table Styling */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--surface-2);
}

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

.data-table td {
    padding: 14px 16px;
    font-size: 0.875rem;
    color: var(--text-2);
    border-bottom: 1px solid var(--border);
    transition: all var(--transition-fast);
}

.data-table tbody tr {
    transition: all var(--transition-fast);
    cursor: pointer;
}

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

.data-table tbody tr:hover td {
    color: var(--text-1);
}

/* Risk Score Bar */
.risk-score-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.risk-bar {
    width: 60px;
    height: 6px;
    background: var(--navy-700);
    border-radius: 3px;
    overflow: hidden;
}

.risk-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width var(--transition-base);
}

.risk-bar-fill.low { background: var(--green); }
.risk-bar-fill.medium { background: var(--amber); }
.risk-bar-fill.high { background: var(--red); }

.risk-value {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 600;
    min-width: 28px;
}

.risk-value.low { color: var(--green); }
.risk-value.medium { color: var(--amber); }
.risk-value.high { color: var(--red); }

/* Monospace for IDs */
.intent-id,
.trace-id,
.hash-value {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================================================
   OPERATIONAL MODE BADGE
   ============================================================================ */

.mode-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border: 1px solid;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mode-badge.enforcing {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.4);
    color: var(--green);
}

.mode-badge.enforcing:hover {
    background: rgba(16, 185, 129, 0.18);
    border-color: var(--green);
}

.mode-badge.shadow {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.4);
    color: var(--amber);
}

.mode-badge.shadow:hover {
    background: rgba(245, 158, 11, 0.18);
    border-color: var(--amber);
}

.mode-badge .mode-icon {
    font-size: 0.875rem;
}

/* ============================================================================
   ANIMATIONS & UTILITIES
   ============================================================================ */

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

@keyframes slideIn {
    from { transform: translateX(-10px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.animate-fade-in {
    animation: fadeIn var(--transition-base) ease forwards;
}

.animate-slide-in {
    animation: slideIn var(--transition-slow) ease forwards;
}

/* Responsive Utilities */
@media (max-width: 768px) {
    .metric-card .drill-down-hint {
        opacity: 1;
        transform: none;
    }
    
    .user-profile-trigger .user-info {
        display: none;
    }
    
    .data-table {
        font-size: 0.8125rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 10px 12px;
    }
}
