/* ============================================
   DSA Visualizations - Shared Styles
   ============================================ */

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    color: #fff;
    padding: 20px;
}

/* Layout */
.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Main Content - Side by Side Layout */
.main-content {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

h1 {
    text-align: center;
    margin-bottom: 10px;
    color: #00d9ff;
}

.description {
    text-align: center;
    color: #aaa;
    margin-bottom: 30px;
}

.back-link {
    display: inline-block;
    color: #00d9ff;
    text-decoration: none;
    margin-bottom: 20px;
    font-size: 14px;
}

.back-link:hover {
    text-decoration: underline;
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-group label {
    color: #aaa;
}

.input-group input {
    padding: 8px 12px;
    border: 1px solid #444;
    border-radius: 5px;
    background: #2a2a4a;
    color: #fff;
    width: 150px;
}

.input-group input:focus {
    outline: none;
    border-color: #00d9ff;
}

.input-group textarea {
    padding: 8px 12px;
    border: 1px solid #444;
    border-radius: 5px;
    background: #2a2a4a;
    color: #fff;
    font-family: 'Courier New', monospace;
    resize: vertical;
}

.input-group textarea:focus {
    outline: none;
    border-color: #00d9ff;
}

/* Buttons */
button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

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

.btn-primary {
    background: #00d9ff;
    color: #1a1a2e;
}

.btn-primary:hover:not(:disabled) {
    background: #00b8d9;
}

.btn-secondary {
    background: #444;
    color: #fff;
}

.btn-secondary:hover:not(:disabled) {
    background: #555;
}

.btn-success {
    background: #00ff88;
    color: #1a1a2e;
}

.btn-success:hover:not(:disabled) {
    background: #00dd77;
}

.btn-random {
    background: #ff79c6;
    color: #1a1a2e;
}

.btn-random:hover:not(:disabled) {
    background: #ff5cb3;
}

/* Speed Control */
.speed-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.speed-control label {
    color: #aaa;
}

.speed-control input[type="range"] {
    width: 100px;
    accent-color: #00d9ff;
}

/* Visualization Panel */
.visualization {
    background: #1e1e3f;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 20px;
    flex: 3;
    min-width: 0;
}

.section-title {
    color: #00d9ff;
    margin-bottom: 15px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Array Display */
.array-wrapper {
    position: relative;
    padding-top: 40px;
    padding-bottom: 40px;
}

.array-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.array-element {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.array-box {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2a2a4a;
    border: 2px solid #444;
    border-radius: 8px;
    font-size: 20px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.array-box.small {
    width: 45px;
    height: 45px;
    font-size: 16px;
}

.array-index {
    margin-top: 5px;
    color: #666;
    font-size: 12px;
}

/* Array Box States */
.array-box.current {
    border-color: #ffaa00;
    background: #3a3a2a;
    box-shadow: 0 0 15px rgba(255, 170, 0, 0.5);
}

.array-box.found,
.array-box.success {
    border-color: #00ff88;
    background: #1a3a2a;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.5);
}

.array-box.highlight {
    border-color: #00d9ff;
    background: #1a2a3a;
}

.array-box.negative {
    border-color: #ff4444;
    background: #3a1a1a;
}

.array-box.visited {
    border-color: #888;
    background: #333;
}

/* Info Panel */
.info-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.info-box {
    background: #2a2a4a;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.info-box h3 {
    color: #00d9ff;
    margin-bottom: 8px;
    font-size: 14px;
}

.info-value {
    font-size: 24px;
    font-weight: bold;
}

.info-value.small {
    font-size: 18px;
}

/* Status Message */
.status {
    text-align: center;
    padding: 15px;
    background: #2a2a4a;
    border-radius: 8px;
    margin-top: 20px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status.success {
    background: #1a3a2a;
    border: 1px solid #00ff88;
}

.status.error {
    background: #3a1a1a;
    border: 1px solid #ff4444;
}

/* Code Panel */
.code-panel {
    background: #1e1e3f;
    border-radius: 15px;
    padding: 20px;
    flex: 2;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    min-width: 0;
}

.code-line {
    font-family: 'Courier New', monospace;
    padding: 5px 10px;
    border-radius: 3px;
    margin: 2px 0;
    transition: all 0.3s ease;
    font-size: 13px;
    border-left: 3px solid transparent;
}

.code-line.active {
    background: #3a3a2a;
    border-left-color: #ffaa00;
}

.code-keyword {
    color: #ff79c6;
}

.code-function {
    color: #50fa7b;
}

.code-variable {
    color: #f8f8f2;
}

.code-comment {
    color: #6272a4;
}

.code-number {
    color: #bd93f9;
}

.code-string {
    color: #f1fa8c;
}

/* Legend */
.legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid;
}

.legend-color.current {
    border-color: #ffaa00;
    background: #3a3a2a;
}

.legend-color.found,
.legend-color.success {
    border-color: #00ff88;
    background: #1a3a2a;
}

.legend-color.highlight {
    border-color: #00d9ff;
    background: #1a2a3a;
}

.legend-color.negative {
    border-color: #ff4444;
    background: #3a1a1a;
}

/* HashMap Display */
.hashmap-container {
    margin-top: 20px;
}

.hashmap {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 50px;
}

.hashmap-entry {
    background: #2a2a4a;
    padding: 10px 15px;
    border-radius: 5px;
    border: 1px solid #444;
    transition: all 0.3s ease;
}

.hashmap-entry.highlight {
    border-color: #00ff88;
    background: #1a3a2a;
}

.hashmap-entry.new {
    border-color: #ffaa00;
    animation: fadeIn 0.3s ease;
}

.hashmap-key {
    color: #00d9ff;
    font-weight: bold;
}

.hashmap-value {
    color: #aaa;
}

/* Grid Display (for matrix algorithms) */
.grid-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.grid {
    display: inline-grid;
    gap: 2px;
    background: #444;
    padding: 2px;
    border-radius: 8px;
}

.grid-cell {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    transition: all 0.3s ease;
    border-radius: 4px;
}

.grid-cell.water {
    background: #1a2a3a;
    color: #4488ff;
}

.grid-cell.land {
    background: #2a4a2a;
    color: #88ff88;
}

.grid-cell.visited {
    background: #4a3a2a;
    color: #ffaa00;
}

.grid-cell.current {
    box-shadow: 0 0 10px rgba(255, 170, 0, 0.8);
}

/* String Display */
.string-container {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.char-box {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2a2a4a;
    border: 2px solid #444;
    border-radius: 6px;
    font-size: 18px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

.char-box.match {
    border-color: #00ff88;
    background: #1a3a2a;
}

.char-box.mismatch {
    border-color: #ff4444;
    background: #3a1a1a;
}

.char-box.current {
    border-color: #ffaa00;
    background: #3a3a2a;
}

.char-box.in-range {
    border-color: #00d9ff;
    background: #1a2a3a;
}

/* Pointer Display */
.pointer {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.pointer.top {
    top: 0;
}

.pointer.bottom {
    bottom: 0;
}

.pointer-arrow {
    font-size: 16px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes swap {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 5px rgba(0, 217, 255, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(0, 217, 255, 0.8);
    }
}

.swapping {
    animation: swap 0.4s ease;
}

.pulsing {
    animation: pulse 1s ease infinite;
}

/* Queue/Stack Display */
.queue-container {
    margin-top: 20px;
}

.queue {
    display: flex;
    gap: 8px;
    min-height: 50px;
    flex-wrap: wrap;
    justify-content: center;
}

.queue-item {
    background: #2a2a4a;
    padding: 8px 12px;
    border-radius: 5px;
    border: 1px solid #444;
    font-family: 'Courier New', monospace;
    animation: fadeIn 0.3s ease;
}

/* Table Display */
.table-container {
    overflow-x: auto;
    margin: 20px 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Courier New', monospace;
}

.data-table th,
.data-table td {
    padding: 10px;
    text-align: center;
    border: 1px solid #444;
}

.data-table th {
    background: #2a2a4a;
    color: #00d9ff;
}

.data-table td {
    background: #1e1e3f;
}

.data-table td.highlight {
    background: #3a3a2a;
    color: #ffaa00;
}

/* Bar Chart */
.bar-chart {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 8px;
    height: 200px;
    margin: 20px 0;
}

.bar {
    width: 40px;
    background: linear-gradient(180deg, #00d9ff 0%, #0066cc 100%);
    border-radius: 4px 4px 0 0;
    transition: all 0.3s ease;
    position: relative;
}

.bar.current {
    background: linear-gradient(180deg, #ffaa00 0%, #cc6600 100%);
}

.bar.min {
    background: linear-gradient(180deg, #00ff88 0%, #00aa55 100%);
}

.bar.max {
    background: linear-gradient(180deg, #ff79c6 0%, #cc4499 100%);
}

.bar-label {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: #888;
}

.bar-value {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    font-weight: bold;
}

/* Responsive */
@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
    }

    .visualization {
        flex: none;
    }

    .code-panel {
        flex: none;
        position: static;
        max-height: none;
        overflow-y: visible;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .controls {
        flex-direction: column;
        align-items: center;
    }

    .info-panel {
        grid-template-columns: 1fr 1fr;
    }

    .array-box {
        width: 50px;
        height: 50px;
        font-size: 16px;
    }

    .char-box {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }

    .grid-cell {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }
}
