/* =================== basic-question.css (완전 통합 버전) =================== */
/* Basic형 문항 전용 스타일시트 */
/* 위치: static/css/slide-viewer/basic-question.css */

/* =================== 기본 레이아웃 =================== */
.basic-question {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    animation: fadeInUp 0.4s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =================== 제시문 영역 =================== */
.question-prebody {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 0;
    margin-bottom: 2rem;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

/* 제시문 토글 버튼 */
.prebody-toggle {
    width: 100%;
    padding: 1rem 1.5rem;
    background: transparent;
    border: none;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s ease;
}

.prebody-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.prebody-toggle:active {
    transform: scale(0.98);
}

.prebody-toggle i.fa-book-open {
    margin-right: 0.5rem;
}

.prebody-toggle-text {
    flex: 1;
    text-align: left;
}

.prebody-toggle-icon {
    transition: transform 0.3s ease;
}

.prebody-toggle[aria-expanded="true"] .prebody-toggle-icon {
    transform: rotate(180deg);
}

/* 제시문 콘텐츠 */
.prebody-content {
    background: white;
    padding: 1.5rem;
    overflow: hidden;
    transition: all 0.3s ease;
}

.prebody-content.expanded {
    max-height: 5000px;
    animation: expandPreBody 0.4s ease-out;
}

@keyframes expandPreBody {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 5000px;
    }
}

/* 제시문 제목 */
.prebody-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 1rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #e5e7eb;
}

/* 제시문 본문 */
.prebody-body {
    color: #374151;
    line-height: 1.8;
    font-size: 1rem;
}

.prebody-body p {
    margin-bottom: 1rem;
}

.prebody-body ul,
.prebody-body ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.prebody-body li {
    margin-bottom: 0.5rem;
}

/* 제시문 미디어 */
.prebody-media {
    margin-top: 1.5rem;
    text-align: center;
}

.prebody-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.prebody-video,
.prebody-audio {
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* =================== 문제 본문 =================== */
.question-body {
    margin-top: 1.5rem;
}

.question-header {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 1.5rem;
    line-height: 1.4;
}

.question-statement {
    font-size: 1.125rem;
    color: #374151;
    margin-bottom: 1.5rem;
    line-height: 1.8;
}

.question-hint {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
    border-radius: 4px;
    font-size: 0.95rem;
    color: #92400e;
}

/* =================== 선택지 =================== */
.question-choices {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.choice {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.choice:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    transform: translateX(4px);
}

.choice.selected {
    background: rgba(12, 102, 228, 0.1);
    border: 2px solid rgba(12, 101, 229, 0.4);
}

.choice.correct {
    background: rgba(12, 102, 228, 0.1);
    border: 2px solid rgba(12, 101, 229, 0.4);
}

.choice.correct .choice-text,
.choice.correct .choice-label {
    color: #0c66e4;
    font-weight: 700;
}

.choice.wrong {
    background: rgba(244, 63, 94, 0.1);
    border: 2px solid rgba(255, 0, 0, 0.4);
}

.choice.wrong .choice-text,
.choice.wrong .choice-label {
    color: #f43f5e;
    font-weight: 700;
}

.choice.disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* 선택지 마커 */
.choice-marker {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    background: white;
    border: 2px solid #d1d5db;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    color: #6b7280;
    transition: all 0.2s ease;
}

.choice.selected .choice-marker {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

.choice.correct .choice-marker {
    background: #0c66e4;
    border-color: #0c66e4;
    color: white;
}

.choice.wrong .choice-marker {
    background: #f43f5e;
    border-color: #f43f5e;
    color: white;
}

/* 선택지 텍스트 */
.choice-text {
    flex: 1;
    color: #1f2937;
    font-size: 1rem;
    line-height: 1.6;
}

/* =================== OX 선택지 =================== */
.ox-choices {
    flex-direction: row;
    justify-content: center;
    gap: 2rem;
}

.ox-choices .choice {
    flex: 0 1 180px;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    padding: 1.5rem;
}

.ox-choices .choice-marker {
    width: 3rem;
    height: 3rem;
    font-size: 1.5rem;
}

/* =================== 복수 선택 =================== */
.question-choices[data-multi-select="true"] .choice-marker {
    border-radius: 4px;
}

.question-choices[data-multi-select="true"] .choice.selected .choice-marker::after {
    content: "✓";
    font-size: 1.25rem;
}

/* =================== Answer 입력 필드 (Tailwind 스타일) =================== */
.answer,
input.answer,
textarea.answer,
.short-answer-input {
    /* 레이아웃 */
    width: 100%;
    padding: 0.875rem 1rem;
    margin: 0 0.5rem; /* mx-2 */
    
    /* 테두리 - ring-2 효과 */
    border: 2px solid #e5e7eb;
    border-radius: 0.375rem; /* rounded */
    box-shadow: 0 0 0 0px rgba(239, 68, 68, 0); /* 기본 링 없음 */
    
    /* 폰트 */
    font-size: 1rem;
    line-height: 1.5;
    color: #1f2937;
    
    /* 트랜지션 */
    transition: all 0.2s ease;
    
    /* 배경 */
    background-color: white;
}

/* Focus 상태 - focus:outline-none focus:ring-red-500 */
.answer:focus,
input.answer:focus,
textarea.answer:focus,
.short-answer-input:focus {
    outline: none; /* focus:outline-none */
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.5); /* ring-2 ring-red-500 */
    border-color: #ef4444;
}

/* Textarea 전용 */
textarea.answer,
textarea.short-answer-input {
    min-height: 120px;
    resize: vertical;
    font-family: inherit;
}

/* ✅ 수정 후 코드 (Basic형 단답형 제외) */
.answer.correct:not(.short-answer),
input.answer.correct:not(.short-answer),
textarea.answer.correct,
.short-answer-input.correct {
    border-color: #22c55e;
    background-color: #f0fdf4;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

/* ✅ 수정 후 */
.answer.correct:not(.short-answer):focus,
input.answer.correct:not(.short-answer):focus,
textarea.answer.correct:focus,
.short-answer-input.correct:focus {
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.5);
}

/* ✅ 수정 후 코드 (Basic형 단답형 제외) */
.answer.wrong:not(.short-answer),
input.answer.wrong:not(.short-answer),
textarea.answer.wrong,
.short-answer-input.wrong {
    border-color: #ef4444;
    background-color: #fef2f2;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

/* ✅ 수정 후 */
.answer.wrong:not(.short-answer):focus,
input.answer.wrong:not(.short-answer):focus,
textarea.answer.wrong:focus,
.short-answer-input.wrong:focus {
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.5);
}
/* Disabled 상태 */
.answer:disabled,
input.answer:disabled,
textarea.answer:disabled,
.short-answer-input:disabled {
    background-color: #f3f4f6;
    border-color: #d1d5db;
    color: #9ca3af;
    cursor: not-allowed;
    box-shadow: none;
}

/* Placeholder */
.answer::placeholder,
input.answer::placeholder,
textarea.answer::placeholder,
.short-answer-input::placeholder {
    color: #9ca3af;
    opacity: 1;
}

/* Hover 효과 */
.answer:not(:disabled):hover,
input.answer:not(:disabled):hover,
textarea.answer:not(:disabled):hover,
.short-answer-input:not(:disabled):hover {
    border-color: #d1d5db;
}

/* 인라인 답안 (짧은 입력) */
.answer.inline,
input.answer.inline {
    width: auto;
    min-width: 150px;
    display: inline-block;
}

/* 오답 애니메이션 */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.answer.wrong,
input.answer.wrong,
textarea.answer.wrong {
    animation: shake 0.3s ease-in-out;
}

/* 읽기 전용 */
.answer[readonly],
input.answer[readonly],
textarea.answer[readonly],
.short-answer-input[readonly] {
    background-color: #f9fafb;
    color: #6b7280;
    cursor: default;
}

/* 답안 컨테이너 */
.answer-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1rem 0;
}

.answer-container label {
    font-weight: 600;
    color: #374151;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

/* =================== 수식 렌더링 =================== */
.MathJax {
    display: inline !important;
    margin: 0 0.1em;
}

.MathJax_Display {
    margin: 1em 0 !important;
}

/* =================== 반응형 디자인 =================== */
@media (max-width: 768px) {
    .basic-question {
        padding: 1.5rem;
        border-radius: 8px;
    }
    
    .question-header {
        font-size: 1.25rem;
    }
    
    .question-statement {
        font-size: 1rem;
    }
    
    .choice {
        padding: 0.875rem 1rem;
    }
    
    .ox-choices {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .ox-choices .choice {
        flex: 1;
    }
    
    .prebody-toggle {
        padding: 0.875rem 1rem;
        font-size: 0.95rem;
    }
    
    .prebody-content {
        padding: 1rem;
    }
    
    /* Answer 입력 필드 모바일 */
    .answer,
    input.answer,
    textarea.answer,
    .short-answer-input {
        margin: 0 0.25rem; /* mx-1 */
        padding: 0.75rem 0.875rem;
        font-size: 0.95rem;
    }
    
    textarea.answer,
    textarea.short-answer-input {
        min-height: 100px;
    }
}

/* =================== 접근성 개선 =================== */
.choice:focus-visible {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
}

.prebody-toggle:focus-visible {
    outline: 3px solid white;
    outline-offset: -3px;
}

.answer:focus-visible,
input.answer:focus-visible,
textarea.answer:focus-visible,
.short-answer-input:focus-visible {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.5);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}