@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --background: #020817;
    --foreground: #f8fafc;
    --card: #020817;
    --card-foreground: #f8fafc;
    --popover: #020817;
    --popover-foreground: #f8fafc;
    --primary: #f8fafc;
    --primary-foreground: #0f172a;
    --secondary: #1e293b;
    --secondary-foreground: #f8fafc;
    --muted: #1e293b;
    --muted-foreground: #94a3b8;
    --accent: #1e293b;
    --accent-foreground: #f8fafc;
    --destructive: #7f1d1d;
    --destructive-foreground: #f8fafc;
    --border: #1e293b;
    --input: #1e293b;
    --ring: #cbd5e1;
    --radius: 0.5rem;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    background-color: var(--background);
    color: var(--foreground);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

.controls {
    width: 320px;
    background-color: var(--card);
    border-right: 1px solid var(--border);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    box-shadow: 4px 0 24px rgba(0,0,0,0.2);
    z-index: 20;
    overflow-y: auto;
}

h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.025em;
    color: var(--foreground);
}

.control-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.section-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-foreground);
}

.button-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-weight: 500;
    height: 2.25rem;
    padding: 0 1rem;
    transition: all 0.2s ease;
    cursor: pointer;
    border: 1px solid var(--border);
    background-color: transparent;
    color: var(--foreground);
}

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

button:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
}

button.active {
    background-color: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
}

button.primary {
    background-color: #16a34a;
    border-color: #16a34a;
    color: white;
    width: 100%;
}
button.primary:hover {
    background-color: #15803d;
}

button.danger {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.2);
}
button.danger:hover {
    background-color: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
}

.slider-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--secondary);
    border-radius: 999px;
    outline: none;
    -webkit-appearance: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--foreground);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--background);
}

#status {
    padding: 0.75rem;
    border-radius: var(--radius);
    background-color: var(--secondary);
    color: var(--secondary-foreground);
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid var(--border);
}

#log-panel {
    flex-grow: 1;
    min-height: 150px;
    background-color: #09090b;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.75rem;
    color: var(--muted-foreground);
    overflow-y: auto;
}

.log-entry {
    margin-bottom: 0.25rem;
    line-height: 1.4;
}
.log-entry::before {
    content: "> ";
    color: #64748b;
}

.legend {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 5px;
    padding: 10px;
    background-color: var(--secondary);
    border-radius: var(--radius);
    font-size: 0.75rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--foreground);
}

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

.dot.start { background-color: #16a34a; }
.dot.end { background-color: #dc2626; }
.dot.visited { background-color: #0284c7; }
.dot.current { background-color: #9333ea; }
.dot.path { background-color: #eab308; }

#graph-canvas {
    flex-grow: 1;
    background-color: #020817;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 20px 20px;
    cursor: crosshair;
}

.modal {
    display: none;
    position: fixed;
    z-index: 50;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    position: relative;
    background-color: var(--card);
    margin: 4vh auto;
    padding: 0;
    border: 1px solid var(--border);
    width: 90%;
    max-width: 900px;
    border-radius: var(--radius);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.close-modal {
    color: var(--muted-foreground);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}
.close-modal:hover {
    color: var(--foreground);
}

#info-text-content {
    padding: 1.5rem;
    overflow-y: auto;
    line-height: 1.6;
    color: var(--secondary-foreground);
}

.info-section { margin-bottom: 2rem; }
.info-section h3 { 
    color: var(--foreground);
    margin-bottom: 1rem;
    font-size: 1.25rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}
.info-section p { margin-bottom: 1rem; color: #cbd5e1; }
.info-section ul { margin-bottom: 1rem; padding-left: 1.5rem; }
.info-section li { margin-bottom: 0.5rem; color: #cbd5e1; }
.info-section strong { color: var(--foreground); }
code {
    background-color: var(--secondary);
    color: #e2e8f0;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-family: monospace;
    font-size: 0.9em;
}
pre {
    background-color: #0f172a;
    padding: 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    border: 1px solid var(--border);
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

input[type="checkbox"] {
    accent-color: var(--primary);
    width: 1rem;
    height: 1rem;
}

.input-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.input-wrapper label {
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--muted-foreground);
}

input[type="number"] {
    background-color: var(--input);
    border: 1px solid var(--border);
    color: var(--foreground);
    padding: 0.4rem;
    border-radius: var(--radius);
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
}
input[type="number"]:focus {
    outline: 2px solid var(--ring);
    border-color: transparent;
}