@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700&family=Playfair+Display:ital,wght@1,700&display=swap');

:root {
    --navy-dark: #152238;
    --navy: #1e3a5f;
    --navy-light: #2b5797;
    --white: #ffffff;
    --bg-header: #f5f7fa;
    --bg-chat: #f8f5f0;
    --border-light: #e4e7ec;
    --text-dark: #333333;
    --text-muted: #999999;
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.18);
    --font: 'Noto Sans JP', sans-serif;
    --chat-width: 370px;
    --chat-height: 580px;
}

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

body {
    font-family: var(--font);
    background: transparent;
}

/* =============================================
   フローティングボタン
============================================= */
#chat-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--navy);
    color: var(--white);
    border: none;
    border-radius: 50px;
    padding: 10px 20px 10px 10px;
    cursor: pointer;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.3s ease,
                opacity 0.3s ease;
    z-index: 9999;
}

#chat-toggle-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 50px rgba(30, 58, 95, 0.35);
}

#chat-toggle-btn:active {
    transform: scale(0.97);
}

#chat-toggle-btn.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.5);
}

.toggle-icon {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.toggle-label {
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.toggle-badge {
    background: #e53e3e;
    color: var(--white);
    font-size: 11px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* =============================================
   チャットウィンドウ
============================================= */
#chat-container {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: var(--chat-width);
    height: var(--chat-height);
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10000;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#chat-container.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

@media (max-width: 440px) {
    #chat-container {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }
}

/* =============================================
   ヘッダー
============================================= */
.chat-header {
    background: var(--bg-header);
    padding: 0;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
    position: relative;
}

.header-actions-top {
    display: flex;
    justify-content: flex-end;
    gap: 2px;
    padding: 6px 8px 0;
}

.header-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: background 0.2s, color 0.2s;
}

.header-action-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-dark);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 4px 20px 18px;
}

.header-ai-label {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-weight: 700;
    font-size: 36px;
    color: var(--navy);
    line-height: 1;
    flex-shrink: 0;
}

.header-info {
    min-width: 0;
}

.header-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--navy);
    line-height: 1.3;
}

.header-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* =============================================
   メッセージエリア
============================================= */
#messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px 18px;
    background: var(--bg-chat);
    display: flex;
    flex-direction: column;
    gap: 18px;
    scroll-behavior: smooth;
}

#messages-area::-webkit-scrollbar {
    width: 4px;
}

#messages-area::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

/* メッセージ行 */
.message-row {
    display: flex;
    gap: 10px;
    animation: msgFadeIn 0.3s ease-out forwards;
}

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

.message-row.user {
    flex-direction: row-reverse;
}

/* ボットアバター */
.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--white);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

/* バブル */
.message-bubble {
    max-width: 78%;
    padding: 14px 16px;
    line-height: 1.7;
    font-size: 13px;
    color: var(--text-dark);
    word-break: break-word;
}

.bot-bubble {
    background: var(--white);
    border: 1px solid var(--border-light);
    border-radius: 2px 14px 14px 14px;
    box-shadow: var(--shadow-sm);
}

.user-bubble {
    background: var(--navy);
    color: var(--white);
    border-radius: 14px 2px 14px 14px;
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.2);
}

/* タイピングインジケーター */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 14px 18px;
    background: var(--white);
    border: 1px solid var(--border-light);
    border-radius: 2px 14px 14px 14px;
    width: fit-content;
    box-shadow: var(--shadow-sm);
}

.dot {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: dotBounce 1.4s infinite ease-in-out both;
}

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

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

/* =============================================
   入力エリア
============================================= */
.input-area {
    padding: 14px 16px;
    background: var(--white);
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

#user-input {
    flex: 1;
    border: 1px solid var(--border-light);
    border-radius: 24px;
    padding: 10px 18px;
    font-size: 16px; /* スマホ(iOS)の自動ズーム防止のため16pxに設定 */
    font-family: var(--font);
    color: var(--text-dark);
    background: var(--white);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#user-input::placeholder {
    color: #bbb;
    font-size: 12px; /* 長い文章を表示するためにプレースホルダーのみ小さく設定 */
}

#user-input:focus {
    border-color: var(--navy-light);
    box-shadow: 0 0 0 2px rgba(43, 87, 151, 0.1);
}

#send-btn {
    width: 38px;
    height: 38px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s, background 0.2s;
}

#send-btn:hover {
    transform: scale(1.1);
    background: rgba(30, 58, 95, 0.06);
}

#send-btn:active {
    transform: scale(0.95);
}

/* =============================================
   フッター
============================================= */
.chat-footer {
    padding: 6px 16px 8px;
    text-align: center;
    font-size: 10px;
    color:#333;
    background: var(--white);
    border-top: 1px solid var(--border-light);
    flex-shrink: 0;
}


/* スマホ（画面幅440px以下）の時の設定 */
@media (max-width: 440px) {
    #chat-container {
        top: 0;        /* 画面の一番上に固定 */
        left: 0;       /* 左端に固定 */
        bottom: 0;
        right: 0;
        width: 100%;   /* 横幅いっぱい */
        height: 100%;  /* 高さいっぱい */
        height: 100dvh; /* スマホのメニューバー等を除いた「本当の高さ」に合わせる */
        border-radius: 0; /* 角の丸みをなくして全画面にする */
    }
}
