/* ========================================
   グローバルスタイル
   ======================================== */
:root {
    --primary-color: #ff6b35;
    --secondary-color: #f7931e;
    --success-color: #4caf50;
    --error-color: #f44336;
    --warning-color: #ff9800;
    --bg-color: #fff8f0;
    --card-bg: #ffffff;
    --text-color: #333333;
    --text-muted: #666666;
    --border-color: #e0e0e0;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.15);
    --radius: 12px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 10px;
}

/* ========================================
   ヘッダー
   ======================================== */
.app-header {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: var(--radius);
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.app-header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

/* ========================================
   ホーム画面
   ======================================== */
.home-content {
    animation: fadeIn 0.5s ease;
}

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

.input-section,
.quiz-set-section {
    background: var(--card-bg);
    padding: 30px;
    border-radius: var(--radius);
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.input-section h2,
.quiz-set-section h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--primary-color);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-color);
}

.required {
    color: var(--error-color);
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.error-message {
    color: var(--error-color);
    font-size: 0.875rem;
    margin-top: 8px;
    min-height: 20px;
}

.global-error {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--radius);
    border-left: 4px solid var(--error-color);
}

/* ========================================
   問題セットカード
   ======================================== */
.quiz-sets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.quiz-card {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.quiz-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: var(--primary-color);
}

.quiz-card-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.quiz-card h3 {
    font-size: 1.3rem;
    margin-bottom: 10px;
    color: var(--primary-color);
}

.quiz-description {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.quiz-badge {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
}

/* ========================================
   セクション説明
   ======================================== */
.section-description {
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 20px;
}

.loading-small {
    text-align: center;
    padding: 40px 20px;
}

.spinner-small {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

.loading-small p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ========================================
   ボタン
   ======================================== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-block;
}

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

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #e55a2b;
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #e08518;
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn-text {
    background: transparent;
    color: var(--primary-color);
    padding: 8px 16px;
}

.btn-text:hover {
    background: rgba(255, 107, 53, 0.1);
}

.btn-large {
    width: 100%;
    padding: 16px 24px;
    font-size: 1.1rem;
}

/* ========================================
   レビュー画面ヘッダー
   ======================================== */
.review-header {
    background: var(--card-bg);
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 10px;
    box-shadow: var(--shadow);
}

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

.header-top h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
}

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

.progress-info {
    flex: 1;
    min-width: 200px;
}

.progress-text {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-color);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width 0.3s ease;
    width: 0%;
}

.meta-info {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ========================================
   バッジ
   ======================================== */
.badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
}

.badge-primary {
    background: var(--primary-color);
    color: white;
}

.badge-reviewer {
    background: var(--secondary-color);
    color: white;
}

.badge-id {
    background: #9c27b0;
    color: white;
}

.badge-keyword {
    background: #2196f3;
    color: white;
}

.badge-category {
    background: #4caf50;
    color: white;
}

.badge-year {
    background: #ff9800;
    color: white;
}

/* ========================================
   ローディング・エラー
   ======================================== */
.loading,
.error-container {
    text-align: center;
    padding: 60px 20px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.error-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.error-container h2 {
    color: var(--error-color);
    margin-bottom: 10px;
}

.error-container .btn {
    margin: 10px 5px;
}

/* ========================================
   問題表示
   ======================================== */
.review-content {
    animation: fadeIn 0.5s ease;
}

.question-section,
.answer-section,
.result-section,
.action-section {
    background: var(--card-bg);
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 10px;
    box-shadow: var(--shadow);
}

.question-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.question-text {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--text-color);
    margin-bottom: 12px;
}

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

.question-reference a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.question-reference a:hover {
    text-decoration: underline;
}

/* ========================================
   選択肢
   ======================================== */
.answer-section h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--text-color);
}

.choices {
    display: grid;
    gap: 10px;
    margin-bottom: 12px;
}

.choice-btn {
    width: 100%;
    padding: 12px 16px;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.5s ease;
    position: relative;
}

.choice-btn:hover:not(:disabled) {
    border-color: var(--primary-color);
    background: rgba(255, 107, 53, 0.05);
    transform: translateX(4px);
}

.choice-btn.selected {
    border-color: var(--primary-color);
    background: rgba(255, 107, 53, 0.1);
    font-weight: 600;
}

.choice-btn.correct {
    border-color: var(--success-color);
    background: rgba(76, 175, 80, 0.1);
    color: var(--success-color);
    font-weight: 600;
}

.choice-btn.incorrect {
    border-color: var(--error-color);
    background: rgba(244, 67, 54, 0.1);
    color: var(--error-color);
    font-weight: 600;
}

.choice-btn:disabled {
    cursor: default;
}

/* ========================================
   コメント
   ======================================== */
.comment-section {
    background: var(--card-bg);
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.comment-section.show {
    opacity: 1;
    transform: translateY(0);
}

.comment-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-color);
}

.comment-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
    transition: var(--transition);
}

.comment-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.comment-hint {
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ========================================
   結果表示
   ======================================== */
.result-section {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.result-section.show {
    opacity: 1;
    transform: translateY(0);
}

.result-card {
    border-radius: var(--radius);
    overflow: hidden;
}

.result-header {
    padding: 12px;
    text-align: center;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.result-header.correct {
    background: var(--success-color);
}

.result-header.incorrect {
    background: var(--error-color);
}

.result-icon {
    font-size: 1.5rem;
}

.result-header h3 {
    font-size: 1.1rem;
    margin: 0;
}

.result-body {
    padding: 12px;
    background: var(--bg-color);
}

.result-item {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

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

.result-label {
    font-weight: 600;
    color: var(--text-muted);
    min-width: 90px;
    font-size: 0.9rem;
}

.result-value {
    flex: 1;
    color: var(--text-color);
    font-size: 0.9rem;
}

/* ========================================
   レスポンシブ
   ======================================== */
@media (max-width: 768px) {
    .container {
        padding: 8px;
    }

    .app-header {
        padding: 20px 15px;
    }

    .app-header h1 {
        font-size: 1.5rem;
    }

    .header-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .header-top h1 {
        font-size: 1.3rem;
    }

    .header-info {
        flex-direction: column;
        gap: 10px;
    }

    .question-text {
        font-size: 1rem;
    }

    .input-section,
    .quiz-set-section,
    .question-section,
    .answer-section,
    .result-section,
    .action-section {
        padding: 12px;
    }

    .quiz-sets {
        grid-template-columns: 1fr;
    }

    .result-header {
        flex-direction: column;
        gap: 8px;
    }

    .result-item {
        flex-direction: column;
        gap: 4px;
    }

    .result-label {
        min-width: auto;
    }
}

/* ========================================
   スムーススクロール
   ======================================== */
html {
    scroll-behavior: smooth;
}

/* ========================================
   モーダルダイアログ
   ======================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-dialog {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    animation: slideUp 0.3s ease;
}

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

.modal-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

.modal-body {
    padding: 24px;
}

.modal-body p {
    font-size: 16px;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.6;
}

.modal-footer {
    padding: 16px 24px 24px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-footer .btn {
    min-width: 100px;
}

/* レスポンシブ対応 */
@media (max-width: 600px) {
    .modal-dialog {
        width: 95%;
    }

    .modal-footer {
        flex-direction: column-reverse;
    }

    .modal-footer .btn {
        width: 100%;
    }
}


/* ========================================
   モーダル
   ======================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1;
}

.modal-content {
    position: relative;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    animation: modalSlideIn 0.3s ease;
    z-index: 2;
}

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

.modal-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.modal-content h2 {
    margin-bottom: 16px;
    color: var(--text-color);
    font-size: 1.5rem;
}

.modal-message {
    color: var(--text-muted);
    margin-bottom: 24px;
    font-size: 1rem;
    line-height: 1.6;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-buttons .btn {
    width: 100%;
    justify-content: center;
}

@media (max-width: 600px) {
    .modal-content {
        padding: 24px;
        width: 95%;
    }

    .modal-content h2 {
        font-size: 1.3rem;
    }

    .modal-message {
        font-size: 0.95rem;
    }
}
