/* Base styles and responsive design */
* {
    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: auto;
    padding: 10px 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Worksheet Header Styles */
.worksheet-header {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 20px;
    margin: 0 20px 20px 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.worksheet-header h1 {
    color: #2c3e50;
    font-size: 24px;
    margin-bottom: 5px;
}

.worksheet-header h2 {
    color: #34495e;
    font-size: 18px;
    margin-bottom: 5px;
}

.worksheet-header h3 {
    color: #3498db;
    font-size: 16px;
    margin-bottom: 20px;
}

.student-info {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.info-field {
    display: flex;
    align-items: center;
    gap: 10px;
}

.info-field label {
    font-weight: 600;
    color: #2c3e50;
    min-width: 50px;
}

.info-field input {
    padding: 8px 12px;
    border: 2px solid #bdc3c7;
    border-radius: 4px;
    font-size: 14px;
    min-width: 150px;
}

.info-field input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.3);
}

/* Container adapts to iframe vs full window */
.container {
    width: calc(100% - 20px);
    margin: 0 10px;
    height: 55vh;
    min-height: 450px;
    max-height: 550px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 0 0 auto;
}

/* Activities Container */
.activities-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    margin: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    background: #34495e;
    border-radius: 8px 8px 0 0;
}

.tab-btn {
    flex: 1;
    padding: 15px 20px;
    border: none;
    background: #34495e;
    color: #ecf0f1;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    background: #2c3e50;
    color: white;
}

.tab-btn.active {
    background: #3498db;
    color: white;
    border-bottom-color: #e74c3c;
}

/* Tab Content */
.tab-content {
    display: none;
    padding: 15px;
    animation: fadeIn 0.3s ease-in;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

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

.tab-content h4 {
    color: #34495e;
    font-size: 14px;
    margin: 10px 0 8px 0;
}

/* Activity Row Layout */
.activity-row {
    display: flex;
    gap: 15px;
    margin: 10px 0;
    flex: 1;
    min-height: 0;
}

.activity-row > div {
    flex: 1;
    min-width: 250px;
    display: flex;
    flex-direction: column;
}

/* Graph Container */
.graph-container {
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.graph-container h4 {
    margin-bottom: 8px;
}

#infectionGraphCanvas {
    border: 2px solid #bdc3c7;
    border-radius: 8px;
    background: white;
    flex: 1;
    max-height: 280px;
    min-height: 200px;
}

/* Outcomes Explanation */
.outcomes-explanation {
    margin-bottom: 10px;
}

.outcomes-explanation ul {
    list-style-type: disc;
    margin-left: 20px;
    color: #34495e;
    margin-bottom: 0;
}

.outcomes-explanation li {
    margin-bottom: 3px;
    line-height: 1.3;
    font-size: 13px;
}

/* Data Tables */
.data-table-container, .possibility-diagram-container, .probability-table-container {
    margin: 10px 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.data-table-container {
    max-height: 250px;
    overflow-y: auto;
}

.possibility-diagram-container, .probability-table-container {
    overflow-y: auto;
}

.data-table, .possibility-table, .probability-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.data-table th, .possibility-table th, .probability-table th {
    background: #3498db;
    color: white;
    padding: 8px;
    text-align: center;
    font-weight: 600;
    font-size: 13px;
}

.data-table td, .possibility-table td, .probability-table td {
    padding: 6px;
    text-align: center;
    border-bottom: 1px solid #ecf0f1;
    font-size: 12px;
}

.data-table tbody tr:hover, .probability-table tbody tr:hover {
    background: #f8f9fa;
}

.possibility-table td {
    background: #ecf0f1;
    font-weight: 600;
    color: #2c3e50;
}

.possibility-table th:first-child {
    background: #2c3e50;
}

.possibility-table tbody th {
    background: #2c3e50;
    color: white;
}

/* Graph Canvas */
.graph-instruction {
    margin: 10px 0;
    text-align: center;
}

/* Question Inputs */
.contagious-question, .reflection-question {
    margin: 10px 0;
}

.contagious-question {
    margin-top: 10px;
}

.contagious-question input {
    width: 100%;
    max-width: 300px;
    padding: 10px;
    border: 2px solid #bdc3c7;
    border-radius: 4px;
    font-size: 14px;
    margin-top: 10px;
}

.reflection-question textarea {
    width: 100%;
    padding: 8px;
    border: 2px solid #bdc3c7;
    border-radius: 4px;
    font-size: 13px;
    margin-top: 8px;
    resize: vertical;
    font-family: inherit;
    min-height: 60px;
    max-height: 80px;
}

.contagious-question input:focus, .reflection-question textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.3);
}

/* Answer feedback styles */
.answer-feedback {
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
}

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

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

/* Input styling for correct/incorrect answers */
.contagious-question input.correct-answer {
    border-color: #28a745;
    background-color: #f8fff9;
    box-shadow: 0 0 5px rgba(40, 167, 69, 0.3);
}

.contagious-question input.incorrect-answer {
    border-color: #dc3545;
    background-color: #fff8f8;
    box-shadow: 0 0 5px rgba(220, 53, 69, 0.3);
}

/* Reflection feedback styles */
.reflection-feedback {
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
}

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

.reflection-feedback.needs-improvement {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

/* Textarea styling for reflection answers */
.reflection-question textarea.good-answer {
    border-color: #28a745;
    background-color: #f8fff9;
    box-shadow: 0 0 5px rgba(40, 167, 69, 0.3);
}

.reflection-question textarea.needs-improvement-answer {
    border-color: #ffc107;
    background-color: #fffdf5;
    box-shadow: 0 0 5px rgba(255, 193, 7, 0.3);
}

/* Control Panel */
.control-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 6px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 0;
    flex-wrap: wrap;
}

.button-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 36px;
    white-space: nowrap;
}

.btn.primary {
    background: #4CAF50;
    color: white;
}

.btn.primary:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.btn.secondary {
    background: #f44336;
    color: white;
}

.btn.secondary:hover {
    background: #da190b;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
}

.btn.dice-btn {
    background: #FF9800;
    color: white;
}

.btn.dice-btn:hover {
    background: #F57C00;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3);
}

.population-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 200px;
}

.population-controls label {
    font-size: 14px;
    font-weight: 600;
    min-width: 80px;
    white-space: nowrap;
}

.slider {
    flex: 1;
    min-width: 100px;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Main Simulation Area */
.simulation-container {
    display: flex;
    gap: 10px;
    flex: 1;
    min-height: 0;
}

#simulationCanvas {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    flex: 1;
    max-width: 60%;
    height: 100%;
}

/* Statistics Panel */
.stats-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: 40%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stats-section h4 {
    color: #2c3e50;
    font-size: 14px;
    margin-bottom: 8px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 4px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 13px;
}

.stat-label {
    font-weight: 600;
    color: #555;
}

.stat-label.healthy {
    color: #4CAF50;
}

.stat-label.infected {
    color: #f44336;
}

.stat-label.recovered {
    color: #2196F3;
}

.stat-value {
    font-weight: bold;
    color: #2c3e50;
    background: rgba(52, 152, 219, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Dice Section */
.dice-section {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 120px;
}

.dice-container {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 2px 0;
}

.dice {
    width: 32px;
    height: 32px;
    background: #fff;
    border: 2px solid #333;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

.dice.rolling {
    animation: diceRoll 0.5s ease-in-out;
}

@keyframes diceRoll {
    0%, 100% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(90deg) scale(1.1); }
    50% { transform: rotate(180deg) scale(1.2); }
    75% { transform: rotate(270deg) scale(1.1); }
}

.dice-face {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    gap: 2px;
    padding: 4px;
}

.dot {
    width: 4px;
    height: 4px;
    background: #333;
    border-radius: 50%;
}

.dice-sum {
    font-size: 12px;
    font-weight: bold;
    color: #2c3e50;
    margin-top: 2px;
}

/* Chart Container */
.chart-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    height: 110px;
    flex-shrink: 0;
}

.chart-container h4 {
    color: #2c3e50;
    font-size: 13px;
    margin-bottom: 6px;
    text-align: center;
}

#chartCanvas {
    width: 100%;
    height: 80px;
    border-radius: 4px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .simulation-container {
        flex-direction: column;
    }
    
    #simulationCanvas {
        max-width: 100%;
        height: 200px;
    }
    
    .stats-panel {
        width: 100%;
        max-height: 150px;
    }
    
    .controls-row {
        justify-content: center;
    }
    
    .btn {
        flex: 1;
        min-width: 80px;
    }
}

/* Tooltip styles */
[title] {
    cursor: help;
}

/* Animation for infected students */
.student-infected {
    animation: infectionPulse 0.5s ease-out;
}

@keyframes infectionPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* Footer Styles */
.footer {
    background: rgba(52, 73, 94, 0.95);
    color: #ecf0f1;
    padding: 15px 20px;
    margin-top: 20px;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
}

.footer .credits {
    font-size: 14px;
    margin-bottom: 8px;
    color: #bdc3c7;
}

.footer .credits strong {
    color: #3498db;
    font-weight: 600;
}

.footer .resources {
    font-size: 13px;
    margin: 0;
    color: #95a5a6;
}

.footer .resources a {
    color: #3498db;
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer .resources a:hover {
    color: #5dade2;
    text-decoration: underline;
}

@media (max-width: 768px) {
    .footer {
        padding: 12px 15px;
    }
    
    .footer .credits,
    .footer .resources {
        font-size: 12px;
    }
    
    .footer .resources a {
        word-break: break-all;
    }
}
