/* ===== 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, #e3f2fd 0%, #fff9c4 100%);
    overflow-x: hidden;
}

/* ===== MAIN CONTAINER - Responsive height ===== */
#main-container {
    width: 100%;
    /* Default to 90vh for standalone, will be overridden by iframe detection in JS */
    height: 90vh;
    display: flex;
    flex-direction: column;
    background: white;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* When in iframe, use fixed height */
body.in-iframe #main-container {
    height: 450px;
}

/* ===== MODE SELECTOR BUTTONS ===== */
#mode-selector {
    display: flex;
    gap: 0;
    padding: 8px;
    background: #f5f5f5;
    border-bottom: 2px solid #ddd;
    flex-shrink: 0;
}

.mode-btn {
    flex: 1;
    padding: 10px 12px;
    border: none;
    background: white;
    color: #555;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 8px 8px 0 0;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mode-btn:hover {
    background: #e3f2fd;
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.mode-btn.active {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    box-shadow: 0 3px 6px rgba(76, 175, 80, 0.3);
}

/* ===== CONTENT AREA ===== */
#content-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}

.mode-content {
    display: none;
    height: 100%;
    padding: 12px;
}

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

/* ===== TWO COLUMN LAYOUT ===== */
.two-column-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    height: 100%;
}

/* ===== DIAGRAM CONTAINER ===== */
.diagram-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fafafa;
    border-radius: 12px;
    padding: 15px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
    position: relative;
}

#flower-diagram, #guided-diagram {
    max-width: 100%;
    max-height: 90%;
    cursor: pointer;
}

.flower-image {
    width: 100%;
    height: auto;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

/* Flower parts - interactive states */
.flower-part {
    cursor: pointer;
    transition: all 0.3s ease;
}

.flower-part:hover {
    filter: brightness(1.2) drop-shadow(0 0 8px rgba(255, 215, 0, 0.8));
    transform: scale(1.05);
}

.flower-part.highlighted {
    filter: brightness(1.3) drop-shadow(0 0 12px rgba(76, 175, 80, 0.9));
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.part-label {
    font-size: 14px;
    font-weight: bold;
    fill: #2d5016;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.instruction-hint {
    margin-top: 10px;
    font-size: 13px;
    color: #666;
    font-style: italic;
}

/* ===== PART SELECTOR ===== */
.part-selector {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #ddd;
}

.part-selector h3 {
    color: #2d5016;
    font-size: 16px;
    margin-bottom: 12px;
    text-align: center;
}

.button-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.part-btn {
    padding: 10px 12px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

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

.back-btn {
    margin-top: 15px;
    padding: 10px 20px;
    background: #f5f5f5;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: #e8e8e8;
    border-color: #4CAF50;
}

/* ===== FLOWER WRAPPER AND LABELS ===== */
.flower-image {
    width: 100%;
    height: auto;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    display: block;
}

/* ===== INFO PANEL ===== */
.info-panel {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

#info-display {
    flex: 1;
}

.welcome-message {
    text-align: center;
}

.welcome-message h2 {
    color: #4CAF50;
    margin-bottom: 15px;
    font-size: 22px;
}

.welcome-message p {
    color: #555;
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 20px;
}

/* Legend for male/female parts */
.legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid #333;
}

.legend-color.male {
    background: #FFD700;
}

.legend-color.female {
    background: #FFB6C1;
}

/* Part information card */
.part-info {
    animation: slideIn 0.4s ease;
}

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

.part-info h2 {
    font-size: 24px;
    margin-bottom: 10px;
    color: #2d5016;
    display: flex;
    align-items: center;
    gap: 10px;
}

.part-type {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: bold;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.part-type.male {
    background: #FFD700;
    color: #333;
    box-shadow: 0 2px 6px rgba(255, 215, 0, 0.4);
}

.part-type.female {
    background: #FFB6C1;
    color: #333;
    box-shadow: 0 2px 6px rgba(255, 182, 193, 0.4);
}

.part-info p {
    font-size: 15px;
    line-height: 1.7;
    color: #444;
    margin-bottom: 12px;
    padding: 10px;
    background: #f9f9f9;
    border-left: 4px solid #4CAF50;
    border-radius: 4px;
}

.part-info ul {
    margin-left: 20px;
    margin-top: 10px;
}

.part-info li {
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
}

/* ===== GUIDED MODE ===== */
.guided-part {
    opacity: 0.3;
    transition: opacity 0.5s ease, filter 0.5s ease;
}

.guided-part.active {
    opacity: 1;
    filter: drop-shadow(0 0 10px rgba(76, 175, 80, 0.7));
}

.guided-text {
    flex: 1;
    font-size: 16px;
    line-height: 1.8;
    color: #333;
}

.guided-text h3 {
    color: #4CAF50;
    margin-bottom: 12px;
    font-size: 20px;
}

.guided-text p {
    margin-bottom: 12px;
}

.guided-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 2px solid #eee;
}

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

/* ===== QUIZ MODE ===== */
.quiz-container {
    max-width: 700px;
    margin: 0 auto;
    padding: 20px;
}

.question-header {
    background: #4CAF50;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: bold;
    text-align: center;
}

.question-text {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
    line-height: 1.6;
}

#answer-area {
    margin-bottom: 20px;
}

/* Multiple choice buttons */
.choice-btn {
    display: block;
    width: 100%;
    padding: 14px 20px;
    margin-bottom: 12px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 8px;
    font-size: 15px;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
}

.choice-btn:hover {
    background: #e3f2fd;
    border-color: #4CAF50;
    transform: translateX(5px);
}

.choice-btn.correct {
    background: #c8e6c9;
    border-color: #4CAF50;
    font-weight: bold;
}

.choice-btn.incorrect {
    background: #ffcdd2;
    border-color: #f44336;
}

.choice-btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

/* Fill in the blank input */
.blank-input {
    padding: 10px 15px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 6px;
    width: 100%;
    max-width: 300px;
    transition: border-color 0.3s ease;
}

.blank-input:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.submit-answer {
    margin-top: 15px;
    padding: 12px 30px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.submit-answer:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Feedback messages */
#feedback-area {
    margin-top: 15px;
    padding: 15px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    display: none;
}

#feedback-area.correct {
    background: #c8e6c9;
    color: #2e7d32;
    border-left: 4px solid #4CAF50;
    display: block;
}

#feedback-area.incorrect {
    background: #ffcdd2;
    color: #c62828;
    border-left: 4px solid #f44336;
    display: block;
}

/* Results area */
#results-area {
    text-align: center;
    padding: 30px;
}

#results-area h2 {
    color: #4CAF50;
    font-size: 28px;
    margin-bottom: 20px;
}

#score-display {
    font-size: 20px;
    margin-bottom: 25px;
    color: #333;
    line-height: 1.8;
}

/* Navigation buttons */
.nav-btn {
    padding: 12px 24px;
    border: none;
    background: #4CAF50;
    color: white;
    font-size: 15px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

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

/* ===== TOOLTIP ===== */
.tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    max-width: 250px;
    text-align: center;
}

.tooltip.visible {
    opacity: 1;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .two-column-layout {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .mode-btn {
        font-size: 12px;
        padding: 8px 6px;
    }
    
    .diagram-container {
        max-height: 250px;
    }
    
    .info-panel {
        padding: 15px;
    }
}

/* ===== ACCESSIBILITY ===== */
.nav-btn:focus,
.mode-btn:focus,
.choice-btn:focus,
.submit-answer:focus {
    outline: 3px solid #4CAF50;
    outline-offset: 2px;
}

/* Ensure touch targets are at least 44x44px */
@media (pointer: coarse) {
    .mode-btn,
    .nav-btn,
    .choice-btn,
    .submit-answer {
        min-height: 44px;
    }
}