/* ===== 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, #667eea 0%, #764ba2 100%);
    overflow: hidden;
}

/* ===== MAIN CONTAINER ===== */
#mainContainer {
    width: 100%;
    height: 450px; /* Default iframe height */
    display: flex;
    flex-direction: column;
    background: white;
    position: relative;
    overflow: hidden;
}

/* If opened in new tab, use 90vh */
body.fullscreen #mainContainer {
    height: 90vh;
}

/* ===== TOOLTIP STYLES ===== */
.tooltip {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border: 2px solid #667eea;
    border-radius: 12px;
    padding: 20px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    max-height: 80%;
    overflow-y: auto;
}

.tooltip.hidden {
    display: none;
}

.tooltip h3 {
    color: #667eea;
    margin-bottom: 12px;
    font-size: 1.3em;
}

.tooltip p {
    margin-bottom: 10px;
    line-height: 1.6;
    color: #333;
}

.tooltip ul {
    margin-left: 20px;
    margin-bottom: 10px;
}

.tooltip li {
    margin-bottom: 6px;
    line-height: 1.5;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #ff4757;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.close-btn:hover {
    background: #ff3838;
}

/* ===== INTERACTIVE AREA ===== */
#interactiveArea {
    display: flex;
    flex: 1;
    gap: 10px;
    padding: 10px;
    overflow: hidden;
}

/* ===== CONTROL PANEL ===== */
#controlPanel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    padding-right: 5px;
}

.info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    color: white;
    cursor: help;
}

.help-icon {
    font-size: 1.3em;
    cursor: pointer;
    transition: transform 0.3s;
}

.help-icon:hover {
    transform: scale(1.2);
}

.level-badge {
    background: rgba(255, 255, 255, 0.3);
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9em;
}

/* ===== MODIFICATION: MODE SELECTOR STYLES ===== */
.mode-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
}

.mode-btn {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid #667eea;
    border-radius: 8px;
    background: white;
    color: #667eea;
    font-weight: 600;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.3s;
}

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

.mode-btn.active {
    background: #667eea;
    color: white;
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

/* ===== PROBLEM BOX ===== */
.problem-box {
    background: #f8f9fa;
    border-left: 4px solid #667eea;
    padding: 12px;
    border-radius: 6px;
    font-size: 0.95em;
    line-height: 1.5;
}

/* ===== CONTROL GROUPS ===== */
.control-group {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    transition: opacity 0.3s, filter 0.3s;
}

/* MODIFICATION: Locked slider styles for quiz mode */
.control-group.locked {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(50%);
    position: relative;
}

.control-group.locked::after {
    content: '🔒 Locked';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: bold;
}

.control-group label {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    flex-wrap: wrap;
}

.label-text {
    flex: 0 0 auto;
    margin-right: 8px;
}

.value-display {
    background: #667eea;
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: bold;
    min-width: 40px;
    text-align: center;
    margin-right: 4px;
}

.unit {
    color: #666;
    font-size: 0.9em;
}

/* ===== SLIDERS ===== */
.slider {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    margin-bottom: 5px;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.slider-marks {
    display: flex;
    justify-content: space-between;
    font-size: 0.75em;
    color: #999;
}

/* ===== INPUT WRAPPER ===== */
.input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.area-input {
    flex: 1;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1em;
    transition: border-color 0.3s;
    min-height: 44px; /* Touch-friendly */
}

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

/* ===== HINT AND FEEDBACK BOXES ===== */
.hint-box {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 10px;
    border-radius: 6px;
    animation: slideIn 0.3s ease-out;
}

.hint-box.hidden {
    display: none;
}

.hint-header {
    font-weight: bold;
    margin-bottom: 5px;
    color: #856404;
}

.feedback-box {
    padding: 10px;
    border-radius: 6px;
    border-left: 4px solid;
    animation: slideIn 0.3s ease-out;
}

.feedback-box.hidden {
    display: none;
}

.feedback-box.correct {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
}

.feedback-box.incorrect {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

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

/* ===== BUTTONS ===== */
.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.btn {
    flex: 1 1 auto;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    min-height: 44px; /* Touch-friendly */
    white-space: nowrap;
}

.btn-primary {
    background: #28a745;
    color: white;
}

.btn-primary:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-hint {
    background: #ffc107;
    color: #333;
}

.btn-hint:hover {
    background: #e0a800;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-next {
    background: #667eea;
    color: white;
}

.btn-next:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-next.hidden {
    display: none;
}

/* ===== RECORDING CONTROLS ===== */
.recording-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    padding-top: 8px;
    border-top: 1px solid #e0e0e0;
}

.btn-record {
    background: #dc3545;
    color: white;
    flex: 1 1 auto;
}

.btn-record:hover {
    background: #c82333;
}

.btn-download {
    background: #17a2b8;
    color: white;
    flex: 1 1 auto;
}

.btn-download:hover {
    background: #138496;
}

.recording-status {
    font-size: 0.85em;
    color: #dc3545;
    font-weight: bold;
    animation: pulse 1.5s infinite;
}

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

/* ===== VISUAL PANEL ===== */
#visualPanel {
    flex: 1.2;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 10px;
    border: 2px solid #e0e0e0;
}

#triangleCanvas {
    flex: 1;
    border-radius: 6px;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ===== FORMULA BOX ===== */
.formula-box {
    background: white;
    border: 2px solid #667eea;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.formula-title {
    font-weight: bold;
    color: #667eea;
    margin-bottom: 5px;
    font-size: 0.9em;
}

.formula-content {
    font-size: 1.1em;
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
    font-family: 'Courier New', monospace;
}

.formula-calculation {
    font-size: 0.95em;
    color: #666;
    font-family: 'Courier New', monospace;
}

/* ===== ANALYTICS PANEL ===== */
.analytics-panel {
    background: white;
    border-top: 2px solid #667eea;
    transition: max-height 0.3s ease-out;
    overflow: hidden;
}

.analytics-panel.collapsed .analytics-content {
    display: none;
}

.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8f9fa;
    cursor: pointer;
    font-weight: 600;
    color: #333;
}

.toggle-btn {
    background: none;
    border: none;
    font-size: 1.2em;
    cursor: pointer;
    transition: transform 0.3s;
}

.analytics-panel:not(.collapsed) .toggle-btn {
    transform: rotate(180deg);
}

.analytics-content {
    max-height: 200px;
    overflow-y: auto;
}

.analytics-tabs {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
}

.tab-btn {
    flex: 1;
    padding: 8px;
    background: #f8f9fa;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.tab-btn.active {
    background: white;
    border-bottom-color: #667eea;
    color: #667eea;
}

.tab-content {
    display: none;
    padding: 10px;
}

.tab-content.active {
    display: block;
}

.analytics-controls {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.btn-small {
    padding: 4px 10px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.8em;
    cursor: pointer;
    transition: background 0.3s;
}

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

.log-container {
    max-height: 150px;
    overflow-y: auto;
    font-size: 0.85em;
    line-height: 1.6;
}

.log-entry {
    padding: 6px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    gap: 8px;
}

.log-entry:hover {
    background: #f8f9fa;
}

.log-time {
    color: #999;
    font-weight: 600;
    min-width: 50px;
}

.log-action {
    flex: 1;
    color: #333;
}

.log-correct {
    color: #28a745;
    font-weight: bold;
}

.log-incorrect {
    color: #dc3545;
    font-weight: bold;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    #interactiveArea {
        flex-direction: column;
    }
    
    #controlPanel, #visualPanel {
        flex: 1;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}

/* ===== SCROLLBAR STYLING ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}