/* Global styles and reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Comic Sans MS', 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    overflow-x: hidden;
}

/* Main container - responsive height */
.container {
    width: 100%;
    height: 450px;
    background: white;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    padding: 10px;
}

/* If opened in new tab, use 90vh */
@media (min-height: 600px) {
    body:not(.iframe-mode) .container {
        height: 90vh;
    }
}

/* Header tooltip - saves vertical space */
.header-tooltip {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border: 3px solid #667eea;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
    z-index: 1000;
    display: none;
    max-width: 90%;
    text-align: center;
}

.header-tooltip.show {
    display: block;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    font-weight: bold;
}

.close-btn:hover {
    color: #ff4444;
}

.info-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 24px;
    cursor: pointer;
    background: #667eea;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 100;
}

.info-icon:hover {
    background: #5568d3;
    transform: scale(1.1);
}

/* Simulation area - two bread samples side by side */
.simulation-area {
    display: flex;
    justify-content: space-around;
    gap: 15px;
    margin-top: 10px;
    flex-wrap: wrap;
}

/* Individual bread section */
.bread-section {
    flex: 1;
    min-width: 280px;
    max-width: 400px;
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.bread-section h3 {
    text-align: center;
    color: #8b4513;
    margin-bottom: 5px;
    font-size: 18px;
}

/* Bread display area */
.bread-display {
    position: relative;
    width: 60%;
    height: 80px;
    background: #f5f5dc;
    border-radius: 50%;
    margin: 0 auto 10px;
    overflow: hidden;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.1);
}

.bread-base {
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, #f4e4c1 0%, #d4a574 100%);
    border-radius: 50%;
    position: relative;
}

/* Mould layer container */
.mould-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    pointer-events: none;
}

.mould-patch {
    position: absolute;
    border-radius: 50%;
    opacity: 0;
    transition: all 0.5s ease;
    filter: blur(1px);
    pointer-events: none;
    z-index: 5;
}

/* Toasted bread effect */
.bread-base.toasted {
    background: radial-gradient(circle, #c19a6b 0%, #8b6914 100%);
}

/* Mould Score Readout */
.mould-score {
    text-align: center;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
    padding: 4px 8px;
    margin-bottom: 8px;
    font-size: 14px;
    color: #2c3e50;
    border: 1px solid #dcdde1;
}
.mould-score strong {
    color: #e74c3c;
}

/* Control groups */
.controls {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.control-group label {
    font-weight: bold;
    color: #5d4037;
    font-size: 14px;
}

.control-select {
    padding: 6px;
    font-size: 14px;
    border: 2px solid #8b4513;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 32px; /* Touch-friendly */
}

.control-select:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.control-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* Button container at bottom */
.button-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 5px 0;
    flex-wrap: wrap;
}

.action-btn {
    padding: 10px 20px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    min-height: 40px;
    min-width: 160px;
    white-space: nowrap;
}

.run-btn {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.run-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(17, 153, 142, 0.4);
}

.run-btn:active {
    transform: translateY(0);
}

.reset-btn {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
}

.reset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 107, 107, 0.4);
}

.reset-btn:active {
    transform: translateY(0);
}

/* Bottom panels side-by-side */
.bottom-panels {
    display: flex;
    justify-content: center;
    gap: 15px;
    max-width: 900px;
    margin: 0 auto;
    align-items: flex-start;
}

.bottom-panels > div {
    flex: 1;
    margin: 5px 0;
}

/* Results area */
.results-area {
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    border: 2px solid #fdcb6e;
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.5s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-content h3 {
    color: #d63031;
    margin-bottom: 5px;
    font-size: 16px;
    text-align: center;
}

.result-content p {
    font-size: 14px;
    color: #2d3436;
    text-align: left;
}

/* Recording controls */
.recording-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 15px 0;
    flex-wrap: wrap;
    align-items: center;
}

.record-btn {
    padding: 10px 20px;
    font-size: 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: #e74c3c;
    color: white;
    font-weight: bold;
    transition: all 0.3s ease;
    min-height: 44px;
    white-space: nowrap;
}

.record-btn:hover {
    background: #c0392b;
    transform: translateY(-2px);
}

.recording-status {
    color: #e74c3c;
    font-weight: bold;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Analytics panel */
.analytics-panel {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 10px;
    margin: 20px auto;
    max-width: 800px;
    overflow: hidden;
}

.analytics-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    user-select: none;
}

.analytics-header:hover {
    background: linear-gradient(135deg, #5568d3 0%, #6a3f8f 100%);
}

.toggle-icon {
    transition: transform 0.3s ease;
}

.toggle-icon.rotated {
    transform: rotate(-180deg);
}

.analytics-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.analytics-content.expanded {
    max-height: 300px;
}

.analytics-controls {
    padding: 10px;
    background: #e9ecef;
    border-bottom: 1px solid #dee2e6;
}

.clear-btn {
    padding: 8px 16px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    min-height: 36px;
}

.clear-btn:hover {
    background: #5a6268;
}

.analytics-log {
    padding: 10px;
    max-height: 200px;
    overflow-y: auto;
    font-size: 13px;
}

.log-entry {
    padding: 8px;
    margin-bottom: 5px;
    background: white;
    border-left: 3px solid #667eea;
    border-radius: 4px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.timestamp {
    color: #6c757d;
    font-weight: bold;
    min-width: 50px;
}

.action {
    flex: 1;
    color: #495057;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .simulation-area {
        flex-direction: column;
    }
    
    .bread-section {
        max-width: 100%;
    }
    
    .button-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .action-btn {
        width: 100%;
    }
    
    .recording-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .record-btn {
        width: 100%;
    }
}

/* Touch-friendly enhancements */
@media (hover: none) and (pointer: coarse) {
    .control-select,
    .action-btn,
    .record-btn,
    .clear-btn {
        min-height: 48px;
    }
    
    .info-icon {
        width: 44px;
        height: 44px;
    }
}

/* Scrollbar styling */
.analytics-log::-webkit-scrollbar,
.container::-webkit-scrollbar {
    width: 8px;
}

.analytics-log::-webkit-scrollbar-track,
.container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.analytics-log::-webkit-scrollbar-thumb,
.container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.analytics-log::-webkit-scrollbar-thumb:hover,
.container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Time display */
.time-display {
    text-align: center;
    padding: 6px 12px;
    background: #e8f4f8;
    border: 2px solid #3498db;
    border-radius: 8px;
    font-size: 16px;
    color: #2980b9;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    animation: fadeIn 0.5s;
    white-space: nowrap;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Hypothesis section */
.hypothesis-section {
    background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
    border-radius: 10px;
    padding: 8px;
    margin: 5px auto;
    max-width: 800px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.hypothesis-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.hypothesis-controls strong {
    color: #4a235a;
    font-size: 16px;
}

.hypothesis-controls label {
    font-size: 16px;
    font-weight: bold;
    color: #2c3e50;
}

.warning-text {
    color: #c0392b;
    font-weight: bold;
    margin-top: 10px;
}

/* Science Journal */
.journal-area {
    background: #fff9e6;
    border: 2px dashed #f39c12;
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.journal-area h3 {
    color: #d35400;
    text-align: center;
    margin-bottom: 5px;
    font-size: 16px;
}

.journal-item {
    padding: 6px;
    margin-bottom: 3px;
    background: white;
    border: 1px solid #e67e22;
    border-radius: 4px;
    font-size: 13px;
    font-weight: bold;
    color: #34495e;
    display: flex;
    align-items: center;
    gap: 5px;
}

.journal-item.completed {
    background: #eafaf1;
    border-color: #2ecc71;
    color: #27ae60;
}