/* --- チャットボット風モーダル --- */
.chat-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.chat-modal.active {
    display: flex;
    opacity: 1;
}

.chat-container {
    background: #fff;
    width: 90%;
    max-width: 450px;
    height: 80vh;
    max-height: 600px;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transform: translateY(20px);
    transition: transform 0.3s;
}

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

/* チャットヘッダー */
.chat-header {
    background: var(--primary-color);
    color: #fff;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-title {
    font-weight: bold;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-avatar-small {
    width: 30px;
    height: 30px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--primary-color);
    font-size: 1.2rem;
}

.chat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

/* プログレスバー */
.chat-progress-container {
    width: 100%;
    height: 4px;
    background: #eee;
}

.chat-progress-bar {
    height: 100%;
    background: linear-gradient(to right, #00cc00, #00ff00); /* LINE風グリーン */
    transition: width 0.5s ease;
}

/* チャットエリア */
.chat-messages {
    flex: 1;
    padding: 20px;
    background: #e6e6e6; /* LINE風の背景色 */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* 入力中アニメーション (...) */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 15px 20px;
    background: #fff;
    border-radius: 15px;
    border-top-left-radius: 0;
    width: fit-content;
    margin-left: 46px; /* アイコン分ずらす */
    margin-bottom: 10px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #ccc;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* 吹き出し共通 */
.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 15px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    animation: fadeIn 0.3s ease-out;
}

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

/* 左側（ボット） */
.message-bot {
    align-self: flex-start;
    background: #fff;
    border-top-left-radius: 0;
    margin-left: 10px;
}

.bot-container {
    display: flex;
    align-items: flex-start;
}

.bot-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden; /* 画像が丸くなるように */
    flex-shrink: 0;
}

/* 右側（ユーザー） */
.message-user {
    align-self: flex-end;
    background: #8de055; /* LINE風の緑 */
    border-top-right-radius: 0;
    margin-right: 5px;
}

/* 選択肢ボタンエリア */
.option-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-self: flex-start;
    width: 80%;
    margin-left: 46px; /* アイコン + マージン分 */
    animation: fadeIn 0.5s ease-out;
}

.chat-btn {
    background: #fff;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 10px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    transition: 0.2s;
    text-align: center;
}

.chat-btn:hover {
    background: var(--primary-color);
    color: #fff;
}

/* 入力エリア */
.chat-input-area {
    background: #fff;
    padding: 15px;
    border-top: 1px solid #eee;
    display: none; /* 最初は非表示 */
}

.chat-input-area.active {
    display: block;
}

.chat-form-group {
    display: flex;
    gap: 10px;
}

.chat-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1rem;
}

.chat-send-btn {
    background: var(--primary-color);
    color: #fff;
    border: none;
    padding: 0 20px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}

/* チャット吹き出しツールチップ */
.chat-tooltip {
    position: absolute;
    bottom: 80px;
    right: 0;
    background: #fff;
    color: #333;
    padding: 10px 15px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    font-size: 0.85rem;
    font-weight: bold;
    white-space: nowrap;
    pointer-events: none; /* クリックは下のボタンに通す */
}

.chat-tooltip::after {
    content: "";
    position: absolute;
    bottom: -8px;
    right: 25px;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #fff;
}

/* 注目させるアニメーション */
.attention-shake {
    animation: shake 0.8s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* フローティングボタンの上書き（チャット起動用） */
.chat-trigger-btn {
    position: fixed;
    bottom: 130px; /* PC Floating CTAの上 */
    right: 30px;
    width: auto; /* 幅自動 */
    height: 60px;
    background: #fff; /* 白背景 */
    color: var(--primary-color);
    border-radius: 50px; /* カプセル型 */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 5px 20px 5px 15px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    cursor: pointer;
    z-index: 9000;
    border: 2px solid var(--primary-color);
    transition: 0.3s;
    gap: 8px;
    animation: bounce-soft 3s infinite;
}

.chat-trigger-icon {
    font-size: 1.8rem;
}

.chat-trigger-text {
    font-weight: bold;
    font-size: 1rem;
    letter-spacing: 0.5px;
}

.chat-trigger-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    background: var(--primary-color);
    color: #fff;
}

.chat-trigger-btn:hover .chat-trigger-badge {
    border-color: var(--primary-color);
}

.chat-trigger-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #cc0000;
    color: #fff;
    font-size: 0.8rem;
    width: 24px;
    height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    font-weight: bold;
    border: 2px solid #fff;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes bounce-soft {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

@media (max-width: 768px) {
    .chat-trigger-btn {
        bottom: 90px; /* スマホ固定フッターの上 */
        right: 15px;
        width: 60px; /* スマホは丸アイコンに戻す */
        height: 60px;
        padding: 0;
        border-radius: 50%;
    }
    
    .chat-trigger-text {
        display: none; /* スマホではテキスト非表示 */
    }
    
    .chat-trigger-icon {
        font-size: 1.8rem;
        margin: 0;
    }
    
    .chat-container {
        height: 100vh;
        height: 100dvh;
        max-height: 100vh;
        max-height: 100dvh;
        width: 100%;
        border-radius: 0;
    }
}

/* 都道府県選択UI (Added) */
.pref-selection-container {
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 10px;
    margin-top: 10px;
    width: 100%;
    box-sizing: border-box;
}

.region-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.region-btn {
    padding: 10px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--primary-color, #0d47a1);
    font-weight: bold;
    transition: background 0.2s;
}

.region-btn:hover {
    background: #e3f2fd;
}

.pref-back-btn {
    border: none;
    background: none;
    color: #666;
    cursor: pointer;
    font-size: 0.9rem;
}

.pref-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

.pref-btn {
    padding: 8px 4px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #333;
    transition: all 0.2s;
}

.pref-btn.selected {
    background: var(--primary-color, #0d47a1);
    color: #fff;
    border-color: var(--primary-color, #0d47a1);
}

.pref-submit-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(45deg, #0d47a1, #1976d2);
    color: white;
    border: none;
    border-radius: 50px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(13, 71, 161, 0.2);
}

.pref-submit-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}
