/* Cognitive Trace Panel - Next Level */
.cognitive-trace-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: linear-gradient(135deg, #0a0a1a 0%, #1a1a2e 100%);
    border: 1px solid rgba(123, 0, 255, 0.3);
    border-radius: 20px;
    padding: 25px;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    overflow-y: auto;
    z-index: 10000;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    animation: tracePanelIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    color: #e0e0ff;
    font-family: 'Inter', -apple-system, sans-serif;
}

@keyframes tracePanelIn {
    from { 
        opacity: 0; 
        transform: translate(-50%, -50%) scale(0.95); 
    }
    to { 
        opacity: 1; 
        transform: translate(-50%, -50%) scale(1); 
    }
}

/* Header */
.trace-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(123, 0, 255, 0.3);
}

.trace-title {
    display: flex;
    align-items: center;
    gap: 15px;
}

.trace-icon {
    font-size: 2.5em;
    background: linear-gradient(135deg, #7b00ff, #ff00ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: iconFloat 3s ease-in-out infinite;
}

@keyframes iconFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.trace-title h3 {
    margin: 0;
    font-size: 1.8em;
    font-weight: 700;
    background: linear-gradient(135deg, #fff, #a0a0ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.trace-subtitle {
    font-size: 0.9em;
    opacity: 0.7;
    margin-top: 5px;
}

.trace-close {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.trace-close:hover {
    background: rgba(255, 0, 100, 0.3);
    transform: rotate(90deg);
}

/* Process Timeline */
.process-timeline {
    margin: 30px 0;
    position: relative;
}

.process-step {
    display: flex;
    align-items: flex-start;
    margin-bottom: 30px;
    opacity: 0;
    animation: slideIn 0.5s ease forwards;
}

.process-step.animate-in {
    opacity: 1;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.step-connector {
    position: absolute;
    left: 35px;
    top: 50px;
    width: 2px;
    height: calc(100% + 10px);
    background: linear-gradient(to bottom, var(--step-color), transparent);
}

.step-connector.last {
    display: none;
}

.step-icon {
    width: 70px;
    height: 70px;
    background: rgba(var(--step-color-rgb), 0.1);
    border: 2px solid var(--step-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-right: 20px;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}

.step-content {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    border-left: 4px solid var(--step-color);
}

.step-title {
    font-size: 1.1em;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--step-color);
}

.step-description {
    font-size: 1em;
    margin-bottom: 8px;
    opacity: 0.9;
}

.step-metrics {
    font-size: 0.9em;
    opacity: 0.7;
    font-family: 'JetBrains Mono', monospace;
}

/* Cognitive State Grid */
.cognitive-state-viz {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
}

.viz-title {
    font-size: 1.1em;
    font-weight: 600;
    margin-bottom: 15px;
    color: #7b00ff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.viz-title::before {
    content: '📊';
}

.viz-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.state-cell {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 15px;
}

.state-label {
    font-size: 0.9em;
    opacity: 0.8;
    margin-bottom: 8px;
}

.state-meter {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.meter-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 1s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.meter-value {
    position: absolute;
    right: 5px;
    top: -20px;
    font-size: 0.8em;
    font-weight: 600;
}

/* Radar Chart */
.pattern-radar {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
}

.radar-container {
    display: flex;
    justify-content: center;
    padding: 20px;
}

.radar-svg {
    width: 200px;
    height: 200px;
}

.radar-grid {
    fill: none;
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 1;
}

.radar-fill {
    fill: rgba(123, 0, 255, 0.2);
    stroke: rgba(123, 0, 255, 0.5);
    stroke-width: 1.5;
}

.radar-point {
    fill: #7b00ff;
}

.radar-label {
    fill: rgba(255, 255, 255, 0.7);
    font-size: 10px;
    text-anchor: middle;
}

/* Learning Progress */
.learning-progress {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
}

.novelty-timeline {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.novelty-item {
    display: flex;
    align-items: center;
    gap: 15px;
}

.novelty-label {
    width: 80px;
    font-size: 0.9em;
    opacity: 0.8;
}

.novelty-bar {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.novelty-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff6b6b, #ffd43b);
    border-radius: 3px;
    position: relative;
    transition: width 1s ease;
}

.novelty-value {
    position: absolute;
    right: 5px;
    top: -20px;
    font-size: 0.8em;
    font-weight: 600;
}

/* Footer */
.trace-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.confidence-badge {
    background: linear-gradient(135deg, #7b00ff, #ff00ff);
    padding: 8px 16px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge-label {
    font-size: 0.9em;
    opacity: 0.9;
}

.badge-value {
    font-weight: 700;
    font-size: 1.1em;
}

.timestamp {
    font-size: 0.9em;
    opacity: 0.7;
}

/* Raw Data Toggle */
.raw-data-toggle {
    margin-top: 20px;
}

.toggle-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-btn:hover {
    background: rgba(123, 0, 255, 0.3);
    transform: translateY(-2px);
}

.raw-data {
    margin-top: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 15px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8em;
    max-height: 200px;
    overflow-y: auto;
}

.raw-data pre {
    margin: 0;
    color: #a0a0ff;
}

/* Cognitive Trace Panel - CSS-Only Styling */
.cognitive-trace-panel {
    /* ... existing panel styles ... */
}

/* Color System Classes */
.step-color-red { --step-color: #ff6b6b; }
.step-color-blue { --step-color: #4dabf7; }
.step-color-green { --step-color: #51cf66; }
.step-color-yellow { --step-color: #ffd43b; }
.step-color-purple { --step-color: #7b00ff; }

.state-color-red { background: #ff6b6b; }
.state-color-blue { background: #4dabf7; }
.state-color-green { background: #51cf66; }
.state-color-yellow { background: #ffd43b; }

/* Process Steps with Index-based Animation */
.process-step { animation-delay: calc(var(--step-index, 0) * 0.1s); }
.process-step:nth-child(1) { --step-index: 1; }
.process-step:nth-child(2) { --step-index: 2; }
.process-step:nth-child(3) { --step-index: 3; }
.process-step:nth-child(4) { --step-index: 4; }

/* Meter Width Classes */
.meter-width-0 { width: 0%; }
.meter-width-10 { width: 10%; }
.meter-width-20 { width: 20%; }
.meter-width-30 { width: 30%; }
.meter-width-40 { width: 40%; }
.meter-width-50 { width: 50%; }
.meter-width-60 { width: 60%; }
.meter-width-70 { width: 70%; }
.meter-width-80 { width: 80%; }
.meter-width-90 { width: 90%; }
.meter-width-100 { width: 100%; }

/* Novelty Width Classes */
.novelty-width-0 { width: 0%; }
.novelty-width-25 { width: 25%; }
.novelty-width-50 { width: 50%; }
.novelty-width-75 { width: 75%; }
.novelty-width-100 { width: 100%; }

/* Radar Value Classes */
.radar-point-1 { transform: translate(40px, 0); }
.radar-point-2 { transform: translate(0, 40px); }
.radar-point-3 { transform: translate(-40px, 0); }
.radar-point-4 { transform: translate(0, -40px); }

/* Animation Classes */
.animate-in {
    animation: slideIn 0.5s ease forwards;
}

.meter-animate {
    animation: meterFill 1s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.radar-animate {
    animation: radarDraw 1.5s ease-out forwards;
}

@keyframes meterFill {
    from { width: 0%; }
}

@keyframes radarDraw {
    from { stroke-dasharray: 0 1000; }
}

/* Confidence Badge Levels */
.confidence-high { background: linear-gradient(135deg, #51cf66, #2b8a3e); }
.confidence-medium { background: linear-gradient(135deg, #ffd43b, #e67700); }
.confidence-low { background: linear-gradient(135deg, #ff6b6b, #c92a2a); }

/* Toggle States */
.toggle-btn.active {
    background: rgba(123, 0, 255, 0.3);
}

.raw-data {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.raw-data.visible {
    max-height: 200px;
}

/* Radar point positioning */
.radar-point-group {
    transform-origin: center;
}

.radar-point-group.radar-point-1 { transform: rotate(0deg) translateY(-50px); }
.radar-point-group.radar-point-2 { transform: rotate(72deg) translateY(-50px); }
.radar-point-group.radar-point-3 { transform: rotate(144deg) translateY(-50px); }
.radar-point-group.radar-point-4 { transform: rotate(216deg) translateY(-50px); }
.radar-point-group.radar-point-5 { transform: rotate(288deg) translateY(-50px); }

.radar-label {
    text-anchor: middle;
    dominant-baseline: middle;
    transform: translateY(-25px);
}