/* 2D Convolution Visualization Tutorial - CSS */
/* Max width: 800px, Font: Courier New */

.conv2d-container {
    max-width: 800px;
    margin: 0 auto;
    font-family: 'Courier New', monospace;
    padding: 20px;
    background: #000;
    color: #fff;
}

.conv2d-header {
    text-align: center;
    margin-bottom: 20px;
}

.conv2d-header h2 {
    color: #4CAF50;
    margin: 0 0 10px 0;
    font-size: 18px;
}

.controls-panel {
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.controls-panel h3 {
    color: #4CAF50;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 14px;
    text-align: center;
}

.control-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    gap: 15px;
    flex-wrap: wrap;
}

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

.delay-group {
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.delay-group label {
    margin: 0;
    white-space: nowrap;
}

.delay-group .slider {
    flex: 1;
    margin: 0;
}

.kernel-select-group {
    flex: 0.9; /* Reduce width by 10% */
}

.control-group label {
    font-size: 12px;
    color: #fff;
    font-weight: bold;
}

.control-group select {
    padding: 6px;
    border: 1px solid #555;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    background: #2a2a2a;
    color: #fff;
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #333;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #2196F3;
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #2196F3;
    cursor: pointer;
    border: none;
}

#delayValue {
    color: #4CAF50;
    font-weight: bold;
    font-size: 12px;
    text-align: center;
    min-width: 40px;
}

.btn {
    padding: 8px 16px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    font-weight: bold;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.btn-icon-top {
    flex-direction: column;
    gap: 2px;
}

.btn-icon {
    font-size: 14px;
    line-height: 1;
}

.btn-text {
    font-size: 12px;
    line-height: 1;
}

.btn:hover {
    background: #1976D2;
}

.btn:active {
    background: #1565C0;
}

.btn.pause {
    background: #FF9800;
}

.btn.pause:hover {
    background: #F57C00;
}

.btn:disabled {
    background: #444;
    color: #888;
    cursor: not-allowed;
}

/* Visualization Area */
.visualization-area {
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.grid-panel {
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.panel-title {
    text-align: center;
    color: #4CAF50;
    font-size: 13px;
    font-weight: bold;
    margin-bottom: 10px;
    border-bottom: 1px solid #444;
    padding-bottom: 5px;
    width: 100%;
}

.grid-container {
    position: relative;
    background: #000;
    border-radius: 4px;
    padding: 10px;
}

.grid {
    display: grid;
    gap: 2px;
    background: #333;
    padding: 2px;
}

/* Override for kernel grid - it has its own styling */
.grid-kernel {
    gap: 1px;
    background: #555;
    border: 1px solid #555;
    padding: 1px;
}

.grid-32x32 {
    grid-template-columns: repeat(32, 8px);
}

.grid-3x3 {
    grid-template-columns: repeat(3, 40px);
}

.grid-7x7 {
    grid-template-columns: repeat(7, 25px);
}

.grid-30x30 {
    grid-template-columns: repeat(30, 8px);
}

.grid-cell {
    width: 8px;
    height: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: bold;
    border-radius: 1px;
    transition: all 0.2s;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

/* Kernel Grid specific styling */
.grid-kernel {
    display: grid;
    /* Use a small gap to show the background color as a border grid */
    gap: 1px; 
    background: #555; /* The color of the lines between cells */
    border: 1px solid #555; /* Outer border */
    padding: 1px; /* Padding for the outer border */
}

.grid-kernel .grid-cell {
    /* Flexbox for perfect centering */
    display: flex;
    align-items: center;
    justify-content: center;
    
    /* Typography */
    font-size: 12px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    line-height: 1; /* Prevents vertical offset */
    
    /* Visuals */
    background: #b71c1c; /* Default red background */
    color: #fff;
    /* Remove individual border (we use gap for the grid lines now) */
    border: none; 
    
    /* Ensure square shape is filled */
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

.grid-32x32 .grid-cell,
.grid-30x30 .grid-cell {
    width: 8px;
    height: 8px;
    font-size: 0; /* Hide text for image-like display */
}

/* Input Grid - Blue shades */
.grid-input .grid-cell {
    background: #0d47a1;
    border: 1px solid #1976d2;
}

.grid-input .grid-cell.highlight {
    background: rgba(255, 235, 59, 0.3);
    border: 2px solid #FFD54F;
    box-shadow: 0 0 10px rgba(255, 235, 59, 0.5);
    z-index: 10;
}

/* Kernel Grid - Red/Orange shades */
.grid-kernel .grid-cell {
    background: #b71c1c;
    border: 1px solid #d32f2f;
}

/* Output Grid - Green shades */
.grid-output .grid-cell {
    background: #1b5e20;
    border: 1px solid #388e3c;
}

.grid-output .grid-cell.active {
    background: #4caf50;
    border: 2px solid #66bb6a;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
    animation: pulse 0.3s ease-out;
}

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

/* Math Panel */
.math-panel {
    margin-top: 20px;
    padding: 15px;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.6;
    min-height: 80px;
}

.math-panel h3 {
    color: #4CAF50;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 14px;
}

.math-content {
    color: #fff;
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
    background: #000;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #444;
}

.math-formula {
    color: #FF6B9D;
    font-style: italic;
    margin: 5px 0;
    text-align: center;
}

/* Responsive */
@media (max-width: 800px) {
    .visualization-area {
        flex-direction: column;
        align-items: center;
    }
    
    .control-row {
        flex-direction: column;
    }
    
    .control-group {
        width: 100%;
    }
}

