/* ============================================
   components.css - コンポーネント別スタイル
   ============================================ */

/* ----- 歴史質問コンテナ ----- */
.history-container {
    max-width: 100%;
}

.history-header {
    margin-bottom: 1.5rem;
}

.history-header h2 {
    font-size: 1.6rem;
    color: #2c1810;
    margin-bottom: 0.3rem;
}

.history-description {
    color: #5a4a3a;
    font-size: 0.95rem;
    line-height: 1.6;
}

/* ----- チケット残高表示 ----- */
.balance-display {
    background: #faf8f5;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    margin-bottom: 1.2rem;
    border: 1px solid #e8e0d8;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.balance-loading {
    color: #8a7a6a;
    font-size: 0.9rem;
}

.balance-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.95rem;
}

.balance-icon {
    font-size: 1.2rem;
}

.balance-text {
    color: #5a4a3a;
}

.balance-text strong {
    color: #2c1810;
    font-size: 1.1rem;
}

.balance-detail {
    color: #8a7a6a;
    font-size: 0.85rem;
}

.balance-mock {
    background: #f39c12;
    color: #fff;
    padding: 0.1rem 0.6rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: bold;
}

.balance-purchase {
    background: #2c7a3a;
    color: #f5f0eb;
    padding: 0.2rem 0.8rem;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.2s;
}

.balance-purchase:hover {
    background: #1e5e2b;
}

/* ----- 質問フォーム ----- */
.question-form {
    background: #faf8f5;
    padding: 1.2rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border: 1px solid #e8e0d8;
}

/* ----- サジェスト ----- */
.suggestions-section {
    margin-bottom: 1.5rem;
}

.suggestions-section h4 {
    font-size: 1rem;
    color: #2c1810;
    margin-bottom: 0.6rem;
}

.suggestions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.suggestion-chip {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    background: #f5f0eb;
    border: 1px solid #e8e0d8;
    border-radius: 20px;
    font-size: 0.85rem;
    color: #5a4a3a;
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion-chip:hover {
    background: #2c1810;
    color: #f5f0eb;
    border-color: #2c1810;
    transform: translateY(-1px);
}

/* ----- 回答表示 ----- */
.answer-section {
    margin-top: 1rem;
}

.answer-container {
    min-height: 200px;
    padding: 0.5rem 0;
}

.answer-wrapper {
    background: #faf8f5;
    border-radius: 8px;
    padding: 1.2rem 1.5rem;
    border: 1px solid #e8e0d8;
}

.answer-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid #e8e0d8;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: #5a4a3a;
}

.meta-region {
    background: #2c1810;
    color: #f5f0eb;
    padding: 0.1rem 0.6rem;
    border-radius: 12px;
}

.meta-year {
    background: #8a7a6a;
    color: #f5f0eb;
    padding: 0.1rem 0.6rem;
    border-radius: 12px;
}

.meta-question {
    color: #2c1810;
    font-weight: 500;
}

.meta-tickets {
    background: #f5f0eb;
    color: #2c1810;
    padding: 0.1rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
}

.answer-content {
    font-size: 1rem;
    line-height: 1.8;
    color: #333;
}

.answer-text {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.answer-text strong {
    color: #2c1810;
}

.answer-text ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.answer-text ul li {
    margin-bottom: 0.3rem;
    list-style: disc;
}

/* ----- 回答アクションボタン ----- */
.answer-actions {
    display: flex;
    gap: 0.8rem;
    margin-top: 1rem;
    padding-top: 0.8rem;
    border-top: 1px solid #e8e0d8;
    flex-wrap: wrap;
}

.btn-copy {
    background: #2c1810;
    color: #f5f0eb;
}

.btn-copy:hover {
    background: #1a0e08;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(44, 24, 16, 0.3);
}

.btn-download {
    background: #2c7a3a;
    color: #f5f0eb;
}

.btn-download:hover {
    background: #1e5e2b;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(44, 122, 58, 0.3);
}

.btn-copy:active,
.btn-download:active {
    transform: scale(0.96);
}

/* ----- チケットエラー表示 ----- */
.ticket-error {
    border: 2px solid #e74c3c;
    background: #fdf2f2;
    padding: 2rem;
}

.ticket-error .error-icon {
    font-size: 3rem;
}

.ticket-error p {
    font-size: 1.1rem;
    margin-bottom: 0.3rem;
}

.ticket-error .error-sub {
    color: #8a7a6a;
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.ticket-error .error-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ----- ローディングオーバーレイ ----- */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 999;
}

.loading-content {
    background: #fff;
    padding: 2rem 3rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
    max-width: 400px;
}

.loading-content .loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e8e0d8;
    border-top-color: #2c1810;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

.loading-content p {
    font-size: 1rem;
    color: #2c1810;
    margin-bottom: 0.3rem;
}

.loading-sub {
    font-size: 0.85rem;
    color: #8a7a6a !important;
}

/* ----- エラーコンテナ（error.html用） ----- */
.error-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 2rem;
}

.error-content {
    text-align: center;
    max-width: 500px;
}

.error-content .error-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.error-content .error-title {
    font-size: 2rem;
    color: #e74c3c;
    margin-bottom: 1rem;
}

.error-content .error-message {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 2rem;
}

.error-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* ----- レスポンシブ補完 ----- */
@media (max-width: 768px) {
    .suggestions-list {
        gap: 0.3rem;
    }
    
    .suggestion-chip {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }
    
    .answer-wrapper {
        padding: 0.8rem 1rem;
    }
    
    .answer-meta {
        font-size: 0.75rem;
        gap: 0.3rem 0.6rem;
    }
    
    .answer-actions {
        flex-direction: column;
    }
    
    .answer-actions .btn {
        width: 100%;
        justify-content: center;
    }
    
    .loading-content {
        padding: 1.5rem 2rem;
        margin: 0 1rem;
    }
    
    .balance-display {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.3rem;
    }
    
    .ticket-error .error-actions {
        flex-direction: column;
        align-items: center;
    }
}

@media (max-width: 480px) {
    .answer-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
    }
    
    .meta-region, .meta-year {
        display: inline-block;
    }
    
    .suggestion-chip {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }
    
    .balance-info {
        font-size: 0.85rem;
    }
}
