* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    padding: 30px;
}

h1 {
    color: #333;
    text-align: center;
    margin-bottom: 10px;
    font-size: 2.5em;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
    font-size: 1.1em;
}

/* ============= TOGGLE SECTION ============= */
.toggle-section {
    text-align: center;
    margin-bottom: 30px;
}

.toggle-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.toggle-btn {
    padding: 12px 30px;
    font-size: 1em;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
}

.toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.toggle-btn.active {
    background: #667eea;
    color: white;
}

/* ============= INPUT SECTION ============= */
.input-section {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 30px;
}

.category-section h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
    font-size: 1em;
}

.input-group input,
.input-group select,
.input-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    font-family: 'Courier New', monospace;
    transition: border-color 0.3s;
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 5px rgba(102, 126, 234, 0.3);
}

.input-group textarea {
    resize: vertical;
    min-height: 120px;
}

.input-group small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 0.9em;
}

.format-guide {
    background: #e3f2fd;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 10px;
    color: #1976d2;
    font-size: 0.95em;
    border-left: 4px solid #1976d2;
}

/* ============= INFO BOX ============= */
.info-box {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border-left: 4px solid #667eea;
}

.info-box h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.3em;
}

.info-box p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 15px;
}

.info-box h4 {
    color: #333;
    margin-top: 15px;
    margin-bottom: 8px;
    font-size: 1em;
}

.graph-type-info,
.why-info {
    background: #f0f7ff;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 12px;
    border-left: 4px solid #2196f3;
}

.complexity-info {
    background: #e8eaf6;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 15px;
    color: #3f51b5;
    font-weight: bold;
    font-size: 0.95em;
}

.formula-box {
    background: #fff3e0;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    border-left: 4px solid #ff9800;
}

.formula-box h4 {
    color: #e65100;
    margin-bottom: 10px;
}

.formula-box pre {
    background: white;
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 0.9em;
    color: #333;
    font-family: 'Courier New', monospace;
    line-height: 1.4;
}

.info-box ul {
    list-style: none;
    padding: 0;
}

.info-box li {
    color: #555;
    padding: 8px 0;
    padding-left: 25px;
    position: relative;
    line-height: 1.5;
}

.info-box li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #4caf50;
    font-weight: bold;
}

/* ============= OPERATION BUTTONS ============= */
.operation-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.operation-btn {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

.operation-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

/* ============= RUN BUTTON ============= */
.run-btn {
    width: 100%;
    padding: 15px;
    font-size: 1.1em;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
    margin-top: 15px;
}

.run-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.run-btn:active {
    transform: translateY(0);
}

/* ============= VISUALIZATION SECTION ============= */
.visualization-section {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-top: 30px;
}

.canvas-area {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
}

.canvas-area h3 {
    color: #333;
    margin-bottom: 15px;
}

#visualizationCanvas {
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    min-height: 400px;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1em;
    color: #999;
}

/* ============= INFO PANEL ============= */
.info-panel {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 900px;
    overflow-y: auto;
}

.step-info,
.step-description,
.step-logic,
.state-info,
.result-panel,
.legend {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.step-info h3,
.step-description h3,
.step-logic h3,
.state-info h3,
.result-panel h3,
.legend h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.step-info p,
.step-description p,
.state-info p,
.result-panel p {
    color: #666;
    line-height: 1.6;
    word-wrap: break-word;
}

.step-logic {
    border-left-color: #ff9800;
}

.step-logic h3 {
    color: #e65100;
}

.step-logic pre {
    background: #fff3e0;
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 0.85em;
    color: #333;
    font-family: 'Courier New', monospace;
    line-height: 1.4;
    margin: 0;
}

#stateDisplay {
    color: #555;
    font-family: 'Courier New', monospace;
    background: #f0f0f0;
    padding: 10px;
    border-radius: 5px;
    line-height: 1.6;
    font-size: 0.9em;
}

/* ============= CONTROLS ============= */
.controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.control-btn {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
    flex: 1;
    min-width: 100px;
}

.control-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

.control-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* ============= LEGEND ============= */
.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.legend-color {
    width: 25px;
    height: 25px;
    border-radius: 4px;
    border: 1px solid #999;
}

.legend-color.active {
    background: #ff9800;
}

.legend-color.visited {
    background: #4caf50;
}

.legend-color.unvisited {
    background: #2196f3;
}

.legend-color.goal {
    background: #f44336;
}

/* ============= RESPONSIVE ============= */
@media (max-width: 768px) {
    .visualization-section {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 1.8em;
    }

    .toggle-buttons {
        flex-direction: column;
    }

    .toggle-btn {
        width: 100%;
    }

    .info-panel {
        max-height: none;
    }
}

/* ============= SVG AND CANVAS STYLES ============= */
svg {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
}

circle {
    cursor: pointer;
}

circle:hover {
    filter: brightness(1.2);
}
