/* NFA Stream Visualization Styles */

:root {
    --bg-dark: #1a1a2e;
    --bg-medium: #16213e;
    --bg-light: #0f3460;
    --accent: #e94560;
    --text: #eee;
    --text-dim: #888;
    --state-inactive: #2a2a4e;
    --state-active: #f97316;  /* Orange for current state */
    --state-done: #3b82f6;  /* Blue for visited states */
    --transition-line: #666;
}

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

body {
    font-family: 'SF Mono', 'Fira Code', monospace;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-medium);
    border-bottom: 1px solid var(--bg-light);
}

header h1 {
    font-size: 1.2rem;
    font-weight: 500;
    letter-spacing: 0.05em;
}

#session-picker {
    display: flex;
    gap: 0.5rem;
}

#session-select {
    padding: 0.5rem 1rem;
    background: var(--bg-dark);
    border: 1px solid var(--bg-light);
    color: var(--text);
    border-radius: 4px;
    min-width: 250px;
}

#nfa-tabs {
    display: flex;
    gap: 0.25rem;
}

#nfa-tabs .tab {
    padding: 0.5rem 1rem;
    background: var(--bg-dark);
    border: 1px solid var(--bg-light);
    color: var(--text-dim);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

#nfa-tabs .tab:hover {
    background: var(--bg-light);
    color: var(--text);
}

#nfa-tabs .tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--text);
}

#nfa-tabs .tab.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

button {
    padding: 0.5rem 1rem;
    background: var(--bg-light);
    border: 1px solid var(--accent);
    color: var(--text);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

button:hover {
    background: var(--accent);
}

#live-btn.active {
    background: #22c55e;
    border-color: #22c55e;
    animation: pulse 1.5s infinite;
}

#speed-select {
    padding: 0.5rem;
    background: var(--bg-dark);
    border: 1px solid var(--bg-light);
    color: var(--text);
    border-radius: 4px;
    cursor: pointer;
}

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

/* Main content - NFA | Thinking | Output */
main {
    flex: 1;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    grid-template-rows: 1fr auto;
    gap: 0.75rem;
    padding: 0.75rem;
    overflow: hidden;
}

/* NFA Visualization */
#nfa-wrapper {
    grid-row: 1;
    grid-column: 1;
    overflow: hidden;
    position: relative;
    min-height: 400px;
    display: flex;
}

/* NFA Panel - fill wrapper */
#nfa-container {
    flex: 1;
    min-width: 0;
    min-height: 0;
}

.nfa-panel {
    background: var(--bg-medium);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.nfa-panel.selected {
    border-color: var(--accent);
}

.nfa-panel:hover {
    border-color: var(--bg-light);
}

.nfa-label {
    position: absolute;
    top: 8px;
    left: 12px;
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    z-index: 10;
}

#nfa-svg {
    width: 100%;
    height: 100%;
}

/* State nodes */
.state-node {
    cursor: pointer;
}

.state-node circle {
    fill: var(--state-inactive);
    stroke: var(--transition-line);
    stroke-width: 2;
    transition: fill 0.3s ease-out, stroke 0.3s ease-out, stroke-width 0.2s ease-out, filter 0.3s ease-out, transform 0.15s ease-out;
}

.state-node:hover circle {
    transform: scale(1.05);
}

.state-node.active circle {
    fill: var(--state-active);
    stroke: #fb923c;  /* Lighter orange for stroke */
    stroke-width: 3;
}

.state-node.done circle {
    fill: var(--state-done);
    stroke: #60a5fa;  /* Lighter blue stroke */
}

.state-node.running circle {
    fill: var(--state-inactive);  /* Not filled */
    stroke: var(--state-active);
    stroke-width: 4;
    filter: drop-shadow(0 0 8px var(--state-active)) drop-shadow(0 0 16px var(--state-active));
    animation: pulse-glow 1.5s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { filter: drop-shadow(0 0 8px var(--state-active)) drop-shadow(0 0 16px var(--state-active)); }
    50% { filter: drop-shadow(0 0 12px var(--state-active)) drop-shadow(0 0 24px var(--state-active)); }
}

.state-node text {
    fill: var(--text);
    font-size: 12px;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
}

/* Transition lines */
.transition-line {
    stroke: var(--transition-line);
    stroke-width: 2;
    fill: none;
    marker-end: url(#arrowhead);
    transition: stroke 0.2s ease-out, stroke-width 0.2s ease-out;
}

.transition-line.active {
    stroke: var(--accent);
    stroke-width: 3;
}

.transition-line.self-loop,
.transition-line.back-loop {
    stroke-dasharray: 5, 3;
}

.transition-label {
    fill: var(--text);
    font-size: 12px;
    text-anchor: middle;
    font-weight: 500;
}

.transition-counter {
    fill: var(--accent);
    font-size: 14px;
    font-weight: 700;
}

/* Timeline */
#timeline-container {
    grid-row: 2;
    grid-column: 1;
    background: var(--bg-medium);
    border-radius: 8px;
    padding: 1rem;
}

#timeline {
    height: 24px;
    background: var(--bg-dark);
    border-radius: 4px;
    position: relative;
    margin-bottom: 0.5rem;
    cursor: pointer;
}

#timeline-track {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    width: 0%;
    transition: width 0.1s ease-out;
}

#timeline-cursor {
    position: absolute;
    top: -4px;
    width: 4px;
    height: 32px;
    background: var(--text);
    border-radius: 2px;
    left: 0%;
    transform: translateX(-50%);  /* Center cursor on position */
    transition: left 0.1s ease-out;
}

#timeline-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

#time-display {
    margin-left: auto;
    color: var(--text-dim);
}

/* Output panels - Thinking and Output side by side, full height */
.output-panel {
    grid-row: 1 / 3;
    background: var(--bg-medium);
    border-radius: 8px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#thinking-panel {
    grid-column: 2;
}

#output-panel {
    grid-column: 3;
}

.output-panel h3 {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#current-state,
#output-state {
    color: var(--accent);
    text-transform: none;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    font-size: 0.8rem;
    line-height: 1.4;
    white-space: pre-wrap;
    color: var(--text);
    background: var(--bg-dark);
    padding: 0.5rem;
    border-radius: 4px;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

/* State output styling */
.state-output {
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--bg-light);
}

.state-output:last-child {
    border-bottom: none;
}

.state-output .action-type {
    color: var(--accent);
    font-weight: 600;
}

.state-output .target {
    color: var(--text-dim);
}

/* Action error/result display for introspection */
.action-error {
    margin-top: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: rgba(233, 69, 96, 0.1);
    border-left: 2px solid var(--accent);
    color: var(--text);
    font-size: 0.75rem;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Footer */
footer {
    padding: 0.5rem 2rem;
    background: var(--bg-medium);
    border-top: 1px solid var(--bg-light);
}

#stats {
    display: flex;
    gap: 2rem;
    color: var(--text-dim);
    font-size: 0.8rem;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}
