/* チャットモーダル用CSS */
body, html {
    overflow-x: hidden;
}
.chat-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    font-family: 'Noto Sans JP', 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;!important
}

.chat-modal.active {
    opacity: 1;
    visibility: visible;
}

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

.chat-modal-container {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 100%;
    max-width: 450px;
    height: 100%;
    max-height: 600px;
    background: white;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3);
    transform: translateY(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-modal.active .chat-modal-container {
    transform: translateY(0);
}

/* チャットヘッダー */
.chat-header {
    background: #DE3E21;
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.chat-header-content {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}

.chat-header-image {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-header-text {
    flex: 1;
}

.chat-title {
    margin: 0 0 5px 0;
    font-size: 18px;
    font-weight: bold;
}

.chat-subtitle {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}

.chat-close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* チャットボディ */
.chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: #f7f7f7;
}

/* チャットメッセージ */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
    min-height: 0;
    max-height: calc(100vh - 200px);
}

/* チャットバブル */
.chat-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.chat-bubble.show {
    opacity: 1;
    transform: translateY(0);
}

.question-bubble {
    align-self: flex-start;
    background: #EBEBEB;
    color: #333;
    border-bottom-left-radius: 4px;
}

/* 質問コンテナ */
.question-container {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
}

.question-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    margin-top: 4px;
    border-radius: 50%;
    object-fit: cover;
}

/* 回答コンテナ（bubble + 編集ボタン） */
.answer-container {
    align-self: flex-end;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
}

.answer-bubble {
    background: #DE3E21;
    color: white;
    border-bottom-right-radius: 4px;
    order: 2;
    max-width: 100%; 
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.completion-bubble {
    align-self: center;
    background: #e8f5e8;
    color: #2e7d32;
    border-radius: 18px;
    text-align: center;
}

.bubble-content {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.bubble-text {
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-all;
    white-space: pre-line;    
}

/* 初期画像用バブル */
.image-bubble {
    align-self: center;
    padding: 0;
    margin: 10px 0;
    max-width: 95%;
}

.image {
    width: 100%;
    min-width: 320px;
    max-width: 380px;
    height: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: block;
    margin: 0 auto;
}

.edit-btn {
    background: transparent;
    border: none;
    padding: 4px 8px;
    cursor: pointer;
    transition: color 0.3s ease;
    flex-shrink: 0;
    order: 1;
    margin-right: auto;
    font-size: 11px;
    color: #525253;
}

.edit-btn:hover {
    background: transparent;
    color: #939397;
}


/* 選択肢ボタン（バブルと同じ領域に表示） */
.options-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    max-width: 100%;
    width: 100%;
    align-self: stretch;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    margin-top: 5px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    flex-shrink: 0;
}

.options-container.show {
    opacity: 1;
    transform: translateY(0);
}

.option-btn {
    background: white;
    border: 2px solid #EBEBEB;
    border-radius: 25px;
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    font-size: 14px;
    color: #333;
    width: 100%;
    flex-shrink: 0;
}

.option-btn:hover {
    border-color: #DE3E21;
    background: #f8f9ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.option-btn:active {
    transform: translateY(0);
}

/* 生年月日入力（バブルと同じ領域に表示） */
.birthdate-container {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    max-width: 100%;
    width: 100%;
    align-self: stretch;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    margin-top: 5px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    flex-shrink: 0;
}

.birthdate-container.show {
    opacity: 1;
    transform: translateY(0);
}

.birthdate-select {
    flex: 1;
    min-width: 80px;
    padding: 10px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    background: white;
    font-size: 14px;
    transition: border-color 0.3s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%23666' d='M6 8L0 2h12z'/%3E%3C/svg%3E");
    background-position: calc(100% - 12px) center;
    background-repeat: no-repeat;
    background-size: 12px 8px;
    padding-right: 35px;
}

.birthdate-select:focus {
    outline: none;
    border-color: #667eea;
}

.birthdate-submit-btn {
    background: linear-gradient(135deg, #F27101 0%, #DE3E21 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
    width: 100%;
    align-self: stretch;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.birthdate-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* 名前入力（バブルと同じ領域に表示） */
.name-input-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 100%;
    width: 100%;
    align-self: stretch;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    margin-top: 5px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    flex-shrink: 0;
}

.name-input-container.show {
    opacity: 1;
    transform: translateY(0);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.input-group label {
    font-size: 14px;
    font-weight: bold;
    color: #333;
}

.name-input {
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.name-input:focus {
    outline: none;
    border-color: #667eea;
}

.name-submit-btn {
    background: linear-gradient(135deg, #F27101 0%, #DE3E21 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.name-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* フォーム（バブルと同じ領域に表示） */
.form-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 100%;
    width: 100%;
    align-self: stretch;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    margin-top: 5px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    flex-shrink: 0;
}

.form-container.show {
    opacity: 1;
    transform: translateY(0);
}

.summary-container {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 15px;
    border: 1px solid #e9ecef;
}

/* 修正案内のスタイル */
.edit-notice {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
}

.edit-notice p {
    margin: 0;
    font-size: 14px;
    color: #6c757d;
    text-align: center;
}

.summary-container h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 16px;
}

.summary-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
}

.summary-item:last-child {
    border-bottom: none;
}

.summary-label {
    font-weight: bold;
    color: #666;
    font-size: 14px;
}

.summary-value {
    color: #333;
    font-size: 14px;
}

.chat-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-field-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-field-group label {
    font-size: 14px;
    font-weight: bold;
    color: #333;
}

.form-input {
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
    resize: vertical;
}

.form-input[type="select"],
.form-input select,
select.form-input {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%23666' d='M6 8L0 2h12z'/%3E%3C/svg%3E");
    background-position: calc(100% - 12px) center;
    background-repeat: no-repeat;
    background-size: 12px 8px;
    padding-right: 35px;
    resize: none;
}

.form-input:focus {
    outline: none;
    border-color: #667eea;
}

.form-input.error {
    border-color: #dc3545;
}

.form-submit-btn {
    background: linear-gradient(135deg, #F27101 0%, #DE3E21 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s ease;
    margin-top: 10px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.form-submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.form-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* エラーメッセージ */
.error-message {
    color: #dc3545;
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

/* スクロールバー */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .chat-modal-container {
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        right: 0;
        left: 0;
        width: 100vw;
    }
    
    .chat-header {
        padding: 15px;
    }
    
    .chat-title {
        font-size: 16px;
    }
    
    .chat-subtitle {
        font-size: 12px;
    }
    
    .chat-messages {
        padding: 15px;
    }
    
    .chat-bubble {
        max-width: 90%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .question-container {
        flex-direction: row;
        align-items: flex-start;
        box-sizing: border-box;
        width: 100%;
        gap: 6px;
    }
    
    .question-bubble {
        flex: 1;
        min-width: 0;
    }
    
    .birthdate-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .birthdate-select {
        min-width: auto;
    }
    
    .option-btn {
        padding: 15px 20px;
        font-size: 16px;
    }
    
    .name-input,
    .form-input {
        padding: 15px;
        font-size: 16px;
    }
    
    .form-submit-btn {
        padding: 12px 20px;
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .chat-bubble {
        max-width: 95%;
        padding: 10px 14px;
        font-size: 14px;
    }
    
    .question-icon {
        width: 32px;
        height: 32px;
    }
    
    .question-container {
        gap: 4px;
    }
    
    .question-bubble {
        flex: 1;
        min-width: 0;
    }
    
    .options-container {
        max-width: 100%;
        width: 100%;
        grid-template-columns: 1fr;
    }
    
    .birthdate-container,
    .name-input-container,
    .form-container {
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
    }
    
    .bubble-content {
        gap: 6px;
    }
    
    .edit-btn {
        font-size: 11px;
        padding: 3px 6px;
    }
    
    .image-bubble {
        max-width: 95%;
    }
    
    .image {
        min-width: 260px;
        max-width: 320px;
        border-radius: 8px;
    }
}
