/* Global 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, #f5f7fa 0%, #c3cfe2 100%);
    overflow-x: hidden;
}

/* Main container - adapts to iframe or standalone */
#mainContainer {
    width: 100%;
    height: 450px; /* Default iframe height */
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: white;
    position: relative;
    overflow-y: auto;
}

/* Adjust height for standalone view (not in iframe) */
@media (min-height: 500px) {
    body:not(.iframe-mode) #mainContainer {
        height: 90vh;
        padding: 20px;
        gap: 15px;
    }
}

/* Info icon for header tooltip */
#infoIcon {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: #4CAF50;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    z-index: 100;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#infoIcon:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* Header tooltip */
#headerTooltip {
    position: absolute;
    top: 40px;
    right: 8px;
    background: #333;
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    max-width: 300px;
    font-size: 13px;
    line-height: 1.4;
    z-index: 101;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

#headerTooltip::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 10px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #333;
}

/* Problem section */
#problemSection {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 12px 15px;
    border-radius: 8px;
    color: white;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}

.problem-text {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
}

.inequality-display {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: bold;
    background: rgba(255,255,255,0.2);
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}

.note-text {
    font-size: 12px;
    font-style: italic;
    opacity: 0.9;
    margin-top: 4px;
}

/* Working area */
#workingArea {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

/* Solution steps */
#solutionSteps {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.step-container {
    background: #f8f9fa;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.step-container.active {
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    border: 2px solid #667eea;
}

/* Step buttons - optimized for touch and mouse */
.step-button {
    width: 100%;
    padding: 10px 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    text-align: left;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    min-height: 40px; /* Touch-friendly target size */
}

.step-button:hover {
    background: linear-gradient(135deg, #5568d3 0%, #6a3f8f 100%);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.step-button:active {
    transform: scale(0.98);
}

.step-button::before {
    content: '▶';
    margin-right: 10px;
    transition: transform 0.3s ease;
    display: inline-block;
}

.step-button.expanded::before {
    transform: rotate(90deg);
}

/* Step content */
.step-content {
    padding: 12px 15px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.step-content.hidden {
    display: none;
}

.inequality-line,
.working-line {
    font-family: 'Courier New', monospace;
    font-size: 15px;
    padding: 6px 10px;
    margin: 4px 0;
    background: #f0f4f8;
    border-left: 3px solid #667eea;
    border-radius: 4px;
}

.working-line.highlight {
    background: #fff3cd;
    border-left-color: #ffc107;
    font-weight: bold;
}

.and-text {
    color: #e91e63;
    font-weight: bold;
    margin: 0 8px;
}

.note {
    font-size: 12px;
    color: #666;
    font-style: italic;
    margin-left: 10px;
}

.final-answer {
    font-size: 18px;
    font-weight: bold;
    color: #4CAF50;
    text-align: center;
    padding: 12px;
    background: #e8f5e9;
    border-radius: 6px;
    margin-top: 8px;
    border: 2px solid #4CAF50;
}

/* Control buttons */
#controlButtons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.control-btn {
    flex: 1;
    padding: 10px 15px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    min-height: 40px; /* Touch-friendly */
}

.control-btn:hover {
    background: #45a049;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    transform: translateY(-2px);
}

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

#resetBtn {
    background: #ff5722;
}

#resetBtn:hover {
    background: #e64a19;
}

/* Number line section */
#numberLineSection {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.section-label {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

#numberLineContainer {
    background: white;
    border-radius: 6px;
    padding: 10px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

#solutionDisplay {
    margin-top: 8px;
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    color: #4CAF50;
    padding: 8px;
    background: #e8f5e9;
    border-radius: 6px;
}

#solutionDisplay.hidden {
    display: none;
}

/* Central tooltip for detailed information */
.central-tooltip {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 20px 25px;
    border-radius: 12px;
    max-width: 400px;
    z-index: 1000;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    animation: fadeIn 0.3s ease;
}

.central-tooltip.hidden {
    display: none;
}

.tooltip-content {
    font-size: 14px;
    line-height: 1.6;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -45%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

/* Hidden utility class */
.hidden {
    display: none;
}

/* Number line SVG styling */
.number-line-axis {
    stroke: #333;
    stroke-width: 2;
}

.number-line-tick {
    stroke: #333;
    stroke-width: 1.5;
}

.number-line-label {
    font-family: 'Segoe UI', sans-serif;
    font-size: 13px;
    fill: #333;
    font-weight: 600;
}

.number-line-solution {
    stroke: #4CAF50;
    stroke-width: 4;
}

.number-line-point {
    fill: white;
    stroke: #4CAF50;
    stroke-width: 2.5;
}

.number-line-arrow {
    fill: #4CAF50;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .problem-text {
        font-size: 14px;
    }
    
    .inequality-display {
        font-size: 16px;
    }
    
    .step-button {
        font-size: 13px;
    }
    
    .working-line,
    .inequality-line {
        font-size: 13px;
    }
}

/* Scrollbar styling */
#mainContainer::-webkit-scrollbar,
#workingArea::-webkit-scrollbar {
    width: 6px;
}

#mainContainer::-webkit-scrollbar-track,
#workingArea::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

#mainContainer::-webkit-scrollbar-thumb,
#workingArea::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

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