/* 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%);
    color: #333;
    overflow-x: hidden;
}

/* Responsive container - adapts to iframe vs full screen */
.container {
    width: 100%;
    height: 450px; /* Default iframe height */
    max-width: 100%;
    position: relative;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    overflow: hidden;
}

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

/* Progress bar */
.progress-container {
    background: #f8f9fa;
    padding: 8px 16px;
    border-bottom: 2px solid #e9ecef;
    position: relative;
}

.progress-bar {
    height: 4px;
    background: linear-gradient(90deg, #28a745, #20c997);
    border-radius: 2px;
    transition: width 0.3s ease;
    width: 12.5%; /* 1/8 modules */
}

.progress-text {
    font-size: 12px;
    color: #6c757d;
    margin-top: 4px;
    font-weight: 500;
}

/* Main content area */
.main-content {
    height: calc(100% - 60px);
    overflow-y: auto;
    padding: 16px;
    position: relative;
}

/* Module base styles */
.module {
    display: none;
    height: 100%;
    animation: fadeIn 0.5s ease-in;
}

.module.active {
    display: block;
}

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

/* Scenario card styles */
.scenario-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border: 2px solid #e9ecef;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.emergency-icon {
    font-size: 48px;
    margin-bottom: 16px;
    animation: pulse 2s infinite;
}

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

.scenario-card h2 {
    color: #dc3545;
    margin-bottom: 12px;
    font-size: 20px;
}

.scenario-card p {
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.5;
}

/* Choice buttons */
.choice-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.choice-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    min-height: 44px; /* Touch-friendly */
}

.choice-btn:hover {
    background: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,123,255,0.3);
}

.choice-btn.correct {
    background: #28a745;
}

.choice-btn.incorrect {
    background: #dc3545;
}

/* Anatomy interactive */
.anatomy-interactive {
    text-align: center;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.body-diagram {
    position: relative;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 300"><rect width="200" height="300" fill="%23f8f9fa" stroke="%23dee2e6"/><ellipse cx="100" cy="80" rx="30" ry="40" fill="%23ffc107" opacity="0.3"/><ellipse cx="70" cy="120" rx="25" ry="35" fill="%2317a2b8" opacity="0.3"/><ellipse cx="130" cy="120" rx="25" ry="35" fill="%2317a2b8" opacity="0.3"/></svg>') center/contain no-repeat;
    height: 200px;
    margin: 20px auto;
    position: relative;
}

.organ {
    position: absolute;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    background: rgba(255,255,255,0.9);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.heart {
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
}

.lungs {
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
}

.organ:hover {
    transform: translateX(-50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.organ-label {
    font-size: 12px;
    font-weight: 500;
}

.organ-info {
    background: #f8f9fa;
    padding: 16px;
    border-radius: 8px;
    margin: 16px 0;
    min-height: 60px;
    font-size: 14px;
    line-height: 1.5;
}

/* Chain builder */
.chain-builder {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.chain-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0;
    justify-content: center;
}

.link {
    background: #17a2b8;
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: grab;
    font-size: 12px;
    font-weight: 500;
    user-select: none;
    min-height: 36px;
    display: flex;
    align-items: center;
}

.link:active {
    cursor: grabbing;
}

.link.dragging {
    opacity: 0.5;
}

.drop-zone {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 20px 0;
    flex-wrap: wrap;
}

.chain-slot {
    width: 60px;
    height: 60px;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #6c757d;
    position: relative;
}

.chain-slot.filled {
    border-color: #28a745;
    background: #d4edda;
}

.chain-slot.filled .link {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    padding: 4px 8px;
}

/* Timeline interactive */
.timeline-interactive {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.timeline {
    display: flex;
    justify-content: space-between;
    margin: 20px 0;
    position: relative;
}

.timeline::before {
    content: '';
    position: absolute;
    top: 30px;
    left: 0;
    right: 0;
    height: 2px;
    background: #dee2e6;
    z-index: 1;
}

.timeline-point {
    text-align: center;
    position: relative;
    z-index: 2;
}

.time-marker {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #dc3545;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    margin: 0 auto 8px;
}

.event {
    font-size: 11px;
    font-weight: 500;
    max-width: 80px;
}

.timer-challenge {
    text-align: center;
    margin: 20px 0;
}

.timer-options {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 12px;
    flex-wrap: wrap;
}

.timer-btn {
    background: #ffc107;
    color: #212529;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    min-height: 36px;
}

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

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

.timer-btn.incorrect {
    background: #dc3545;
    color: white;
}

/* Symptom checker */
.symptom-checker {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.patient-scenario {
    text-align: center;
    margin-bottom: 16px;
}

.patient-avatar {
    font-size: 48px;
    margin-bottom: 8px;
}

.symptoms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    margin: 16px 0;
}

.symptom-card {
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.symptom-card:hover {
    border-color: #007bff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,123,255,0.2);
}

.symptom-card.selected-correct {
    border-color: #28a745;
    background: #d4edda;
}

.symptom-card.selected-incorrect {
    border-color: #dc3545;
    background: #f8d7da;
}

.symptom-icon {
    font-size: 24px;
    margin-bottom: 4px;
}

.symptom-card p {
    font-size: 11px;
    line-height: 1.3;
}

.score-display {
    text-align: center;
    font-weight: bold;
    color: #007bff;
    margin: 12px 0;
}

/* Risk sorter */
.risk-sorter {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.sorting-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 16px 0;
    flex: 1;
}

.category-box {
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.category-box h3 {
    margin-bottom: 8px;
    font-size: 14px;
}

.drop-area {
    min-height: 100px;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.drop-area.drag-over {
    border-color: #007bff;
    background: rgba(0,123,255,0.1);
}

.risk-factors {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin: 16px 0;
}

.risk-factor {
    background: #6f42c1;
    color: white;
    padding: 6px 12px;
    border-radius: 16px;
    cursor: grab;
    font-size: 12px;
    user-select: none;
    min-height: 32px;
    display: flex;
    align-items: center;
}

.risk-factor:active {
    cursor: grabbing;
}

.risk-factor.placed {
    cursor: default;
}

/* CPR Simulator */
.cpr-simulator {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.patient-body {
    text-align: center;
    margin: 16px 0;
}

.patient-figure {
    font-size: 64px;
}

.assessment-steps {
    flex: 1;
    overflow-y: auto;
}

.step {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    transition: all 0.3s ease;
}

.step.hidden {
    display: none;
}

.step.active {
    border-color: #007bff;
    background: rgba(0,123,255,0.1);
}

.step h3 {
    font-size: 14px;
    margin-bottom: 4px;
    color: #007bff;
}

.step p {
    font-size: 12px;
    margin-bottom: 8px;
    color: #6c757d;
}

.step-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    min-height: 32px;
}

.step-btn:hover {
    background: #218838;
}

/* CPR Practice */
.cpr-practice {
    height: 100%;
    display: flex;
    flex-direction: column;
    text-align: center;
}

.practice-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.compression-zone {
    margin: 20px 0;
}

.chest-model {
    width: 120px;
    height: 120px;
    background: #ffc107;
    border-radius: 50%;
    margin: 0 auto 12px;
    position: relative;
    cursor: pointer;
    transition: all 0.1s ease;
}

.chest-model:active {
    transform: scale(0.95);
    background: #e0a800;
}

.compression-point {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: #dc3545;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.compression-counter, .ventilation-counter {
    font-size: 18px;
    font-weight: bold;
    color: #007bff;
}

.ventilation-zone {
    margin: 20px 0;
}

.airway-model {
    width: 100px;
    height: 60px;
    background: #17a2b8;
    border-radius: 30px;
    margin: 0 auto 12px;
    cursor: pointer;
    transition: all 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.airway-model:active {
    transform: scale(0.95);
    background: #138496;
}

.mouth-piece {
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
}

.instructions {
    font-size: 14px;
    color: #6c757d;
    margin: 12px 0;
    font-weight: 500;
}

.cycle-progress {
    font-size: 16px;
    font-weight: bold;
    color: #28a745;
    margin: 12px 0;
}

/* Completion screen */
.completion-card {
    text-align: center;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    padding: 20px;
}

.achievement-badge {
    font-size: 64px;
    margin-bottom: 16px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

.completion-card h2 {
    margin-bottom: 12px;
    font-size: 24px;
}

.final-score {
    font-size: 18px;
    margin: 16px 0;
    font-weight: bold;
}

.achievements {
    display: flex;
    gap: 12px;
    margin: 16px 0;
    flex-wrap: wrap;
    justify-content: center;
}

.achievement {
    background: rgba(255,255,255,0.2);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    backdrop-filter: blur(10px);
}

/* Navigation buttons */
.next-btn, .restart-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    margin-top: auto;
    transition: all 0.2s ease;
    min-height: 44px;
}

.next-btn:hover, .restart-btn:hover {
    background: #218838;
    transform: translateY(-2px);
}

.next-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
}

/* Feedback messages */
.feedback {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    padding: 8px 12px;
    margin: 12px 0;
    font-size: 12px;
    text-align: center;
}

.feedback.error {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.feedback.success {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s ease;
    max-width: 200px;
    line-height: 1.4;
}

.tooltip.show {
    opacity: 1;
}

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

/* Mobile optimizations */
@media (max-width: 768px) {
    .main-content {
        padding: 12px;
    }
    
    .symptoms-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
    
    .sorting-area {
        grid-template-columns: 1fr;
    }
    
    .choice-buttons {
        gap: 6px;
    }
    
    .choice-btn {
        padding: 10px 12px;
        font-size: 12px;
    }
    
    .timeline {
        flex-direction: column;
        gap: 12px;
    }
    
    .timeline::before {
        display: none;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .choice-btn, .step-btn, .timer-btn {
        min-height: 48px;
    }
    
    .organ, .symptom-card {
        min-width: 48px;
        min-height: 48px;
    }
    
    .chest-model {
        width: 140px;
        height: 140px;
    }
}