/* Common Styles */
/* Header Styles */
.header {
    background-color: #fff;
    color: #064583;
    padding: 20px;
    text-align: center;
    margin-bottom: 20px;
}

.header-title {
    color: #064583;
    text-decoration: none;
    display: block;
}

.header h1 {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    font-size: 2.5rem;
    margin-bottom: 5px;
    color: #064583; 
}

.header .subtitle {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    color: #8ABAD3; 
    font-size: 1.2rem;
}

.subtitle span {
    font-weight: bold;
    color: #064583; 
    font-size: 2.0rem;
}

button, select, input[type="text"] {
    border-color: #00AEEF; 
}

button {
    background-color: #064583;
}

button:hover {
    background-color: #008ec5; 
}

.options .option.correct {
    background-color: #d0e9c6; /* 薄い緑 */
}

.options .option.incorrect {
    background-color: #f8d7da; /* 薄い赤 */
}

body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    background-color: #fff;
    margin: 0;
    padding: 0;
}

/* モード選択のスタイル調整 */
.mode-selector {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 30px;
    padding: 0 20px;
}

.mode-tab.active {
    display: none; /* アクティブなタブは非表示 */
}

.mode-tab:not(.active) {
    background-color: #f8f9fa;
    color: #6c757d;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    border: 1px solid #dee2e6;
}

.mode-tab:not(.active):hover {
    background-color: #e9ecef;
    color: #495057;
}

.container {
    width: 100%;
    max-width: 80%;
    margin: 20px auto;
    padding: 15px;
    background-color: #fff;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
    border-radius: 5px;
    box-sizing: border-box;
}

.flex-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
}

.flex-container > div {
    flex: 1 1 auto;
    margin: 0.5em;
    text-align: center;
}

h1 {
    color: #333;
    text-align: center;
    margin-bottom: 10px;
    font-size: 1.8rem;
}

.subtitle {
    color: #666;
    text-align: center;
    font-size: 1rem;
    margin-bottom: 20px;
}

.input-section {
    margin-bottom: 15px;
}

.input-section label {
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
}

.input-section input[type="text"],
.input-section select,
.input-section textarea {
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 1rem;
    font-family: Arial, sans-serif;
    line-height: 1.6;
    border-color: #00AEEF;
}

button {
    width: 100%;
    padding: 15px;
    background-color: #064583; 
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s ease;
    display: block;
    margin: 0 auto;
}

button:hover {
    background-color: #4da8c7; 
}

/* Mode Selector Styles */
.mode-selector {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    gap: 20px;
}

.mode-tab {
    padding: 15px 30px;
    background: #f8f8f8;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    transition: all 0.3s ease;
}

.mode-tab.active {
    background: #00AEEF;
    color: white;
    border-color: #00AEEF;
}

.mode-content {
    display: none;
}

.mode-content.active {
    display: block;
}

/* Practice Problem Styles */
.practice-problem {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.practice-problem h4 {
    color: #00AEEF;
    margin-bottom: 10px;
}

.japanese-text {
    background: #f4f8fb;
    border-left: 4px solid #2196F3;
    padding: 10px 15px;
    margin: 10px 0;
    font-size: 1.05rem;
}

.prompting-questions {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    padding: 10px;
    margin: 10px 0;
    font-size: 0.9rem;
}

/* Marked Text Styles */
.marked-number {
    background: linear-gradient(90deg, #ffeb3b 0%, #ffe082 100%);
    color: #222;
    padding: 2px 7px 2px 5px;
    border-radius: 5px;
    font-weight: bold;
    box-shadow: 0 2px 6px rgba(255, 235, 59, 0.3), 0 1px 2px rgba(0,0,0,0.08);
    font-family: 'Segoe UI', 'Arial', sans-serif;
    margin: 0 2px;
    display: inline-block;
}

#corrected_text, textarea#corrected_text {
    font-family: 'Fira Mono', 'Consolas', 'Menlo', 'Monaco', 'Liberation Mono', monospace !important;
    font-size: 1.05rem;
    background-color: #f9f9f9;
    border: 2px solid #2196F3;
    color: #222;
}

/* Results Tables */
.results-table,
.final-results-table {
    width: 100%;
    margin: 15px 0;
    border-collapse: collapse;
}

.results-table th,
.results-table td,
.final-results-table th,
.final-results-table td {
    padding: 12px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid #ddd;
}

/* Simple rows for Japanese Text and Your Answer/Original English Text */
.simple-row {
    background-color: #f8f9fa;
    color: #6c757d;
    font-weight: normal;
    border-left: 2px solid #dee2e6;
}

/* Highlighted rows for Correction and Explanation */
.highlight-row {
    background-color: #e8f5e8;
    color: #155724;
    font-weight: bold;
    border-left: 4px solid #28a745;
}

.highlight-row td {
    font-weight: normal;
}

/* New Session Button */
.new-session-btn {
    width: 50%;
    margin-top: 20px;
}

/* Error Message */
.error-message {
    background: #ffebee;
    color: #c62828;
    padding: 15px;
    border-radius: 4px;
    margin: 20px 0;
}

#loading {
    text-align: center;
    padding: 20px;
}

.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

#quiz-section {
    margin-top: 20px;
}

#question-text {
    font-size: 1rem;
    margin-bottom: 15px;
    padding: 12px;
    background-color: #f9f9f9;
    border-radius: 4px;
    line-height: 1.6;
}

.options {
    margin-bottom: 15px;
}

.options .option {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    padding: 12px;
    background-color: #f9f9f9;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.options .option:hover {
    background-color: #e9e9e9;
}

.options input[type="radio"] {
    margin-right: 10px;
}

#evaluation {
    margin-top: 15px;
}

.probability-item {
    display: flex;
    flex-direction: column;
    padding: 10px;
    margin-bottom: 8px;
    background-color: #f5f5f5;
    border-radius: 4px;
}

.probability-item.selected {
    background-color: #b3e0f5; 
}

.explanation {
    margin-top: 15px;
    padding: 12px;
    background-color: #b3e0f5; 
    border-radius: 4px;
}

#final-results {
    text-align: center;
    margin-top: 25px;
}

#average-score h4 {
    margin-bottom: 8px;
    font-size: 1.2rem;
}

#average-score p.average {
    font-size: 2.5rem;
    color: #ff0000;
    margin: 0;
}

.summary-table {
    width: 100%;
    margin: 15px 0;
    border-collapse: collapse;
}

.summary-table th,
.summary-table td {
    border: 1px solid #D6F4FE;
    padding: 10px;
    font-size: 0.9rem;
}

.summary-table th {
    background-color: #D6F4FE;
}

/* Footer Styles */
.footer {
    background-color: #00AEEF;
    color: #fff;
    padding: 20px;
    text-align: center;
    margin-top: 20px; 
}

.footer-text {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    font-size: 1rem;
    margin: 5px 0;
}

/* Error Search Results Styles */
#search-results {
    margin-top: 20px;
}

#search-results h2 {
    color: #064583;
    text-align: center;
    margin-bottom: 15px;
    font-size: 1.8rem;
    border-bottom: 2px solid #00AEEF;
    padding-bottom: 10px;
}

.search-stats {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.stats-item {
    font-size: 1rem;
    color: #495057;
}

.stats-item strong {
    color: #064583;
    font-weight: 600;
}

/* Example Item Container */
.example-item {
    background: #ffffff;
    border: 2px solid #e3f2fd;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.08);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.example-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

/* Example Header */
.example-header {
    background: linear-gradient(135deg, #064583 0%, #00AEEF 100%);
    color: white;
    padding: 12px 20px;
    margin: 0;
}

.example-number {
    font-weight: bold;
    font-size: 1.1rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Concordance Table */
.concordance-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

.concordance-table tbody tr {
    border-bottom: 1px solid #f8f9fa;
}

.concordance-table tbody tr:last-child {
    border-bottom: none;
}

.context-label {
    background-color: #f8f9fa;
    color: #495057;
    font-weight: 600;
    padding: 15px 20px;
    width: 140px;
    text-align: right;
    vertical-align: top;
    border-right: 3px solid #dee2e6;
    font-size: 0.95rem;
}

.context-text {
    padding: 15px 20px;
    color: #212529;
    font-size: 1rem;
    line-height: 1.6;
    background-color: #ffffff;
}

/* Japanese text styling */
.concordance-table tbody tr:first-child .context-text {
    background-color: #f4f8fb;
    border-left: 4px solid #2196F3;
    font-weight: 500;
    color: #1565c0;
}

/* Error row styling */
.error-row .context-label {
    background-color: #fff5f5;
    color: #c53030;
    border-right: 3px solid #fc8181;
}

.error-row .error-text {
    background-color: #fff5f5;
    color: #c53030;
    padding: 15px 20px;
    font-family: 'Courier New', monospace;
    font-weight: 500;
    border-left: 4px solid #fc8181;
    position: relative;
}

.error-text::before {
    content: "❌";
    position: absolute;
    left: -2px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
}

/* Correction row styling */
.correction-row .context-label {
    background-color: #f0fff4;
    color: #22543d;
    border-right: 3px solid #68d391;
}

.correction-row .correction-text {
    background-color: #f0fff4;
    color: #22543d;
    padding: 15px 20px;
    font-family: 'Courier New', monospace;
    font-weight: 600;
    border-left: 4px solid #68d391;
    position: relative;
}

.correction-text::before {
    content: "✅";
    position: absolute;
    left: -2px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
}

/* Explanation text styling */
.explanation-text {
    background-color: #fffbf0;
    color: #744210;
    padding: 15px 20px;
    font-size: 0.95rem;
    line-height: 1.7;
    border-left: 4px solid #fbb041;
    font-style: italic;
}

/* Search Actions */
.search-actions {
    text-align: center;
    margin-top: 30px;
    padding: 20px;
}

.search-actions .new-session-btn {
    background: linear-gradient(135deg, #064583 0%, #00AEEF 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-actions .new-session-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
    background: linear-gradient(135deg, #00AEEF 0%, #064583 100%);
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    .search-stats {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .context-label {
        width: 120px;
        font-size: 0.9rem;
        padding: 12px 15px;
    }
    
    .context-text,
    .error-text,
    .correction-text,
    .explanation-text {
        padding: 12px 15px;
        font-size: 0.95rem;
    }
    
    .example-header {
        padding: 10px 15px;
    }
    
    .example-number {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .concordance-table {
        font-size: 0.9rem;
    }
    
    .context-label {
        width: 100px;
        font-size: 0.85rem;
        padding: 10px 12px;
    }
    
    .context-text,
    .error-text,
    .correction-text,
    .explanation-text {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
    
    .search-stats {
        padding: 12px;
    }
    
    .stats-item {
        font-size: 0.9rem;
    }
}

/* Animation for example items */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.example-item {
    animation: slideIn 0.5s ease-out;
}

.example-item:nth-child(even) {
    animation-delay: 0.1s;
}

.example-item:nth-child(odd) {
    animation-delay: 0.2s;
}

/* Responsive Design */

/* For smartphones (screens less than 600px wide) */
@media (max-width: 600px) {
    body {
        font-size: 1rem;
    }

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

    h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1.2rem;
    }

    button {
        padding: 10px;
        font-size: 1rem;
    }

    .mode-selector {
        flex-direction: column;
        gap: 10px;
    }

    .mode-tab {
        padding: 10px 20px;
        font-size: 1rem;
    }

    #question-text {
        font-size: 1rem;
        padding: 10px;
    }

    .options .option {
        padding: 10px;
        font-size: 1rem;
    }

    .probability-item {
        padding: 8px;
        font-size: 1rem;
    }

    .explanation {
        padding: 10px;
        font-size: 1rem;
    }

    #average-score h4 {
        font-size: 1rem;
    }

    #average-score p.average {
        font-size: 2rem;
    }

    .summary-table th,
    .summary-table td,
    .results-table th,
    .results-table td,
    .final-results-table th,
    .final-results-table td {
        padding: 8px;
        font-size: 0.9rem;
    }

    .new-session-btn {
        width: 80%;
    }
}