/* Global styles and responsive container setup */
* {
    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-x: hidden;
}

/* Container adapts to iframe (450px) or full screen (90vh) */
.container {
    width: 100%;
    height: 450px; /* Default for iframe */
    padding: 10px;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Full screen mode detection */
@media (min-height: 500px) {
    .container {
        height: 90vh;
        padding: 20px;
    }
}

/* Tooltip for header information - saves vertical space */
.tooltip {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.tooltip.show {
    opacity: 1;
}

/* Main interactive panel */
.main-panel {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    padding: 15px;
    height: 100%;
    display: flex;
    flex-direction: column;
    cursor: help;
}

/* Problem display at the top */
.problem-display {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    text-align: center;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.fraction-expression {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

/* Fraction styling */
.fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.numerator {
    padding: 2px 8px;
    border-bottom: 2px solid #333;
    margin-bottom: 2px;
}

.denominator {
    padding: 2px 8px;
}

.operator {
    font-size: 28px;
    color: #666;
    margin: 0 5px;
}

.equals {
    margin: 0 8px;
    color: #666;
}

/* Steps container - flexible height */
.steps-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Step navigation */
.step-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 2px solid #eee;
}

.nav-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    min-height: 36px;
    white-space: nowrap;
}

.nav-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

.step-indicator {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

/* Step content area */
.step-content {
    flex: 1;
    position: relative;
    overflow-y: auto;
}

.step {
    display: none;
    animation: fadeIn 0.5s ease-in-out;
}

.step.active {
    display: block;
}

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

.step h3 {
    color: #333;
    margin-bottom: 8px;
    font-size: 16px;
    border-left: 4px solid #667eea;
    padding-left: 10px;
}

.step p {
    color: #666;
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.4;
}

/* Work area for step calculations */
.work-area {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
    margin: 10px 0;
    border-left: 4px solid #667eea;
}

.work-area p {
    margin-bottom: 6px;
}

.result {
    font-weight: bold;
    color: #667eea;
    font-size: 16px;
}

/* Conversion and calculation displays */
.conversion, .addition, .simplification {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
    flex-wrap: wrap;
}

.note {
    font-style: italic;
    color: #888;
    font-size: 12px;
}

/* Highlighting for important parts */
.highlight {
    background: linear-gradient(135deg, #ffeaa7, #fab1a0);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
}

.final-answer {
    background: linear-gradient(135deg, #00b894, #00cec9);
    color: white;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: bold;
}

/* Controls */
.controls {
    margin-top: auto;
    padding-top: 10px;
    text-align: center;
}

.control-btn {
    background: linear-gradient(135deg, #fd79a8, #fdcb6e);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    min-height: 36px;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(253, 121, 168, 0.4);
}

/* Responsive adjustments for smaller screens */
@media (max-width: 480px) {
    .fraction-expression {
        font-size: 20px;
        gap: 10px;
    }
    
    .step-navigation {
        flex-direction: column;
        gap: 8px;
    }
    
    .nav-btn {
        width: 100%;
        max-width: 120px;
    }
    
    .conversion, .addition, .simplification {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
    .nav-btn, .control-btn {
        min-height: 44px;
        padding: 12px 20px;
    }
}