/* Pathfinding Visualizer Styles */
.visualizer-section {
    padding: 30px;
    max-width: 1400px;
    margin: 0 auto;
    margin-bottom: 30px;
}

.controls-panel {
    background: #2a2a2a;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
    margin-bottom: 30px;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    justify-content: space-between;
    border: 1px solid #3a3a3a;
}

.algorithm-selector, .speed-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.algorithm-selector label, .speed-control label {
    font-weight: 600;
    color: #e0e0e0;
}

.algorithm-selector select {
    padding: 8px 12px;
    border: 2px solid #3a3a3a;
    border-radius: 6px;
    font-size: 1rem;
    background: #1f1f1f;
    color: #e0e0e0;
    cursor: pointer;
    transition: border-color 0.3s;
}

.algorithm-selector select:hover, .algorithm-selector select:focus {
    border-color: #10b981;
    outline: none;
}

.algorithm-selector select option {
    background: #1f1f1f;
    color: #e0e0e0;
}

.speed-control input[type="range"] {
    width: 150px;
    cursor: pointer;
    background: #3a3a3a;
}

input[type="range"]::-webkit-slider-thumb {
    background: #10b981;
}

input[type="range"]::-moz-range-thumb {
    background: #10b981;
}

#speedValue {
    font-weight: 600;
    color: #10b981;
    min-width: 30px;
    text-align: center;
}

.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(16, 185, 129, 0.4);
}

.btn-secondary {
    background: #3a3a3a;
    color: #e0e0e0;
}

.btn-secondary:hover {
    background: #4a4a4a;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Grid Container - No scrollbars */
.grid-container {
    background: #2a2a2a;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
    margin-bottom: 20px;
    width: 100%;
    height: 500px;
    overflow: hidden; /* Changed from auto to hidden to prevent scrollbars */
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid #3a3a3a;
}

.pathfinding-grid {
    display: grid;
    gap: 1px;
    background: #3a3a3a;
    padding: 1px;
    width: max-content;
    height: max-content;
}

.grid-node {
    background: #1f1f1f;
    border: 1px solid #3a3a3a;
    cursor: pointer;
    transition: background 0.3s ease;
    box-sizing: border-box;
}

.grid-node:hover:not(.start-node):not(.end-node):not(.wall-node):not(.visited-node):not(.path-node) {
    background: #252525;
}

/* Node States */
.start-node {
    background: #7fffd4 !important;
    animation: pulse 1s infinite;
}

.end-node {
    background: #ef4444 !important;
    animation: pulse 1s infinite;
}

.wall-node {
    background: #d3d3d3 !important;
    animation: wallAnimation 0.3s ease;
}

.visited-node {
    background: #00926b !important;
    animation: visitedAnimation 0.5s ease;
}

.visiting-node {
    background: #00e99f !important;
    animation: visitingAnimation 0.5s ease;
}

.path-node {
    background: #fffb00 !important;
    animation: pathAnimation 0.5s ease;
}

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

@keyframes wallAnimation {
    0% {
        transform: scale(0.3);
        background: #3a3a3a;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        background: #4a4a4a;
    }
}

@keyframes visitedAnimation {
    0% {
        transform: scale(0.3);
        background: #10b981;
        border-radius: 50%;
    }
    50% {
        background: #059669;
    }
    100% {
        transform: scale(1);
        background: #064e3b;
        border-radius: 0;
    }
}

@keyframes visitingAnimation {
    0% {
        transform: scale(0.5);
        background: #10b981;
    }
    100% {
        transform: scale(1);
        background: #059669;
    }
}

@keyframes pathAnimation {
    0% {
        transform: scale(0.3);
        background: #10b981;
    }
    50% {
        transform: scale(1.2);
        background: #34d399;
    }
    100% {
        transform: scale(1);
        background: #34d399;
    }
}

/* Legend */
.legend {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
    padding: 20px;
    background: #2a2a2a;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
    border: 1px solid #3a3a3a;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #b0b0b0;
}

.legend-color {
    width: 20px;
    height: 20px;
    border: 1px solid #3a3a3a;
    border-radius: 3px;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .grid-container {
        height: 450px;
    }
}

@media (max-width: 768px) {
    .visualizer-section {
        padding: 15px;
        margin-bottom: 40px;
    }
    
    .controls-panel {
        flex-direction: column;
        align-items: stretch;
        padding: 15px;
    }
    
    .algorithm-selector, .speed-control {
        justify-content: space-between;
    }
    
    .action-buttons {
        justify-content: center;
    }
    
    .grid-container {
        height: 400px;
        padding: 15px;
    }
    
    .legend {
        gap: 15px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .btn {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
    
    .grid-container {
        height: 350px;
        padding: 10px;
    }
    
    .action-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}