/* 
   COSMO Intelligence Dashboard - Modern Redesign 
   Injects modern UI/UX patterns while preserving structure
*/

:root {
    /* Refined Palette */
    --bg-root: #090c10;
    --bg-glass: rgba(22, 27, 34, 0.7);
    --bg-card: #161b22;
    --bg-card-hover: #1c2128;
    
    --accent-blue-glow: rgba(88, 166, 255, 0.15);
    --accent-orange-glow: rgba(243, 156, 18, 0.15);
    
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    --shadow-surface: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(88, 166, 255, 0.1);
}

body {
    background: var(--bg-root);
    background-image: 
        radial-gradient(circle at 10% 10%, rgba(88, 166, 255, 0.05) 0%, transparent 20%),
        radial-gradient(circle at 90% 90%, rgba(35, 134, 54, 0.05) 0%, transparent 20%);
    background-attachment: fixed;
}

/* ==================== HEADER & NAV ==================== */

header {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 12px 24px;
}

.header-content {
    max-width: 1600px;
}

.run-name {
    font-family: 'SF Mono', 'Monaco', monospace;
    letter-spacing: -0.5px;
    background: linear-gradient(90deg, #fff, #8b949e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Floating Nav Pill Design */
nav {
    background: transparent;
    border-bottom: none;
    margin-top: 10px;
    padding-bottom: 10px;
    position: sticky;
    top: 60px;
    z-index: 900;
    pointer-events: none; /* Let clicks pass through container */
}

.nav-content {
    max-width: 1600px;
    background: rgba(13, 17, 23, 0.8);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 6px;
    border-radius: 100px;
    display: inline-flex;
    gap: 4px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.2);
    pointer-events: auto; /* Re-enable clicks */
    margin: 0 auto;
    left: 50%;
    position: relative;
    transform: translateX(-50%);
}

.nav-link {
    padding: 8px 16px;
    border-bottom: none;
    border-radius: 20px;
    font-weight: 500;
    font-size: 12px;
    transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    opacity: 0.7;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    opacity: 1;
    transform: translateY(-1px);
}

.nav-link.active {
    background: var(--accent-blue);
    color: white;
    opacity: 1;
    box-shadow: 0 2px 12px rgba(88, 166, 255, 0.4);
    border-bottom-color: transparent;
}

/* ==================== CARDS & LAYOUT ==================== */

.content {
    max-width: 1600px;
    padding: 24px 40px;
}

.section, .run-config-card, .stat-card, .dream-card, .goal-card, .thought-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-surface);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.section:hover, .dream-card:hover, .goal-card:hover {
    border-color: rgba(88, 166, 255, 0.3);
    box-shadow: var(--shadow-glow), var(--shadow-surface);
}

.section-title {
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, rgba(255,255,255,0.1), transparent);
}

/* Stats Bar Modernization */
.stats-bar {
    background: transparent;
    border: none;
    padding: 0;
    gap: 20px;
}

.stat {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 16px 24px;
    border-radius: var(--radius-md);
    flex: 1;
    position: relative;
    overflow: hidden;
}

.stat::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-blue), transparent);
    opacity: 0.5;
}

.stat-value {
    font-family: 'SF Mono', monospace;
    font-size: 28px;
    letter-spacing: -1px;
}

/* ==================== TABLES ==================== */

.clean-table thead th {
    background: transparent;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.clean-table tbody tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: background 0.2s;
}

.clean-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.score {
    border-radius: 100px;
    font-weight: 600;
    padding: 4px 10px;
}

/* ==================== INTERACTIVE ELEMENTS ==================== */

/* Buttons */
.btn {
    border-radius: 8px;
    font-weight: 500;
    letter-spacing: 0.3px;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, #238636 0%, #2ea043 100%);
    box-shadow: 0 2px 8px rgba(35, 134, 54, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(35, 134, 54, 0.5);
}

/* Inputs */
.form-input, .form-select, .form-textarea {
    background: #0d1117;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus, .form-textarea:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.1);
}

/* ==================== QUERY INTERFACE ==================== */

.info-banner {
    background: linear-gradient(90deg, rgba(88, 166, 255, 0.05), transparent);
    border: 1px solid rgba(88, 166, 255, 0.2);
    border-left: 4px solid var(--accent-blue);
}

.quick-action-btn {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 20px;
    padding: 8px 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.quick-action-btn:hover {
    background: rgba(88, 166, 255, 0.1);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

/* ==================== MEMORY GRAPH ==================== */

.memory-graph-container {
    background: radial-gradient(circle at center, #161b22 0%, #0d1117 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.memory-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(8px);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 11px;
    color: var(--text-secondary);
    pointer-events: none;
}

.legend-title {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* Graph Interaction Styles */
.graph-node {
    transition: opacity 0.3s, stroke-width 0.2s;
}

.graph-link {
    transition: stroke-opacity 0.3s, stroke-width 0.2s;
}

.graph-node.dimmed {
    opacity: 0.1 !important;
}

.graph-node.selected {
    stroke: #fff !important;
    stroke-width: 3px !important;
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.5));
}

.graph-link.highlighted {
    stroke-opacity: 0.8 !important;
    stroke: #fff !important;
}

.node-label {
    text-shadow: 0 2px 4px rgba(0,0,0,0.9);
    pointer-events: none;
    font-family: 'SF Mono', monospace;
    letter-spacing: -0.3px;
}

/* Improved Tooltip */
.memory-tooltip {
    position: absolute;
    background: rgba(22, 27, 34, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(88, 166, 255, 0.3);
    padding: 12px;
    border-radius: 8px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    min-width: 200px;
    display: none;
}

.memory-tooltip-concept {
    font-weight: 600;
    color: #fff;
    margin-bottom: 6px;
    font-size: 13px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 6px;
}

.memory-tooltip-metrics {
    color: var(--text-secondary);
    font-family: 'SF Mono', monospace;
    font-size: 10px;
    margin-bottom: 4px;
}

.memory-tooltip-connections {
    color: var(--accent-blue);
    font-size: 11px;
}

/* ==================== DREAM CARDS ==================== */

.dream-card.dream-narrative {
    background: linear-gradient(135deg, rgba(243,156,18,0.1) 0%, rgba(22,27,34,1) 100%);
    border: 1px solid rgba(243, 156, 18, 0.3);
    box-shadow: 0 4px 20px rgba(243, 156, 18, 0.15);
}

/* ==================== LOADING STATES ==================== */

.spinner {
    border-color: rgba(255,255,255,0.1);
    border-top-color: var(--accent-blue);
}

/* ==================== TOAST NOTIFICATIONS ==================== */

#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: rgba(22, 27, 34, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 4px solid var(--accent-blue);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    min-width: 300px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.success { border-left-color: #238636; }
.toast.error { border-left-color: #da3633; }
.toast.warning { border-left-color: #f39c12; }

.toast-close {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    margin-left: 12px;
}

.toast-close:hover {
    color: white;
}
