/* ============================================================
   REGEX → MINIMIZED DFA SIMULATOR — STYLES
   Premium light theme
   ============================================================ */

/* ---------- CSS VARIABLES ---------- */
:root {
    --bg-deep: #f4f5f9;
    --bg-base: #ffffff;
    --bg-surface: #f0f1f6;
    --bg-elevated: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.75);
    --bg-glass-hover: rgba(0, 0, 0, 0.04);
    --border-subtle: rgba(0, 0, 0, 0.08);
    --border-medium: rgba(0, 0, 0, 0.13);
    --border-bright: rgba(0, 0, 0, 0.2);

    --text-primary: #1a1c2e;
    --text-secondary: #4a4d6a;
    --text-muted: #8b8fa8;
    --text-code: #6d28d9;

    --accent-purple: #6d5ce7;
    --accent-purple-glow: rgba(109, 92, 231, 0.18);
    --accent-cyan: #0891b2;
    --accent-cyan-glow: rgba(8, 145, 178, 0.12);
    --accent-green: #059669;
    --accent-green-glow: rgba(5, 150, 105, 0.12);
    --accent-gold: #d97706;
    --accent-gold-glow: rgba(217, 119, 6, 0.12);
    --accent-blue: #2563eb;
    --accent-blue-glow: rgba(37, 99, 235, 0.12);
    --accent-red: #dc2626;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 14px rgba(0,0,0,0.07);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
    --shadow-glow-purple: 0 0 20px var(--accent-purple-glow);
    --shadow-glow-cyan: 0 0 20px var(--accent-cyan-glow);
    --shadow-glow-green: 0 0 20px var(--accent-green-glow);
    --shadow-glow-gold: 0 0 20px var(--accent-gold-glow);
    --shadow-glow-blue: 0 0 20px var(--accent-blue-glow);

    --transition-fast: 150ms ease;
    --transition-med: 250ms ease;
    --transition-slow: 400ms ease;
}

/* ---------- RESET & BASE ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font-sans);
    background: var(--bg-deep);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    background-image:
        radial-gradient(ellipse 80% 50% at 50% 0%, rgba(109,92,231,0.05) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 80% 100%, rgba(8,145,178,0.03) 0%, transparent 50%);
}
code {
    font-family: var(--font-mono);
    background: rgba(109,92,231,0.1);
    color: var(--text-code);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}
::selection { background: var(--accent-purple); color: #fff; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c4c7d4; border-radius: 3px; }

/* ---------- HEADER ---------- */
#app-header {
    text-align: center;
    padding: 48px 24px 32px;
    position: relative;
}
.header-icon {
    font-size: 42px;
    margin-bottom: 12px;
    animation: spin-slow 12s linear infinite;
}
@keyframes spin-slow { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.gradient-text {
    background: linear-gradient(135deg, #6d5ce7, #0891b2, #059669);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradient-shift 6s ease infinite;
    font-size: clamp(1.6rem, 4vw, 2.6rem);
    font-weight: 800;
    letter-spacing: -0.5px;
}
@keyframes gradient-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}
.header-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 300;
    margin-top: 4px;
}
.header-desc {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ---------- INPUT SECTION ---------- */
#input-section {
    max-width: 800px;
    margin: 0 auto 32px;
    padding: 0 20px;
}
.input-container {
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 28px 32px;
    box-shadow: var(--shadow-md);
}
.input-wrapper label {
    display: block;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 4px;
    color: var(--text-primary);
}
.input-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 14px;
}
.input-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
#regex-input {
    flex: 1;
    min-width: 200px;
    padding: 12px 18px;
    font-family: var(--font-mono);
    font-size: 1.05rem;
    background: var(--bg-surface);
    border: 1.5px solid var(--border-medium);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-med), box-shadow var(--transition-med);
}
#regex-input:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px var(--accent-purple-glow);
}
#regex-input::placeholder { color: var(--text-muted); }

/* ---------- BUTTONS ---------- */
.btn-primary, .btn-secondary, .btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 11px 22px;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-med);
    white-space: nowrap;
}
.btn-primary {
    background: linear-gradient(135deg, #6d5ce7, #5a4bd4);
    color: #fff;
    box-shadow: var(--shadow-sm), 0 0 16px var(--accent-purple-glow);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md), 0 0 24px var(--accent-purple-glow);
}
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-secondary);
    border: 1px solid var(--border-medium);
}
.btn-secondary:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
    border-color: var(--border-bright);
}
.btn-danger {
    background: rgba(220,38,38,0.08);
    color: var(--accent-red);
    border: 1px solid rgba(220,38,38,0.2);
}
.btn-danger:hover { background: rgba(220,38,38,0.14); }
.btn-icon { font-size: 1rem; }
.icon-btn {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.1rem;
    transition: all var(--transition-fast);
}
.icon-btn:hover { background: var(--bg-glass-hover); color: var(--text-primary); }

/* Zoom toggle */
.zoom-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-med);
    user-select: none;
}
.zoom-toggle-btn:hover {
    background: var(--bg-glass-hover);
    color: var(--text-secondary);
    border-color: var(--border-medium);
}
.zoom-toggle-btn.active {
    background: rgba(109, 92, 231, 0.1);
    border-color: var(--accent-purple);
    color: var(--accent-purple);
    box-shadow: 0 0 10px var(--accent-purple-glow);
}

/* ---------- DROPDOWN ---------- */
.dropdown-wrapper { position: relative; }
.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 220px;
    background: var(--bg-base);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    padding: 6px;
}
.dropdown-menu.open { display: block; animation: fadeIn 0.15s ease; }
.dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 14px;
    text-align: left;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.dropdown-item:hover { background: var(--bg-surface); color: var(--text-primary); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- ERROR / INFO ---------- */
.error-msg {
    margin-top: 10px;
    padding: 10px 14px;
    font-size: 0.85rem;
    color: var(--accent-red);
    background: rgba(220,38,38,0.06);
    border: 1px solid rgba(220,38,38,0.15);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
}

/* ---------- STEP NAVIGATOR ---------- */
#step-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0 20px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.step-tab {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 22px;
    background: var(--bg-base);
    border: 1.5px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.88rem;
    font-weight: 500;
    transition: all var(--transition-med);
    position: relative;
}
.step-tab:hover { background: var(--bg-surface); color: var(--text-secondary); border-color: var(--border-medium); }
.step-tab.active {
    color: var(--text-primary);
    border-color: var(--accent-purple);
    background: rgba(109,92,231,0.06);
    box-shadow: var(--shadow-glow-purple);
}
.step-tab[data-step="nfa"].active { border-color: var(--accent-cyan); background: rgba(8,145,178,0.06); box-shadow: var(--shadow-glow-cyan); }
.step-tab[data-step="dfa"].active { border-color: var(--accent-green); background: rgba(5,150,105,0.06); box-shadow: var(--shadow-glow-green); }
.step-tab[data-step="min-dfa"].active { border-color: var(--accent-blue); background: rgba(37,99,235,0.06); box-shadow: var(--shadow-glow-blue); }
.step-number {
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px;
    background: var(--bg-surface);
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.8rem;
}
.step-tab.active .step-number { background: var(--accent-purple); color: #fff; }
.step-tab[data-step="nfa"].active .step-number { background: var(--accent-cyan); color: #fff; }
.step-tab[data-step="dfa"].active .step-number { background: var(--accent-green); color: #fff; }
.step-tab[data-step="min-dfa"].active .step-number { background: var(--accent-blue); color: #fff; }

.step-connector {
    display: flex;
    align-items: center;
    width: 36px;
    position: relative;
}
.connector-line {
    width: 100%;
    height: 1px;
    background: var(--border-medium);
}
.connector-arrow {
    position: absolute;
    right: 2px;
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 700;
}

/* ---------- VISUALIZATION AREA ---------- */
#viz-area {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
    padding: 0 20px;
    margin-bottom: 28px;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}
#viz-panel {
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
}
.panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border-subtle);
}
.panel-header h2 {
    font-size: 1.05rem;
    font-weight: 600;
    flex: 1;
}
.panel-badges { display: flex; gap: 8px; }
.badge {
    padding: 4px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 20px;
    background: var(--bg-surface);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}
.panel-actions { display: flex; gap: 6px; }

#graph-container {
    width: 100%;
    height: 560px;
    position: relative;
    background: #fafbfd;
}
#graph-legend {
    display: flex;
    gap: 20px;
    padding: 10px 22px;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.78rem;
    color: var(--text-muted);
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot {
    width: 12px; height: 12px;
    border-radius: 50%;
    border: 2px solid var(--text-muted);
}
.legend-dot.start { background: var(--accent-green); border-color: var(--accent-green); }
.legend-dot.accept { border-width: 3px; border-color: var(--accent-blue); background: transparent; }
.legend-line {
    width: 20px; height: 0;
    border-top: 2px dashed var(--text-muted);
}

/* ---------- INFO PANEL ---------- */
#info-panel {
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    max-height: 650px;
}
.info-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-subtle);
}
.info-tab {
    flex: 1;
    padding: 13px 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-bottom: 2px solid transparent;
}
.info-tab:hover { color: var(--text-secondary); background: var(--bg-surface); }
.info-tab.active { color: var(--accent-purple); border-bottom-color: var(--accent-purple); }
#info-content {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
}
.info-pane { display: none; }
.info-pane.active { display: block; animation: fadeIn 0.2s ease; }

/* Transition Table */
.trans-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 0.78rem;
}
.trans-table th {
    padding: 8px 10px;
    text-align: left;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-medium);
    position: sticky;
    top: 0;
    background: var(--bg-base);
    z-index: 5;
}
.trans-table td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}
.trans-table tr:hover td { background: var(--bg-surface); }
.state-start { color: var(--accent-green); font-weight: 700; }
.state-accept { color: var(--accent-blue); font-weight: 700; }
.state-both { color: var(--accent-purple); font-weight: 700; }
.state-label-cell { white-space: nowrap; }

/* Algorithm Description */
.algo-section { margin-bottom: 20px; }
.algo-section h4 {
    font-size: 0.88rem;
    color: var(--accent-purple);
    margin-bottom: 8px;
    font-weight: 700;
}
.algo-section p, .algo-section li {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.7;
}
.algo-section ul { padding-left: 18px; }
.algo-section li { margin-bottom: 4px; }
.algo-section code {
    font-size: 0.78rem;
}

/* ---------- STRING TESTER ---------- */
#string-tester {
    max-width: 1400px;
    margin: 0 auto 28px;
    padding: 0 20px;
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 24px 28px;
    margin-left: auto;
    margin-right: auto;
    max-width: calc(1400px - 40px);
    box-shadow: var(--shadow-md);
}
#string-tester h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 4px;
}
.tester-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 14px;
}
.tester-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
#test-string {
    flex: 1;
    min-width: 200px;
    padding: 10px 16px;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    background: var(--bg-surface);
    border: 1.5px solid var(--border-medium);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-med), box-shadow var(--transition-med);
}
#test-string:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px var(--accent-cyan-glow);
}

/* Test Result */
#test-result {
    margin-top: 14px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 600;
    animation: fadeIn 0.3s ease;
}
#test-result.accepted {
    background: rgba(5,150,105,0.08);
    border: 1px solid rgba(5,150,105,0.2);
    color: var(--accent-green);
}
#test-result.rejected {
    background: rgba(220,38,38,0.06);
    border: 1px solid rgba(220,38,38,0.15);
    color: var(--accent-red);
}

/* Trace Display */
#trace-display {
    margin-top: 14px;
    padding: 14px 18px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 2;
    animation: fadeIn 0.3s ease;
}
.trace-step {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-right: 4px;
}
.trace-state {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--bg-base);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    font-weight: 600;
}
.trace-state.active {
    background: var(--accent-purple);
    border-color: var(--accent-purple);
    color: #fff;
    animation: pulse-glow 0.6s ease;
}
.trace-state.accept-state { border-color: var(--accent-blue); }
.trace-symbol {
    color: var(--accent-cyan);
    font-weight: 700;
    margin: 0 2px;
}
.trace-arrow { color: var(--text-muted); margin: 0 4px; }
@keyframes pulse-glow {
    0% { box-shadow: 0 0 0 0 var(--accent-purple-glow); }
    70% { box-shadow: 0 0 0 8px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}

/* ---------- STATS SECTION ---------- */
#stats-section {
    max-width: calc(1400px - 40px);
    margin: 0 auto 40px;
    padding: 24px 28px;
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    margin-left: 20px;
    margin-right: 20px;
}
@media (min-width: 800px) {
    #stats-section { margin-left: auto; margin-right: auto; }
}
#stats-section h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 18px;
}
.stats-grid {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}
.stat-card {
    text-align: center;
    padding: 18px 24px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    min-width: 110px;
    transition: all var(--transition-med);
}
.stat-card:hover { border-color: var(--border-medium); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.stat-card.highlight {
    border-color: var(--accent-purple);
    background: rgba(109,92,231,0.05);
    box-shadow: var(--shadow-glow-purple);
}
.stat-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    font-family: var(--font-mono);
}
.stat-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.stat-arrow {
    font-size: 1.4rem;
    color: var(--text-muted);
    font-weight: 300;
}

/* ---------- FOOTER ---------- */
#app-footer {
    text-align: center;
    padding: 28px 20px;
    color: var(--text-muted);
    font-size: 0.78rem;
    border-top: 1px solid var(--border-subtle);
}

/* ---------- UTILITIES ---------- */
.hidden { display: none !important; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 900px) {
    #viz-area {
        grid-template-columns: 1fr;
    }
    #info-panel { max-height: 400px; }
    #graph-container { height: 450px; }
    .step-tab { padding: 10px 14px; font-size: 0.8rem; }
    .step-connector { width: 20px; }
    .stats-grid { gap: 10px; }
    .stat-card { min-width: 85px; padding: 14px 16px; }
    .stat-value { font-size: 1.4rem; }
    .stat-arrow { font-size: 1rem; }
}
@media (max-width: 600px) {
    #step-nav { gap: 4px; }
    .step-tab { padding: 8px 10px; }
    .step-label { display: none; }
    .step-connector { width: 14px; }
    #graph-container { height: 360px; }
    .input-row { flex-direction: column; }
    .tester-row { flex-direction: column; }
}
