/**
 * 理解度チェックテスト専用スタイル
 * レスポンシブ対応、選択肢シャッフル表示対応
 */

/* ============================================
   基本レイアウト
   ============================================ */
.quiz-page-container {
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.quiz-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.quiz-wrapper {
    display: flex;
    gap: 2rem;
}

.quiz-container {
    flex: 1;
    background: white;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    min-height: 600px;
}

/* ============================================
   サイドバー
   ============================================ */
.quiz-sidebar {
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidebar-section {
    background: white;
    border-radius: 15px;
    padding: 1.5rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.sidebar-section h3 {
    margin: 0 0 1rem 0;
    color: #333;
    font-size: 1.1rem;
}

.sidebar-section p {
    color: #666;
    line-height: 1.6;
    font-size: 0.95rem;
}

.sidebar-section ul {
    margin: 1rem 0 0 0;
    padding-left: 1.5rem;
    color: #666;
}

.level-list {
    margin: 0;
}

.level-list dt {
    font-weight: 600;
    margin: 0.75rem 0 0.25rem 0;
}

.level-list dd {
    margin: 0 0 0 1rem;
    color: #666;
    font-size: 0.9rem;
}

/* ============================================
   難易度選択画面
   ============================================ */
.level-selection {
    text-align: center;
}

.level-selection h2 {
    color: #333;
    margin-bottom: 0.5rem;
    font-size: 2rem;
}

.level-selection .description {
    color: #666;
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.level-card {
    position: relative;
    height: 100%;
}

.level-button {
    width: 100%;
    min-height: 200px;
    padding: 1.5rem 1rem;
    background: white;
    border: 3px solid;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    text-align: center;
    height: 100%;
}

.level-button:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.level-button:active {
    transform: translateY(-2px);
}

.level-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.level-button h3 {
    margin: 0.5rem 0;
    color: #333;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.level-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: inherit;
    margin: 0.25rem 0;
    flex-shrink: 0;
}

.level-description {
    font-size: 0.9rem;
    color: #666;
    margin: 0.5rem 0;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.4;
}

.level-icon {
    flex-shrink: 0;
}

.question-count {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* ============================================
   パンくずリスト
   ============================================ */
.breadcrumb {
    background: rgba(255, 255, 255, 0.9);
    padding: 1rem 2rem;
    font-size: 0.9rem;
    color: #6c757d;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
}

.breadcrumb a {
    color: #667eea;
    text-decoration: none;
    transition: color 0.2s ease;
}

.breadcrumb a:hover {
    color: #764ba2;
    text-decoration: underline;
}

/* ============================================
   問題タイプ表示
   ============================================ */
.question-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.type-icon {
    font-size: 1.1rem;
}

.type-text {
    font-size: 0.85rem;
}

/* ============================================
   複数選択UI
   ============================================ */
.choice-label {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.choice-label:hover {
    background: #e9ecef;
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.choice-checkbox {
    width: 20px;
    height: 20px;
    accent-color: #667eea;
    transform: scale(1.2);
}

.choice-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.choice-label .choice-number {
    background: #667eea;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.choice-label code {
    background: transparent;
    color: #333;
    font-size: 1rem;
    font-weight: 500;
}

.choice-label:has(.choice-checkbox:checked) {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
}

.choice-label:has(.choice-checkbox:checked) code {
    color: white;
}

.choice-label:has(.choice-checkbox:disabled) {
    opacity: 0.7;
    cursor: not-allowed;
}

.choice-label.correct-choice {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
    border-color: #28a745 !important;
    color: white !important;
}

.choice-label.correct-choice code {
    color: white !important;
}

.choice-label.incorrect-choice {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%) !important;
    border-color: #dc3545 !important;
    color: white !important;
}

.choice-label.incorrect-choice code {
    color: white !important;
}

.answer-comparison {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border-left: 4px solid #667eea;
}

.selected-answers, .correct-answers {
    margin: 0.5rem 0;
    font-size: 0.95rem;
}

.selected-answers strong, .correct-answers strong {
    color: #333;
    font-weight: 600;
}

/* ============================================
   選択情報・確定ボタン
   ============================================ */
.selection-info {
    margin: 1rem 0;
    text-align: center;
}

.selection-counter {
    background: #f8f9fa;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    color: #6c757d;
    font-size: 0.9rem;
    border: 1px solid #e9ecef;
}

.confirm-button {
    padding: 0.75rem 2rem;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 1rem;
}

.confirm-button:hover:not(.disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.4);
}

.confirm-button.disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

/* ============================================
   問題表示画面
   ============================================ */
.quiz-question {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.quiz-header {
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 1rem;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.level-badge {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
}

.question-number {
    color: #666;
    font-weight: 500;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
}

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

/* ============================================
   問題と選択肢
   ============================================ */
.question-content h3 {
    color: #333;
    font-size: 1.3rem;
    line-height: 1.6;
    margin: 0 0 2rem 0;
}

.choices {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.choice-button {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-size: 1rem;
    position: relative;
}

.choice-button:hover:not(:disabled) {
    background: #e9ecef;
    border-color: #667eea;
    transform: translateX(5px);
}

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

.choice-button.correct {
    background: #d4edda;
    border-color: #28a745;
}

.choice-button.incorrect {
    background: #f8d7da;
    border-color: #dc3545;
}

.choice-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: white;
    border-radius: 50%;
    font-weight: 600;
    color: #667eea;
    flex-shrink: 0;
}

.choice-button code {
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    color: #333;
    background: rgba(255, 255, 255, 0.5);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
}

/* ============================================
   フィードバック
   ============================================ */
.feedback {
    margin-top: 1rem;
    animation: slideIn 0.3s ease;
}

.feedback.hidden {
    display: none;
}

.feedback-content {
    padding: 1.5rem;
    border-radius: 12px;
    border: 2px solid;
}

.feedback-content.correct {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
}

.feedback-content.incorrect {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

.feedback-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.feedback-message strong {
    display: block;
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.feedback-message p {
    margin: 0.5rem 0;
}

.feedback-message code {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
}

.explanation {
    background: rgba(255, 255, 255, 0.5);
    padding: 0.75rem;
    border-radius: 8px;
    margin-top: 0.75rem;
}

.related-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    background: white;
    border-radius: 20px;
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.related-link:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

/* ============================================
   アクションボタン
   ============================================ */
.quiz-actions {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
}

.next-button {
    padding: 0.75rem 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.next-button.hidden {
    display: none;
}

/* ============================================
   結果画面
   ============================================ */
.quiz-results {
    text-align: center;
}

.quiz-results h2 {
    color: #333;
    margin-bottom: 2rem;
    font-size: 2rem;
}

.score-display {
    display: flex;
    justify-content: center;
    margin: 2rem 0;
}

.score-circle {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.score-percentage {
    font-size: 3rem;
    font-weight: 700;
}

.score-fraction {
    font-size: 1.2rem;
    opacity: 0.9;
}

.result-message {
    margin: 2rem 0;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 12px;
}

.result-message h3 {
    margin: 0 0 0.5rem 0;
    color: #333;
}

.result-message p {
    margin: 0;
    color: #666;
}

.result-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin: 2rem 0;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.stat-value {
    color: #333;
    font-size: 1.2rem;
    font-weight: 600;
}

/* ============================================
   回答の振り返り
   ============================================ */
.answer-review {
    margin: 3rem 0;
    text-align: left;
}

.answer-review h3 {
    color: #333;
    margin-bottom: 1rem;
}

.answer-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 12px;
}

.answer-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.75rem;
    background: white;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.answer-item.correct {
    border-color: #28a745;
}

.answer-item.incorrect {
    border-color: #dc3545;
}

.answer-number {
    font-weight: 600;
    color: #667eea;
    min-width: 35px;
}

.answer-icon {
    font-size: 1.2rem;
}

.answer-details {
    flex: 1;
}

.answer-question {
    color: #333;
    margin: 0 0 0.5rem 0;
    font-weight: 500;
}

.answer-correction {
    color: #666;
    font-size: 0.9rem;
    margin: 0;
}

.answer-correction code {
    background: #f0f0f0;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-family: monospace;
}

/* ============================================
   結果画面のアクションボタン
   ============================================ */
.result-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

.action-button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-button.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.action-button.secondary {
    background: #6c757d;
    color: white;
}

.action-button.share {
    background: #1da1f2;
    color: white;
}

.action-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* ============================================
   クイズ履歴
   ============================================ */
.quiz-stats {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 12px;
}

.quiz-stats h3 {
    margin: 0 0 1rem 0;
    color: #333;
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 1rem;
}

.history-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem;
    background: white;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.history-level {
    font-weight: 600;
    font-size: 0.9rem;
}

.history-score {
    font-size: 1.2rem;
    font-weight: 700;
    color: #333;
}

.no-history {
    color: #666;
    font-style: italic;
}

/* ============================================
   ローディング
   ============================================ */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f0f0f0;
    border-top: 5px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

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

/* ============================================
   レスポンシブデザイン
   ============================================ */
@media (max-width: 1024px) {
    .quiz-wrapper {
        flex-direction: column;
    }

    .quiz-sidebar {
        width: 100%;
        order: 2;
    }

    .quiz-container {
        order: 1;
    }
}

@media (max-width: 768px) {
    /* ハンバーガーメニューのモバイル対応 */
    .hamburger-menu {
        display: flex !important;
        margin-left: auto !important;
        align-self: center !important;
    }

    .main-nav {
        display: none !important;
    }

    .quiz-main {
        padding: 1rem 0.5rem;
    }

    .quiz-container {
        padding: 1.5rem;
        border-radius: 15px;
    }

    .level-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .level-button {
        min-height: 180px;
        padding: 1.25rem 1rem;
    }

    .question-content h3 {
        font-size: 1.1rem;
    }

    .choice-button {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }

    .score-circle {
        width: 150px;
        height: 150px;
    }

    .score-percentage {
        font-size: 2.5rem;
    }

    .result-stats {
        flex-direction: column;
        gap: 1rem;
    }

    .result-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .quiz-sidebar {
        display: none; /* モバイルではサイドバーを非表示 */
    }
}

@media (max-width: 480px) {
    .quiz-container {
        padding: 1rem;
    }

    .level-button {
        padding: 1rem 0.75rem;
        min-height: 160px;
    }

    .level-icon {
        font-size: 2rem;
    }

    .choice-button {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .choice-number {
        width: 25px;
        height: 25px;
        font-size: 0.9rem;
    }
}