/* Reset and base styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f8f9fa;
    margin: 0;
    padding: 20px;
    color: #333;
}

#app-container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Header */
header {
    background: white;
    border-radius: 8px;
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
}

header h1 {
    font-size: 28px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 8px;
}

header p {
    font-size: 16px;
    color: #666;
}

/* Control Panel */
#control-panel {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 150px;
}

.control-group label {
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.control-group span {
    color: #0066cc;
    font-weight: 600;
}

.control-group input[type="range"] {
    width: 150px;
    cursor: pointer;
}

.control-group select {
    width: 150px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    font-size: 14px;
    cursor: pointer;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.control-group select:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.1);
}

.button-controls {
    flex-direction: row;
    margin-left: auto;
    min-width: auto;
}

.control-group button {
    padding: 10px 20px;
    background: #0066cc;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    font-size: 20px;
    transition: background 0.2s;
}

.control-group button:hover {
    background: #0052a3;
}

.control-group button:active {
    background: #004080;
}

#play-pause {
    background: #28a745;
}

#play-pause:hover {
    background: #218838;
}

#reset {
    background: #dc3545;
}

#reset:hover {
    background: #c82333;
}

#step {
    background: #ffc107;
    color: #333;
}

#step:hover {
    background: #e0a800;
}

/* Visualization Grid */
#visualization-grid {
    background: white;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.vis-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.vis-row:last-child {
    margin-bottom: 0;
}

.vis-panel {
    text-align: center;
}

.vis-panel h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 12px 0;
    color: #333;
}

.vis-panel canvas {
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    display: block;
    margin: 0 auto;
}

/* Stats Panel */
#stats-panel {
    text-align: left;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 4px;
    font-family: 'Roboto Mono', monospace;
    font-size: 13px;
    line-height: 1.8;
    max-width: 280px;
    margin: 0 auto;
}

#stats-panel p {
    margin: 8px 0;
}

#stats-panel span {
    font-weight: 600;
    color: #0066cc;
}

/* Current Sum Display */
#current-sum {
    margin-top: 12px;
    font-family: 'Roboto Mono', monospace;
    font-size: 14px;
    color: #666;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 4px;
    display: inline-block;
}

#sum-value {
    font-weight: 600;
    color: #0066cc;
}

/* Matrix View */
#matrix-view {
    grid-column: 1 / -1;
    background: #f8f9fa;
    border-radius: 4px;
    padding: 20px;
}

#matrix-view h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 16px 0;
    color: #333;
    text-align: center;
}

#matrix-display {
    font-family: 'Roboto Mono', monospace;
    font-size: 11px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-width: 800px;
    margin: 0 auto;
    justify-content: center;
}

.matrix-cell {
    padding: 8px;
    background: white;
    border: 1px solid #ddd;
    text-align: center;
    min-width: 60px;
    border-radius: 2px;
    transition: all 0.2s;
}

.matrix-cell.highlighted {
    background: #ffeb3b;
    border-color: #f57c00;
    border-width: 2px;
    transform: scale(1.05);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .vis-row {
        grid-template-columns: 1fr;
    }

    #control-panel {
        justify-content: center;
    }
}

/* Canvas overlays for grid lines */
.block-grid-overlay {
    stroke: #dc3545;
    stroke-width: 1;
    fill: none;
}

.current-block-highlight {
    stroke: #ffc107;
    stroke-width: 3;
    fill: rgba(255, 193, 7, 0.1);
}

/* Measurements vs Reconstruction Section */
#measurements-recon-section {
    max-width: 1400px;
    margin: 0 auto;
    padding: 60px 20px;
    background: white;
}

#measurements-recon-section h2 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 10px;
    color: #2d3748;
    font-weight: 600;
}

.comparison-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 40px;
    margin-top: 40px;
}

.comparison-group {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.comparison-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: #0984e3;
    margin-bottom: 20px;
    font-family: 'Roboto Mono', monospace;
}

/* Image Comparison Slider */
.image-comparison-slider {
    position: relative;
    width: 100%;
    max-width: 500px;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.comparison-images {
    position: relative;
    width: 100%;
    margin: 0;
    padding: 0;
    line-height: 0;
}

.comparison-images img {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
}

.img-base {
    position: relative;
    z-index: 1;
}

.img-overlay {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    object-fit: cover;
    clip-path: inset(0 50% 0 0);
}

/* Slider Handle */
.slider-handle {
    position: absolute;
    top: 0;
    left: 50%;
    width: 4px;
    height: 100%;
    background: white;
    cursor: ew-resize;
    z-index: 3;
    transform: translateX(-50%);
}

.slider-line {
    position: absolute;
    width: 100%;
    height: 100%;
    background: white;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
}

.slider-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background: #0984e3;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}

.slider-button:hover {
    transform: translate(-50%, -50%) scale(1.1);
}

.slider-button:active {
    transform: translate(-50%, -50%) scale(0.95);
}

.slider-arrows {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.slider-arrows span {
    color: white;
    font-size: 18px;
    font-weight: bold;
    line-height: 1;
}

/* Comparison Labels */
.comparison-labels {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 500px;
    margin-top: 15px;
    padding: 0 10px;
}

.comparison-labels span {
    font-size: 0.95rem;
    font-weight: 500;
    color: #495057;
}

.label-left {
    text-align: left;
}

.label-right {
    text-align: right;
}

/* Diffusion GIF Container */
.diffusion-gif-container {
    margin-top: 30px;
    width: 100%;
    max-width: 500px;
}

.diffusion-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 15px;
    text-align: center;
}

.diffusion-gif {
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: block;
}

/* Responsive Design for Comparison Section */
@media (max-width: 1024px) {
    .comparison-container {
        grid-template-columns: 1fr;
        gap: 50px;
    }

    #measurements-recon-section {
        padding: 40px 15px;
    }
}

@media (max-width: 768px) {
    #measurements-recon-section h2 {
        font-size: 1.6rem;
    }

    .comparison-title {
        font-size: 1.1rem;
    }

    .image-comparison-slider {
        max-width: 100%;
    }

    .comparison-labels {
        max-width: 100%;
    }

    .diffusion-gif-container {
        max-width: 100%;
    }

    .diffusion-title {
        font-size: 1rem;
    }
}

/* Fourier Space Masking Section */
#fourier-masking-section {
    max-width: 1400px;
    margin: 0 auto;
    padding: 60px 20px;
    background: #f7fafc;
}

#fourier-masking-section h2 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 10px;
    color: #2d3748;
    font-weight: 600;
}

.section-subtitle {
    text-align: center;
    font-size: 1.1rem;
    color: #718096;
    margin-bottom: 40px;
}

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

/* Carousel Container */
.fourier-carousel {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
}

.fourier-slides-container {
    overflow: hidden;
    position: relative;
}

.compression-group {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.fourier-slide {
    display: none;
    opacity: 0;
}

.fourier-slide.active {
    display: block;
    opacity: 1;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.compression-ratio {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 600;
    color: #0984e3;
    margin-bottom: 30px;
    font-family: 'Roboto Mono', monospace;
}

.mask-type-section {
    margin-bottom: 30px;
}

.mask-type-section:last-child {
    margin-bottom: 0;
}

.mask-type-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e2e8f0;
}

.mask-results {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.image-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.fourier-image-panel {
    text-align: center;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    transition: all 0.3s ease;
}

.fourier-image-panel:hover {
    background: #e9ecef;
    transform: scale(1.02);
}

.fourier-image-panel img {
    width: 100%;
    height: auto;
    border-radius: 6px;
    border: 1px solid #ddd;
    background: white;
    display: block;
}

.image-label {
    margin-top: 12px;
    font-size: 0.95rem;
    font-weight: 500;
    color: #495057;
}

/* Carousel Navigation Buttons */
.carousel-nav {
    background: #0984e3;
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    flex-shrink: 0;
}

.carousel-nav:hover {
    background: #0770c4;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.carousel-nav:active {
    transform: scale(0.95);
}

/* Carousel Indicators */
.carousel-indicators {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 30px;
}

.indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #cbd5e0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.indicator:hover {
    background: #a0aec0;
    transform: scale(1.2);
}

.indicator.active {
    background: #0984e3;
    width: 30px;
    border-radius: 6px;
}

/* Responsive Design for Fourier Section */
@media (max-width: 1024px) {
    .image-row,
    .mask-results {
        grid-template-columns: 1fr;
    }

    #fourier-masking-section {
        padding: 40px 15px;
    }

    .compression-group {
        padding: 20px;
    }

    .carousel-controls {
        gap: 15px;
        margin-bottom: 20px;
    }

    .carousel-nav {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }

    .mask-type-section {
        margin-bottom: 25px;
    }
}

@media (max-width: 768px) {
    #fourier-masking-section h2 {
        font-size: 1.6rem;
    }

    .compression-ratio {
        font-size: 1.3rem;
    }

    .section-subtitle {
        font-size: 1rem;
    }

    .carousel-nav {
        width: 35px;
        height: 35px;
        font-size: 1.3rem;
    }

    .mask-type-title {
        font-size: 1rem;
    }
}
