/* SAM AI Strategy Navigator - Premium Chatbot Styles */

:root {
    /* 2026-07-11 ライトテーマ化（座長: 黒背景がUGっぽい→本体の薄ブルー世界観に合わせる）。
       旧ダーク値は末尾コメント参照。色は本体 index.html の --sam-primary:#818cf8 等に準拠。 */
    --sam-chat-primary: #818cf8;              /* 本体と同じインディゴ（グラデ・ユーザー吹き出し） */
    --sam-chat-secondary: #6366f1;            /* 濃いめインディゴ（送信ボタン・小見出し＝白地で読める） */
    --sam-chat-bg: rgba(247, 249, 255, 0.97); /* ほぼ白＋ごく薄い青（本体の薄ブルーに馴染む） */
    --sam-chat-glass: rgba(129, 140, 248, 0.10); /* 薄いインディゴのすりガラス（白地でも見える） */
    --sam-chat-border: rgba(129, 140, 248, 0.28);
    --sam-chat-text: #1e293b;                 /* 本体と同じ濃色テキスト（白地で読める） */
    --sam-chat-muted: #64748b;
    --sam-chat-shadow: 0 20px 45px rgba(99, 102, 241, 0.22);
    /* 旧ダーク: primary#8a2be2 / secondary#00d4ff / bg rgba(15,15,20,.85) / glass rgba(255,255,255,.03)
       / border rgba(255,255,255,.1) / text#fff / muted#a0a0a0 / shadow rgba(0,0,0,.4) */
}

/* Floating Widget Container */
.sam-chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 10000;
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    transition: all 0.5s cubic-bezier(0.19, 1, 0.22, 1);
}

.sam-chat-widget.minimized {
    opacity: 0.2;
    pointer-events: none;
    transform: scale(0.8);
    filter: blur(1px);
}

/* Floating Icon */
.sam-chat-trigger {
    width: 85px;
    height: 85px;
    background: linear-gradient(135deg, var(--sam-chat-primary), #6a11cb);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(138, 43, 226, 0.4);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.sam-chat-trigger:hover {
    transform: scale(1.1) rotate(5deg);
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 15px 35px rgba(138, 43, 226, 0.6);
    box-shadow: 0 0 20px var(--sam-chat-secondary);
}

.sam-chat-trigger i, .sam-chat-trigger svg {
    color: white;
    width: 30px;
    height: 30px;
}

.sam-chat-trigger .avatar {
    margin: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 50%;
    overflow: hidden;
}
.sam-chat-trigger::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--sam-chat-primary);
    opacity: 0.5;
    z-index: -1;
    animation: sam-pulse 2s infinite;
}

@keyframes sam-pulse {
    0% { transform: scale(1); opacity: 0.5; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* Speech Bubble */
.sam-speech-bubble {
    position: absolute;
    bottom: 80px;
    right: 0;
    background: var(--sam-chat-glass);
    border: 1px solid var(--sam-chat-border);
    backdrop-filter: blur(20px);
    padding: 10px 15px;
    border-radius: 15px;
    border-bottom-right-radius: 2px;
    color: var(--sam-chat-text);
    font-size: 0.85rem;
    white-space: nowrap;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    opacity: 1;
    transform: translateY(0);
    transition: all 0.5s ease;
    pointer-events: auto;
}

.sam-speech-bubble.active {
    opacity: 1;
    transform: translateY(0);
}

/* Chat Window */
.sam-chat-window {
    position: absolute;
    bottom: 85px;
    right: 0;
    width: 380px;
    height: 600px;
    max-height: 80vh;
    background: var(--sam-chat-bg);
    backdrop-filter: blur(25px);
    border: 1px solid var(--sam-chat-border);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    box-shadow: var(--sam-chat-shadow);
}

.sam-chat-window.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
.sam-chat-header {
    padding: 20px;
    background: rgba(129, 140, 248, 0.07);
    border-bottom: 1px solid var(--sam-chat-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sam-chat-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sam-chat-title .avatar {
    width: 45px;
    height: 45px;
    background: var(--sam-chat-glass);
    border: 2px solid var(--sam-chat-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    overflow: hidden;
    flex-shrink: 0;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sam-chat-info h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    color: var(--sam-chat-text);
}

.sam-chat-info p {
    font-size: 0.75rem;
    color: var(--sam-chat-secondary);
    margin: 0;
    font-weight: 600;
}

.sam-chat-close {
    background: rgba(129, 140, 248, 0.10);
    border: 1px solid var(--sam-chat-border);
    color: var(--sam-chat-text);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 7px 13px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    line-height: 1;
    transition: all 0.3s;
}

.sam-chat-close:hover {
    background: var(--sam-chat-secondary);
    color: #ffffff;
    border-color: var(--sam-chat-secondary);
}

.sam-chat-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.sam-chat-action-btn {
    background: rgba(129, 140, 248, 0.10);
    border: 1px solid var(--sam-chat-border);
    color: var(--sam-chat-text);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s;
}

.sam-chat-action-btn:hover {
    background: var(--sam-chat-primary);
    border-color: var(--sam-chat-primary);
}

.sam-chat-action-btn i, .sam-chat-action-btn svg {
    width: 14px;
    height: 14px;
}

/* Messages Area */
.sam-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
}

.sam-chat-messages::-webkit-scrollbar {
    width: 5px;
}

.sam-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

/* Message Bubbles */
.sam-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.9rem;
    line-height: 1.5;
    position: relative;
    animation: sam-msg-in 0.3s ease-out;
}

@keyframes sam-msg-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.sam-msg.ai {
    align-self: flex-start;
    background: var(--sam-chat-glass);
    border: 1px solid var(--sam-chat-border);
    border-bottom-left-radius: 4px;
    color: var(--sam-chat-text);
    font-weight: 500;
}

.sam-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--sam-chat-primary), #5a189a);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 5px 15px rgba(138, 43, 226, 0.2);
}

/* Table Styling */
.sam-table-wrapper {
    overflow-x: auto;
    margin: 10px 0;
    border-radius: 8px;
    border: 1px solid var(--sam-chat-border);
}

.sam-table-wrapper table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    color: var(--sam-chat-text);
}

.sam-table-wrapper th, .sam-table-wrapper td {
    padding: 8px 12px;
    text-align: left;
    border: 1px solid var(--sam-chat-border);
}

.sam-table-wrapper th {
    background: rgba(255, 255, 255, 0.1);
    color: var(--sam-chat-secondary);
    font-weight: 700;
}

.sam-table-wrapper tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.03);
}

/* Analysis Card */
.sam-card {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--sam-chat-secondary);
    border-radius: 18px;
    padding: 18px;
    margin: 12px 0;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3), 0 0 20px rgba(0, 212, 255, 0.15);
}

.sam-card-header {
    font-size: 0.8rem;
    color: var(--sam-chat-secondary);
    font-weight: 700;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sam-card-body {
    font-size: 0.95rem;
}

.sam-stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.sam-stat-val {
    font-weight: 700;
    color: var(--sam-chat-secondary);
}

/* Visual Components for Cards */
.sam-progress-container {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    margin: 10px 0;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.sam-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--sam-chat-primary), var(--sam-chat-secondary));
    box-shadow: 0 0 10px var(--sam-chat-secondary);
    border-radius: 4px;
    transition: width 1s ease-out;
}

/* Horizontal Chart Styles */
.sam-chart-header { margin-bottom: 15px; }
.sam-chart-msg { font-weight: bold; font-size: 1rem; color: var(--sam-chat-secondary); margin: 0 0 5px 0; }
.sam-chart-sub { font-size: 0.8rem; color: var(--sam-chat-muted); margin: 0; }

.sam-chart-container { margin: 15px 0; }

.sam-bar-row { display: flex; align-items: center; margin-bottom: 12px; }
.sam-bar-label { width: 45px; font-size: 0.85rem; color: var(--sam-chat-muted); font-weight: bold; }
.sam-bar-track { flex: 1; display: flex; align-items: center; position: relative; }

.sam-bar-fill { 
    height: 24px; 
    border-radius: 4px; 
    display: flex; 
    align-items: center; 
    justify-content: flex-end; 
    padding-right: 8px; 
    font-weight: bold; 
    font-size: 0.8rem; 
    transition: width 1s cubic-bezier(0.2, 0.8, 0.2, 1);
    /* For animation effect when rendering */
    animation: bar-grow 1s ease-out forwards;
}

@keyframes bar-grow {
    from { opacity: 0; transform: scaleX(0); transform-origin: left; }
    to { opacity: 1; transform: scaleX(1); transform-origin: left; }
}

.bar-gray { background: rgba(255, 255, 255, 0.15); color: #fff; }
.bar-highlight { background: linear-gradient(90deg, var(--sam-chat-primary), var(--sam-chat-secondary)); color: #fff; box-shadow: 0 0 10px rgba(0, 212, 255, 0.3); }
.bar-highlight-text { color: var(--sam-chat-secondary); }

/* 100% Stacked Bar Chart (帯グラフ) Styles */
.sam-stacked-bar {
    display: flex;
    width: 100%;
    height: 30px;
    border-radius: 6px;
    overflow: hidden;
    margin: 15px 0;
}
.sam-stacked-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    color: white;
    box-sizing: border-box;
    border-right: 1px solid rgba(0,0,0,0.1);
    animation: bar-grow 1s ease-out forwards;
}
.sam-stacked-segment:last-child { border-right: none; }
.sam-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 10px;
    font-size: 0.8rem;
    justify-content: center;
}
.sam-legend-item { display: flex; align-items: center; gap: 5px; }
.sam-legend-dot { width: 10px; height: 10px; border-radius: 50%; }

.bg-highlight { background: linear-gradient(90deg, var(--sam-chat-primary), var(--sam-chat-secondary)); color: #fff; }
.bg-gray { background: rgba(255, 255, 255, 0.15); color: #ccc; }
.text-highlight { color: var(--sam-chat-secondary); font-weight: bold; }
.text-gray { color: var(--sam-chat-muted); }
.sam-chat-input-container {
    padding: 20px;
    background: rgba(129, 140, 248, 0.04);
    border-top: 1px solid var(--sam-chat-border);
}

.sam-chat-input-wrapper {
    display: flex;
    gap: 10px;
    background: #ffffff;
    padding: 5px 5px 5px 15px;
    border-radius: 30px;
    border: 1px solid var(--sam-chat-border);
    transition: all 0.3s;
}

.sam-chat-input-wrapper:focus-within {
    border-color: var(--sam-chat-secondary);
    background: #ffffff;
}

.sam-chat-input-wrapper input {
    flex: 1;
    background: none;
    border: none;
    color: var(--sam-chat-text);
    font-size: 0.9rem;
    padding: 10px 0;
}

.sam-chat-input-wrapper input:focus {
    outline: none;
}

.sam-chat-send {
    width: 40px;
    height: 40px;
    background: var(--sam-chat-secondary);
    border: none;
    border-radius: 50%;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s;
}

.sam-chat-send:hover {
    transform: scale(1.1);
}

/* Quick Replies */
.sam-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.sam-btn-quick {
    background: rgba(129, 140, 248, 0.06);
    border: 1px solid var(--sam-chat-border);
    color: var(--sam-chat-muted);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s;
}

.sam-btn-quick:hover {
    background: var(--sam-chat-secondary);
    color: #ffffff;
    border-color: var(--sam-chat-secondary);
}

/* Mode Specific Adjustments */
.sam-chat-window.business {
    width: 420px; /* Business mode slightly wider for data */
}

/* Mobile Responsive */
@media (max-width: 500px) {
    .sam-chat-window {
        width: 90vw;
        right: -10px;
        bottom: 80px;
    }
}
