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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #e8f5e8 0%, #f0f8f0 100%);
    color: #333;
    line-height: 1.4;
    overflow-x: hidden;
}

/* Main container - responsive height for iframe vs full screen */
.main-container {
    width: 100%;
    height: 450px; /* Default iframe height */
    padding: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr 200px; /* Added third column for comparison sidebar */
    grid-template-rows: auto auto auto;
    gap: 8px;
    overflow-y: auto;
}

/* Full screen detection */
@media (min-height: 600px) {
    .main-container {
        height: 90vh;
        padding: 15px;
        gap: 12px;
        grid-template-columns: 1fr 1fr 220px; /* Slightly wider sidebar for larger screens */
    }
}

/* Panel styling */
.panel {
    background: white;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 1px solid #e0e0e0;
    transition: all 0.3s ease;
}

.panel:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(-1px);
}

.panel h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #2c5530;
    border-bottom: 2px solid #4CAF50;
    padding-bottom: 4px;
}

/* Food selection grid */
.food-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 6px;
}

.food-btn {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 8px 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 70px;
    font-size: 11px;
}

.food-btn:hover {
    background: #e8f5e8;
    border-color: #4CAF50;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.2);
}

.food-btn.selected {
    background: #4CAF50;
    color: white;
    border-color: #45a049;
}

.food-icon {
    font-size: 20px;
    margin-bottom: 4px;
}

.food-name {
    font-weight: 500;
    text-align: center;
}

/* Preparation options */
.preparation-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.prep-btn {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 10px;
    min-height: 60px;
}

.prep-btn:hover {
    background: #fff3cd;
    border-color: #ffc107;
    transform: translateY(-1px);
}

.prep-btn.selected {
    background: #ffc107;
    color: #212529;
    border-color: #ffb300;
}

.prep-icon {
    font-size: 16px;
    margin-bottom: 2px;
}

.surface-area {
    font-size: 9px;
    color: #666;
    text-align: center;
}

/* Enzyme grid */
.enzyme-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}

.enzyme-btn {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    min-height: 45px;
}

.enzyme-btn:hover {
    background: #e3f2fd;
    border-color: #2196F3;
    transform: translateY(-1px);
}

.enzyme-btn.selected {
    background: #2196F3;
    color: white;
    border-color: #1976D2;
}

.enzyme-btn.correct {
    background: #4CAF50;
    color: white;
    border-color: #45a049;
}

.enzyme-btn.incorrect {
    background: #f44336;
    color: white;
    border-color: #d32f2f;
}

.enzyme-icon {
    font-size: 16px;
}

.enzyme-name {
    font-weight: 600;
}

.enzyme-target {
    font-size: 9px;
    opacity: 0.8;
}

/* Simulation panel spans two columns */
.simulation-panel {
    grid-column: 1 / 3;
}

.simulation-container {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.food-display, .enzyme-display {
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.food-visual, .enzyme-visual {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

/* Enhanced food visual representation with surface area visualization */
.food-pieces-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 2px;
    margin-top: 5px;
    min-height: 30px;
}

.food-piece {
    background: #4CAF50;
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Different sizes for different preparation methods */
.food-piece.whole {
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.food-piece.sliced {
    width: 15px;
    height: 8px;
    border-radius: 2px;
}

.food-piece.chopped {
    width: 6px;
    height: 6px;
    border-radius: 1px;
}

.food-piece.mashed {
    width: 3px;
    height: 3px;
    border-radius: 50%;
}

.placeholder-text {
    color: #6c757d;
    font-size: 12px;
    font-style: italic;
}

.digestion-progress {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #dee2e6;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 10px;
}

.digestion-rate {
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    color: #495057;
}

.start-btn {
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.start-btn:hover:not(:disabled) {
    background: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.3);
}

.start-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Results panel spans two columns */
.results-panel {
    grid-column: 1 / 3;
}

.results-content {
    font-size: 12px;
    line-height: 1.5;
}

.learning-point ul {
    margin-left: 15px;
    margin-top: 8px;
}

.learning-point li {
    margin-bottom: 4px;
}

/* New Comparison Sidebar Styles */
.comparison-sidebar {
    grid-column: 3;
    grid-row: 1 / -1; /* Spans all rows */
    background: #f8f9fa;
    border: 2px solid #e9ecef;
}

.comparison-sidebar h3 {
    font-size: 12px;
    text-align: center;
    margin-bottom: 10px;
    color: #2c5530;
}

.comparison-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.comparison-item {
    background: white;
    border-radius: 6px;
    padding: 8px;
    border: 1px solid #dee2e6;
    transition: all 0.3s ease;
}

.comparison-item:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

.comparison-item.active {
    border-color: #4CAF50;
    background: #e8f5e8;
}

.comparison-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.prep-method {
    font-size: 10px;
    font-weight: 600;
    color: #2c5530;
}

.surface-multiplier {
    font-size: 9px;
    background: #4CAF50;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
}

.visual-representation {
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.food-pieces {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 1px;
}

/* Visual representations for different preparation methods */
.whole-pieces::before {
    content: '';
    width: 16px;
    height: 16px;
    background: #4CAF50;
    border-radius: 50%;
    display: block;
}

.sliced-pieces {
    gap: 2px;
}

.sliced-pieces::before,
.sliced-pieces::after {
    content: '';
    width: 12px;
    height: 6px;
    background: #4CAF50;
    border-radius: 2px;
    display: block;
}

.chopped-pieces {
    gap: 1px;
}

.chopped-pieces::before,
.chopped-pieces::after {
    content: '';
    width: 4px;
    height: 4px;
    background: #4CAF50;
    border-radius: 1px;
    display: block;
}

.chopped-pieces {
    position: relative;
}

.chopped-pieces::before {
    content: '';
    position: absolute;
    width: 4px;
    height: 4px;
    background: #4CAF50;
    border-radius: 1px;
    left: 0;
}

.chopped-pieces::after {
    content: '';
    position: absolute;
    width: 4px;
    height: 4px;
    background: #4CAF50;
    border-radius: 1px;
    left: 6px;
}

.chopped-pieces {
    width: 20px;
    height: 10px;
    position: relative;
}

.chopped-pieces::before,
.chopped-pieces::after {
    position: absolute;
    top: 0;
}

/* Create multiple small pieces for chopped visualization */
.chopped-pieces {
    background: repeating-linear-gradient(
        45deg,
        #4CAF50,
        #4CAF50 2px,
        transparent 2px,
        transparent 4px
    );
    width: 20px;
    height: 10px;
    border-radius: 2px;
}

.mashed-pieces {
    background: radial-gradient(circle, #4CAF50 1px, transparent 1px);
    background-size: 3px 3px;
    width: 20px;
    height: 10px;
    border-radius: 2px;
    opacity: 0.8;
}

.digestion-time {
    font-size: 8px;
    color: #666;
    text-align: center;
    font-style: italic;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    max-width: 200px;
    opacity: 0;
    transition: opacity 0.3s ease;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.tooltip.show {
    opacity: 1;
}

/* Animations */
@keyframes digest {
    0% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(0.8) rotate(180deg); }
    100% { transform: scale(0.6) rotate(360deg); opacity: 0.7; }
}

.digesting {
    animation: digest 2s ease-in-out infinite;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .main-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto auto auto auto; /* Added extra row for sidebar */
        padding: 8px;
        gap: 6px;
    }
    
    .simulation-panel {
        grid-column: 1;
    }
    
    .results-panel {
        grid-column: 1;
    }
    
    .comparison-sidebar {
        grid-column: 1;
        grid-row: auto;
    }
    
    .simulation-container {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .food-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .preparation-options {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .panel h3 {
        font-size: 13px;
    }
    
    .food-btn, .prep-btn, .enzyme-btn {
        font-size: 10px;
        min-height: 50px;
    }
}

/* Touch-friendly sizing for mobile */
@media (pointer: coarse) {
    .food-btn, .prep-btn, .enzyme-btn, .start-btn {
        min-height: 48px;
        padding: 10px;
    }
    
    .tooltip {
        font-size: 14px;
        padding: 10px 15px;
    }
}