* {
    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: 1600px;
    margin: 0 auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

header p {
    font-size: 1.1em;
    opacity: 0.9;
}

.controls {
    display: flex;
    gap: 20px;
    padding: 20px 30px;
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
    flex-wrap: wrap;
    align-items: center;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-group label {
    font-weight: 600;
    color: #495057;
}

select {
    padding: 8px 12px;
    border: 2px solid #dee2e6;
    border-radius: 5px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

select:hover {
    border-color: #667eea;
}

select:focus {
    outline: none;
    border-color: #667eea;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-left: auto;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

#start-btn {
    background: #28a745;
    color: white;
}

#start-btn:hover:not(:disabled) {
    background: #218838;
}

#pause-btn {
    background: #ffc107;
    color: #212529;
}

#pause-btn:hover:not(:disabled) {
    background: #e0a800;
}

#reset-btn {
    background: #dc3545;
    color: white;
}

#reset-btn:hover:not(:disabled) {
    background: #c82333;
}

#step-btn {
    background: #007bff;
    color: white;
}

#step-btn:hover:not(:disabled) {
    background: #0056b3;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.main-content {
    display: flex;
    height: calc(100vh - 250px);
    min-height: 600px;
}

.visualization-panel {
    flex: 2;
    padding: 20px;
    background: #ffffff;
    overflow: hidden;
}

#graph-svg {
    width: 100%;
    height: 100%;
    border: 2px solid #e9ecef;
    border-radius: 5px;
    background: #fafbfc;
}

.info-panel {
    flex: 1;
    padding: 20px;
    background: #f8f9fa;
    border-left: 2px solid #e9ecef;
    overflow-y: auto;
    min-width: 300px;
    max-width: 400px;
}

.info-panel h3 {
    color: #495057;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #dee2e6;
}

.algorithm-info,
.stats,
.paths-list,
.step-info {
    margin-bottom: 25px;
    padding: 15px;
    background: white;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

#algorithm-description {
    color: #6c757d;
    line-height: 1.6;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    font-weight: 600;
    color: #495057;
}

.stat-item span:last-child {
    color: #667eea;
    font-weight: 600;
}

#paths-content {
    max-height: 300px;
    overflow-y: auto;
}

.path-item {
    padding: 10px;
    margin-bottom: 8px;
    background: #e7f3ff;
    border-left: 4px solid #667eea;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.path-item.from-cache {
    background: #d1f0f5;
    border-left: 4px solid #17a2b8;
}

.path-item .cache-badge {
    display: inline-block;
    background: #17a2b8;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    margin-left: 8px;
    vertical-align: middle;
}

#step-description {
    color: #6c757d;
    line-height: 1.6;
    font-size: 14px;
}

/* SVG node and edge styles */
.node-circle {
    fill: #fff;
    stroke: #495057;
    stroke-width: 2;
    cursor: pointer;
    transition: all 0.3s;
}

.node-circle.visiting {
    fill: #ffc107;
    stroke: #ff9800;
    stroke-width: 3;
}

.node-circle.visited {
    fill: #6c757d;
    stroke: #495057;
}

.node-circle.in-path {
    fill: #28a745;
    stroke: #1e7e34;
    stroke-width: 3;
}

.node-circle.current {
    fill: #dc3545;
    stroke: #bd2130;
    stroke-width: 4;
    animation: pulse 1s infinite;
}

.node-circle.path-found {
    fill: #007bff;
    stroke: #0056b3;
    stroke-width: 3;
}

.node-circle.cache-hit {
    fill: #17a2b8;
    stroke: #138496;
    stroke-width: 3;
    animation: cache-flash 0.5s ease-in-out;
}

.node-circle.cycle {
    fill: #ff6b6b;
    stroke: #ee5a52;
    stroke-width: 4;
    animation: cycle-pulse 1s ease-in-out;
}

.node-circle.skipped {
    fill: #ffa500;
    stroke: #ff8c00;
    stroke-width: 3;
    opacity: 0.7;
}

.node-circle.warning {
    fill: #ffc107;
    stroke: #ff9800;
    stroke-width: 3;
    animation: warning-blink 0.8s ease-in-out infinite;
}

@keyframes warning-blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

@keyframes cache-flash {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

@keyframes cycle-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.15);
        opacity: 0.8;
    }
}

.node-label {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    font-weight: bold;
    fill: #212529;
    text-anchor: middle;
    pointer-events: none;
}

.visit-badge {
    pointer-events: none;
}

.badge-circle {
    fill: #667eea;
    stroke: #fff;
    stroke-width: 2;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.badge-text {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 11px;
    font-weight: bold;
    fill: #fff;
    text-anchor: middle;
    dominant-baseline: middle;
}

.edge-line {
    fill: none;
    stroke: #adb5bd;
    stroke-width: 2;
    marker-end: url(#arrowhead);
}

.edge-line.active {
    stroke: #667eea;
    stroke-width: 3;
    animation: dash 1s linear;
}

.edge-line.in-path {
    stroke: #28a745;
    stroke-width: 3;
}

.edge-line.path-found {
    stroke: #007bff;
    stroke-width: 3;
}

.edge-line.cycle {
    stroke: #ff6b6b;
    stroke-width: 4;
    stroke-dasharray: 5, 5;
    animation: cycle-dash 1s linear infinite;
}

.edge-line.skipped {
    stroke: #ffa500;
    stroke-width: 3;
    stroke-dasharray: 8, 4;
    opacity: 0.7;
}

.edge-line.warning {
    stroke: #ffc107;
    stroke-width: 3;
    stroke-dasharray: 10, 5;
    animation: warning-blink 0.8s ease-in-out infinite;
}

@keyframes cycle-dash {
    from {
        stroke-dashoffset: 10;
    }
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes dash {
    from {
        stroke-dashoffset: 20;
    }
    to {
        stroke-dashoffset: 0;
    }
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}
