/* 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;
}

/* Container with responsive height */
.container {
    width: 100%;
    height: 100vh;
    max-height: 450px;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    overflow: hidden;
}

/* Check if running in new tab vs iframe */
@media (min-height: 500px) {
    .container {
        height: 90vh;
        max-height: none;
    }
}

/* Progress bar */
.progress-container {
    background: #f8f9fa;
    padding: 8px 16px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 40px;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    margin-right: 12px;
    overflow: hidden;
}

.progress-bar::before {
    content: '';
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #28a745, #20c997);
    border-radius: 3px;
    width: var(--progress, 0%);
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 12px;
    font-weight: 600;
    color: #6c757d;
    white-space: nowrap;
}

/* Content area */
.content-area {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: white;
}

/* Module content styles */
.module {
    animation: fadeIn 0.3s ease-in;
}

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

.module-header {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
    padding: 12px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 8px;
}

.module-icon {
    font-size: 24px;
    margin-right: 12px;
}

.module-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.scenario-box {
    background: #f8f9fa;
    border-left: 4px solid #007bff;
    padding: 16px;
    margin: 16px 0;
    border-radius: 0 8px 8px 0;
}

.scenario-title {
    font-weight: 600;
    color: #007bff;
    margin-bottom: 8px;
}

/* Interactive elements */
.interactive-challenge {
    background: white;
    border: 2px solid #28a745;
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.1);
}

.challenge-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.challenge-icon {
    font-size: 20px;
    margin-right: 8px;
    color: #28a745;
}

.challenge-title {
    font-weight: 600;
    color: #28a745;
}

/* Question styles */
.question-container {
    margin: 16px 0;
}

.question {
    font-weight: 600;
    margin-bottom: 12px;
    color: #495057;
}

.options {
    display: grid;
    gap: 8px;
}

.option {
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.option:hover {
    border-color: #007bff;
    background: #f8f9ff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,123,255,0.1);
}

.option.selected {
    border-color: #007bff;
    background: #007bff;
    color: white;
}

.option.correct {
    border-color: #28a745;
    background: #28a745;
    color: white;
}

.option.incorrect {
    border-color: #dc3545;
    background: #dc3545;
    color: white;
}

/* Feedback styles */
.feedback {
    margin-top: 12px;
    padding: 12px;
    border-radius: 6px;
    font-size: 14px;
    animation: slideDown 0.3s ease;
}

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

.feedback.correct {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.feedback.incorrect {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* Practice activity styles */
.practice-activity {
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
}

.practice-steps {
    list-style: none;
    counter-reset: step-counter;
}

.practice-steps li {
    counter-increment: step-counter;
    margin: 8px 0;
    padding-left: 30px;
    position: relative;
}

.practice-steps li::before {
    content: counter(step-counter);
    position: absolute;
    left: 0;
    top: 0;
    background: #ffc107;
    color: #212529;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

/* Navigation controls */
.nav-controls {
    padding: 12px 16px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.nav-btn {
    padding: 8px 16px;
    border: 2px solid #6c757d;
    background: white;
    color: #6c757d;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    min-height: 36px;
    flex: 1;
    max-width: 120px;
}

.nav-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.nav-btn.primary {
    background: #007bff;
    border-color: #007bff;
    color: white;
}

.nav-btn.primary:hover:not(:disabled) {
    background: #0056b3;
    border-color: #0056b3;
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.tooltip.show {
    opacity: 1;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #000;
}

/* Score tracker */
.score-tracker {
    position: absolute;
    top: 8px;
    right: 16px;
    background: rgba(255,255,255,0.9);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    color: #495057;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        border-radius: 0;
    }
    
    .content-area {
        padding: 12px;
    }
    
    .module-title {
        font-size: 16px;
    }
    
    .option {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .nav-controls {
        padding: 8px 12px;
    }
    
    .nav-btn {
        padding: 6px 12px;
        font-size: 13px;
    }
}

/* Touch-friendly improvements */
@media (hover: none) {
    .option:hover {
        transform: none;
        box-shadow: none;
    }
    
    .nav-btn:hover:not(:disabled) {
        transform: none;
        box-shadow: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .option {
        border-width: 3px;
    }
    
    .interactive-challenge {
        border-width: 3px;
    }
}