/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader {
    text-align: center;
    color: white;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top: 5px solid white;
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loader p {
    font-size: 18px;
    margin: 10px 0;
}

.loading-progress {
    font-size: 24px;
    font-weight: bold;
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
}

.section {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    margin-bottom: 20px;
}

.hidden {
    display: none !important;
}

/* Drag Drop Question Image Styles */
#question-text img {
    display: block;
    margin: 15px 0;
    max-width: 100%;
    height: auto;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

#question-text img:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}

/* Quiz Setup */
.setup-options {
    display: grid;
    gap: 20px;
    margin-bottom: 30px;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.option-group label {
    font-weight: 600;
    color: #333;
}

.option-group select,
.option-group input[type="number"] {
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
}

.option-group select:focus,
.option-group input[type="number"]:focus {
    outline: none;
    border-color: #667eea;
}

.option-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Buttons */
.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #0517c7 0%, #030c68 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover:not(:disabled) {
    background: #d0d0d0;
}

.btn-warning {
    background: linear-gradient(135deg, #f39c12 0%, #f1c40f 100%);
    color: white;
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(243, 156, 18, 0.4);
}

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

#start-quiz {
    width: 100%;
    padding: 15px;
    font-size: 1.1em;
}

/* Quiz Content */
.quiz-header {
    margin-bottom: 30px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 15px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s ease;
    width: 0%;
}

.quiz-info {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    font-weight: 600;
    color: #666;
}

.question-container {
    margin-top: 20px;
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.question-number {
    background: #667eea;
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9em;
}

.answer-count-info {
    background: #ff9800;
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9em;
    display: none;
}

.answer-count-info.show {
    display: inline-block;
}

.question-text {
    font-size: 1.1em;
    line-height: 1.6;
    color: #333;
    margin-bottom: 25px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.options {
    display: grid;
    gap: 15px;
    margin-bottom: 25px;
}

.option {
    padding: 15px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.option:hover {
    border-color: #667eea;
    background: #f5f7ff;
}

.option.selected {
    border-color: #667eea;
    background: #e8ebff;
}

.option.correct {
    border-color: #4caf50;
    background: #e8f5e9;
}

.option.wrong {
    border-color: #f44336;
    background: #ffebee;
}

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

.option-letter {
    font-weight: 700;
    font-size: 1.1em;
    min-width: 30px;
    color: #667eea;
}

.option input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    margin-right: 8px;
}

.option.correct .option-letter {
    color: #4caf50;
}

.option.wrong .option-letter {
    color: #f44336;
}

.option-text {
    flex: 1;
    line-height: 1.5;
}

/* Feedback */
.feedback {
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-weight: 600;
}

.feedback.correct {
    background: #e8f5e9;
    border: 2px solid #4caf50;
    color: #2e7d32;
}

.feedback.wrong {
    background: #ffebee;
    border: 2px solid #f44336;
    color: #c62828;
}

/* Quiz Controls */
.quiz-controls {
    display: flex;
    gap: 15px;
    justify-content: space-between;
    flex-wrap: wrap;
}

.quiz-controls .btn {
    flex: 1;
    min-width: 150px;
}

/* Results */
.result-summary {
    background: #f5f7ff;
    padding: 30px;
    border-radius: 10px;
    margin-bottom: 30px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 15px 0;
    border-bottom: 1px solid #e0e0e0;
}

.result-item:last-child {
    border-bottom: none;
}

.result-label {
    font-weight: 600;
    color: #666;
}

.result-value {
    font-size: 1.3em;
    font-weight: 700;
}

.result-value.correct {
    color: #4caf50;
}

.result-value.wrong {
    color: #f44336;
}

.result-value.score {
    color: #667eea;
}

.result-details {
    margin-top: 30px;
}

.result-details h3 {
    margin-bottom: 20px;
    color: #333;
}

.answer-detail {
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    border-left: 4px solid;
}

.answer-detail.correct {
    background: #e8f5e9;
    border-left-color: #4caf50;
}

.answer-detail.wrong {
    background: #ffebee;
    border-left-color: #f44336;
}

.answer-detail-header {
    font-weight: 600;
    margin-bottom: 5px;
}

.answer-detail-text {
    font-size: 0.9em;
    color: #666;
}

#restart-quiz {
    width: 100%;
    margin-top: 20px;
    padding: 15px;
    font-size: 1.2em;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    header {
        margin-bottom: 15px;
    }
    
    header h1 {
        font-size: 1.6em;
        margin-bottom: 5px;
    }
    
    .subtitle {
        font-size: 0.9em;
    }
    
    .section {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .quiz-header {
        margin-bottom: 15px;
    }
    
    .progress-bar {
        height: 6px;
        margin-bottom: 10px;
    }
    
    .quiz-info {
        font-size: 0.85em;
        gap: 8px;
    }
    
    .question-header {
        margin-bottom: 12px;
        gap: 8px;
    }
    
    .question-number {
        padding: 5px 10px;
        font-size: 0.8em;
    }
    
    .answer-count-info {
        padding: 5px 10px;
        font-size: 0.8em;
    }
    
    .question-text {
        font-size: 0.95em;
        line-height: 1.5;
        margin-bottom: 15px;
        padding: 12px;
    }
    
    .options {
        gap: 10px;
        margin-bottom: 15px;
    }
    
    .option {
        padding: 10px 12px;
        gap: 8px;
    }
    
    .option-letter {
        font-size: 1em;
        min-width: 25px;
    }
    
    .option-text {
        font-size: 0.9em;
        line-height: 1.4;
    }
    
    .feedback {
        padding: 12px;
        margin-bottom: 15px;
        font-size: 0.9em;
    }
    
    /* Quiz Controls - 2 buttons trên cùng 1 hàng */
    .quiz-controls {
        flex-direction: row;
        gap: 8px;
    }
    
    .quiz-controls .btn {
        flex: 1;
        min-width: 0;
        padding: 10px 8px;
        font-size: 0.85em;
    }
    
    /* Result page */
    .result-summary {
        padding: 15px;
    }
    
    .result-item {
        padding: 10px 0;
    }
    
    .result-label,
    .result-value {
        font-size: 0.9em;
    }
    
    .result-value {
        font-size: 1.1em;
    }
}

/* Tối ưu cho iPhone (390px - 430px width) */
@media (max-width: 430px) {
    body {
        padding: 8px;
    }
    
    header h1 {
        font-size: 1.4em;
    }
    
    .subtitle {
        font-size: 0.85em;
    }
    
    .section {
        padding: 12px;
        border-radius: 12px;
    }
    
    .quiz-header {
        margin-bottom: 12px;
    }
    
    .quiz-info {
        font-size: 0.8em;
    }
    
    .question-text {
        font-size: 0.9em;
        padding: 10px;
        margin-bottom: 12px;
    }
    
    .options {
        gap: 8px;
        margin-bottom: 12px;
    }
    
    .option {
        padding: 8px 10px;
    }
    
    .option-text {
        font-size: 0.85em;
    }
    
    .quiz-controls .btn {
        padding: 9px 6px;
        font-size: 0.8em;
    }
    
    /* Emoji trong button có thể ẩn trên màn hình nhỏ */
    #prev-btn::before {
        content: '';
    }
    
    #next-btn::after {
        content: '';
    }
}

/* Tối ưu cho iPhone nhỏ (dưới 375px) */
@media (max-width: 375px) {
    header h1 {
        font-size: 1.3em;
    }
    
    .question-text {
        font-size: 0.85em;
    }
    
    .option-text {
        font-size: 0.8em;
    }
    
    .quiz-controls .btn {
        font-size: 0.75em;
        padding: 8px 5px;
    }
}

/* Donate Sections */
.donate-section {
    margin-top: 30px;
    padding: 20px;
    text-align: center;
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
    border-radius: 10px;
    border: 2px dashed #667eea;
}

.donate-section h3 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1.3em;
}

.donate-section p {
    color: #666;
    margin-bottom: 15px;
    font-size: 0.95em;
}

.donate-image {
    max-width: 250px;
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Footer Donate - Compact */
.footer-donate {
    position: fixed;
    bottom: 0;
    right: 0;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    border: none;
    border-radius: 20px 0 0 0;
    box-shadow: 0 -4px 20px rgba(255, 107, 107, 0.5);
    z-index: 1000;
    max-width: 200px;
    transition: all 0.3s ease;
    animation: donatePulse 1.5s ease-in-out infinite;
}

.footer-donate:hover {
    transform: scale(1.1) translateY(-3px);
    box-shadow: 0 -8px 30px rgba(255, 107, 107, 0.8);
}

@keyframes donatePulse {
    0%, 100% {
        box-shadow: 0 -4px 20px rgba(255, 107, 107, 0.5), 0 0 0 0 rgba(255, 107, 107, 0.4);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 -6px 30px rgba(255, 107, 107, 0.8), 0 0 20px rgba(255, 107, 107, 0.5);
        transform: scale(1.03);
    }
}

.footer-content {
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.footer-text {
    font-size: 1.1em;
    color: #ffffff;
    font-weight: 900;
    white-space: nowrap;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    letter-spacing: 1px;
}

.footer-qr {
    display: none;
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 10px;
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.footer-donate:hover .footer-qr {
    display: block;
}

.footer-donate-img {
    width: 150px;
    height: auto;
    border-radius: 5px;
}

/* Mobile responsive for donate sections */
@media (max-width: 768px) {
    .donate-image {
        max-width: 200px;
    }
    
    .footer-donate {
        max-width: 160px;
    }
    
    .footer-content {
        padding: 12px 16px;
    }
    
    .footer-text {
        font-size: 0.95em;
    }
    
    .footer-donate-img {
        width: 130px;
    }
}

@media (max-width: 480px) {
    .donate-section {
        padding: 15px;
    }
    
    .donate-section h3 {
        font-size: 1.1em;
    }
    
    .donate-section p {
        font-size: 0.85em;
    }
    
    .donate-image {
        max-width: 180px;
    }
    
    .footer-donate {
        max-width: 140px;
    }
    
    .footer-content {
        padding: 10px 14px;
    }
    
    .footer-text {
        font-size: 0.85em;
    }
    
    .footer-donate-img {
        width: 120px;
    }
}
