/* ============================================================
   FXマネーナビ AIチャットボット - Styles
   Design: Finance-premium, STORK SE compatible
   ============================================================ */

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

:root {
    --fxnavi-primary: #1a56db;
    --fxnavi-primary-dark: #1242b0;
    --fxnavi-primary-light: #e8effc;
    --fxnavi-accent: #f59e0b;
    --fxnavi-accent-glow: rgba(245, 158, 11, 0.3);
    --fxnavi-bg: #ffffff;
    --fxnavi-bg-subtle: #f8fafc;
    --fxnavi-text: #1e293b;
    --fxnavi-text-muted: #64748b;
    --fxnavi-border: #e2e8f0;
    --fxnavi-bubble-user: #1a56db;
    --fxnavi-bubble-bot: #f1f5f9;
    --fxnavi-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    --fxnavi-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --fxnavi-radius: 16px;
    --fxnavi-font: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── FABボタン（チャット起動） ── */
.fxnavi-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99998;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--fxnavi-primary), var(--fxnavi-primary-dark));
    color: #fff;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(26, 86, 219, 0.4);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.fxnavi-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 40px rgba(26, 86, 219, 0.5);
}

.fxnavi-fab:active {
    transform: scale(0.95);
}

.fxnavi-fab svg {
    width: 28px;
    height: 28px;
    transition: transform 0.3s ease;
}

.fxnavi-fab.is-open svg {
    transform: rotate(90deg);
}

/* パルスアニメーション（注目喚起） */
.fxnavi-fab::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: rgba(26, 86, 219, 0.3);
    animation: fxnavi-pulse 2s ease-in-out infinite;
    z-index: -1;
}

.fxnavi-fab.is-open::before {
    animation: none;
    opacity: 0;
}

@keyframes fxnavi-pulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.2); opacity: 0; }
}

/* 未読バッジ */
.fxnavi-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #fff;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fxnavi-bounce 0.5s ease;
}

@keyframes fxnavi-bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* ── チャットウィンドウ ── */
.fxnavi-chat {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: 99999;
    width: 380px;
    max-height: 600px;
    height: calc(100vh - 140px);
    background: var(--fxnavi-bg);
    border-radius: var(--fxnavi-radius);
    box-shadow: var(--fxnavi-shadow);
    display: flex;
    flex-direction: column;
    font-family: var(--fxnavi-font);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: bottom right;
}

.fxnavi-chat.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ── ヘッダー ── */
.fxnavi-header {
    background: linear-gradient(135deg, var(--fxnavi-primary), var(--fxnavi-primary-dark));
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.fxnavi-header::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 120px;
    height: 200%;
    background: rgba(255,255,255,0.05);
    transform: rotate(15deg);
    pointer-events: none;
}

.fxnavi-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.3);
    overflow: hidden;
}

.fxnavi-avatar > img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.fxnavi-msg-avatar > img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

#fxnavi-chatbot-root .fxnavi-close svg {
    display: block !important;
    width: 16px !important;
    height: 16px !important;
    fill: none !important;
    stroke: #fff !important;
    stroke-width: 2.5 !important;
    flex-shrink: 0;
    visibility: visible !important;
    opacity: 1 !important;
}

#fxnavi-chatbot-root .fxnavi-send svg {
    display: block !important;
    width: 18px !important;
    height: 18px !important;
    fill: #fff !important;
    stroke: none !important;
    flex-shrink: 0;
    visibility: visible !important;
    opacity: 1 !important;
}

.fxnavi-header-info h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.fxnavi-header-info p {
    margin: 2px 0 0;
    font-size: 11px;
    opacity: 0.85;
    font-weight: 400;
}

.fxnavi-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.fxnavi-status::before {
    content: '';
    width: 7px;
    height: 7px;
    background: #4ade80;
    border-radius: 50%;
    animation: fxnavi-blink 2s ease infinite;
}

@keyframes fxnavi-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.fxnavi-close {
    margin-left: auto;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    position: relative;
    z-index: 2;
    overflow: visible;
}

.fxnavi-close:hover {
    background: rgba(255,255,255,0.25);
}

/* ── メッセージエリア ── */
.fxnavi-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--fxnavi-bg-subtle);
    scroll-behavior: smooth;
}

.fxnavi-messages::-webkit-scrollbar {
    width: 4px;
}

.fxnavi-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

/* メッセージバブル */
.fxnavi-msg {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: fxnavi-fadeUp 0.3s ease;
}

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

.fxnavi-msg.is-bot {
    align-self: flex-start;
}

.fxnavi-msg.is-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.fxnavi-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--fxnavi-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 2px;
}

.fxnavi-msg.is-user .fxnavi-msg-avatar {
    background: #dbeafe;
}

.fxnavi-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.65;
    color: var(--fxnavi-text);
    word-break: break-word;
}

.fxnavi-msg.is-bot .fxnavi-msg-bubble {
    background: var(--fxnavi-bg);
    border: 1px solid var(--fxnavi-border);
    border-bottom-left-radius: 4px;
    box-shadow: var(--fxnavi-shadow-sm);
}

.fxnavi-msg.is-user .fxnavi-msg-bubble {
    background: var(--fxnavi-bubble-user);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* リンク */
.fxnavi-msg-bubble a {
    color: var(--fxnavi-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 500;
}

.fxnavi-msg.is-user .fxnavi-msg-bubble a {
    color: #bfdbfe;
}

/* アフィリエイトCTAボタン */
.fxnavi-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, var(--fxnavi-accent), #d97706);
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 0.02em;
    transition: all 0.25s ease;
    box-shadow: 0 4px 12px var(--fxnavi-accent-glow);
}

.fxnavi-cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--fxnavi-accent-glow);
}

.fxnavi-cta svg {
    width: 14px;
    height: 14px;
}

/* タイピングインジケーター */
.fxnavi-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 2px;
}

.fxnavi-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94a3b8;
    animation: fxnavi-typing 1.2s ease infinite;
}

.fxnavi-typing span:nth-child(2) { animation-delay: 0.15s; }
.fxnavi-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes fxnavi-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ── クイックリプライ ── */
.fxnavi-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 12px;
    background: var(--fxnavi-bg-subtle);
}

.fxnavi-quick-btn {
    padding: 6px 12px;
    border: 1px solid var(--fxnavi-border);
    border-radius: 20px;
    background: var(--fxnavi-bg);
    color: var(--fxnavi-primary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--fxnavi-font);
    white-space: nowrap;
}

.fxnavi-quick-btn:hover {
    background: var(--fxnavi-primary-light);
    border-color: var(--fxnavi-primary);
}

/* ── 入力エリア ── */
.fxnavi-input-area {
    padding: 12px 14px;
    border-top: 1px solid var(--fxnavi-border);
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--fxnavi-bg);
    flex-shrink: 0;
}

.fxnavi-input-wrap {
    flex: 1;
    position: relative;
}

.fxnavi-input {
    width: 100%;
    border: 1px solid var(--fxnavi-border);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 13.5px;
    font-family: var(--fxnavi-font);
    color: var(--fxnavi-text);
    background: var(--fxnavi-bg-subtle);
    resize: none;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    max-height: 100px;
    overflow-y: auto;
    line-height: 1.5;
    box-sizing: border-box;
}

.fxnavi-input:focus {
    border-color: var(--fxnavi-primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

.fxnavi-input::placeholder {
    color: var(--fxnavi-text-muted);
}

.fxnavi-send {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--fxnavi-primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    overflow: visible;
}

.fxnavi-send:hover:not(:disabled) {
    background: var(--fxnavi-primary-dark);
    transform: scale(1.05);
}

.fxnavi-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.fxnavi-send svg {
    width: 18px;
    height: 18px;
}

/* ── フッター ── */
.fxnavi-footer {
    padding: 6px 14px 8px;
    text-align: center;
    font-size: 10px;
    color: var(--fxnavi-text-muted);
    background: var(--fxnavi-bg);
    flex-shrink: 0;
}

.fxnavi-footer a {
    color: var(--fxnavi-primary);
    text-decoration: none;
}

/* ── ウェルカムティーザー ── */
.fxnavi-teaser {
    position: fixed;
    bottom: 96px;
    right: 24px;
    z-index: 99997;
    background: var(--fxnavi-bg);
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: var(--fxnavi-shadow-sm);
    border: 1px solid var(--fxnavi-border);
    font-family: var(--fxnavi-font);
    font-size: 13px;
    color: var(--fxnavi-text);
    max-width: 260px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    pointer-events: none;
    line-height: 1.6;
}

.fxnavi-teaser.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.fxnavi-teaser::after {
    content: '';
    position: absolute;
    bottom: -7px;
    right: 28px;
    width: 14px;
    height: 14px;
    background: var(--fxnavi-bg);
    border-right: 1px solid var(--fxnavi-border);
    border-bottom: 1px solid var(--fxnavi-border);
    transform: rotate(45deg);
}

.fxnavi-teaser-close {
    position: absolute;
    top: 4px;
    right: 6px;
    background: none;
    border: none;
    color: var(--fxnavi-text-muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 2px 4px;
}

/* ── モバイル対応 ── */
@media (max-width: 480px) {
    .fxnavi-chat {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        transform: translateY(100%);
    }

    .fxnavi-chat.is-visible {
        transform: translateY(0);
    }

    .fxnavi-fab {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }

    .fxnavi-fab svg {
        width: 24px;
        height: 24px;
    }

    .fxnavi-teaser {
        right: 16px;
        bottom: 82px;
        max-width: 220px;
        font-size: 12px;
    }
}

/* ── Markdownスタイル（ボット応答内） ── */
.fxnavi-msg-bubble strong {
    font-weight: 700;
}

.fxnavi-msg-bubble ul,
.fxnavi-msg-bubble ol {
    margin: 6px 0;
    padding-left: 18px;
}

.fxnavi-msg-bubble li {
    margin-bottom: 2px;
}

.fxnavi-msg-bubble code {
    background: rgba(0,0,0,0.06);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 12px;
}

/* ── 免責エリア ── */
.fxnavi-disclaimer {
    padding: 6px 16px 8px;
    background: #fffbeb;
    border-top: 1px solid #fde68a;
    font-size: 10px;
    color: #92400e;
    line-height: 1.5;
    flex-shrink: 0;
}
