/**
 * ai-chat-bridge.css
 * V2898 [22-A] AIチャット橋渡し スタイル
 * PC: 右カラム / SP: 右下フロートバブル (Intercom型)
 */

/* ========== コンテナ ========== */
#aiCbContainer {
  position: fixed;
  z-index: 9990;
  background: #fff;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "メイリオ", sans-serif;
  transition: all 0.3s ease;
}

/* V2915 [44] PC layout: フロート/バブル絶対禁止・右カラム固定表示のみ */
@media (min-width: 1024px) {
  #aiCbContainer {
    position: fixed;
    top: 100px;
    right: 24px;
    width: 380px;
    height: calc(100vh - 140px);
    max-height: 720px;
  }
  #aiCbContainer.ai-cb-collapsed {
    /* V2915: PC時は collapse 状態でも表示禁止 (バブルになりかけ防止) */
    display: none !important;
  }
  /* V2915: PC時バブル絶対禁止 */
  #aiCbBubble,
  #aiCbBadge {
    display: none !important;
  }
}

/* V2915 [44] SP layout: CV1後のみフロート起動・CTA/ランキング阻害禁止 */
@media (max-width: 1023px) {
  #aiCbContainer {
    /* V2915: 上部 100px から → 80px に縮小・CTA エリア確保 */
    bottom: 88px; /* 下部CTAバナー領域を回避 */
    right: 12px;
    width: calc(100vw - 24px);
    max-width: 340px;
    height: 60vh;
    max-height: 460px;
    z-index: 9990;
  }
  #aiCbContainer.ai-cb-collapsed {
    display: none;
  }
  #aiCbBubble {
    position: fixed;
    /* V2915: バブル位置を CTA 阻害しないよう調整 */
    bottom: 84px; /* 下部CTAバナーの上 */
    right: 12px;
    width: 52px; /* 控えめサイズ (60→52) */
    height: 52px;
    border-radius: 50%;
    background: #2563EB;
    color: #fff;
    box-shadow: 0 4px 12px rgba(37,99,235,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9989;
    cursor: pointer;
    border: none;
    font-size: 24px;
    opacity: 0.92;
  }
  #aiCbContainer.ai-cb-open ~ #aiCbBubble {
    display: none;
  }
}

/* ========== ヘッダー ========== */
.ai-cb-header {
  background: linear-gradient(135deg, #1E40AF, #2563EB);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: bold;
  font-size: 14px;
  flex-shrink: 0;
}
.ai-cb-header img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  object-fit: cover;
  background-size: cover;
  background-position: center;
}
.ai-cb-header .ai-cb-title {
  flex: 1;
  line-height: 1.3;
}
.ai-cb-header .ai-cb-subtitle {
  font-size: 11px;
  opacity: 0.85;
  font-weight: normal;
}
.ai-cb-header .ai-cb-close {
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.ai-cb-header .ai-cb-close:hover { background: rgba(255,255,255,0.35); }

/* ========== メッセージエリア ========== */
.ai-cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  background: #F8FAFC;
  scroll-behavior: smooth;
}
.ai-cb-row {
  display: flex;
  margin-bottom: 12px;
  align-items: flex-end;
  gap: 8px;
  animation: aiCbFadeIn 0.3s ease;
}
.ai-cb-row-bot { justify-content: flex-start; }
.ai-cb-row-user { justify-content: flex-end; }
.ai-cb-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #ddd;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}
.ai-cb-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  max-width: 75%;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}
.ai-cb-bubble-bot {
  background: #fff;
  color: #1F2937;
  border: 1px solid #E5E7EB;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.ai-cb-bubble-user {
  background: #2563EB;
  color: #fff;
  border-bottom-right-radius: 4px;
}

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

/* ========== ボタンエリア ========== */
.ai-cb-buttons-row {
  margin-top: 4px;
}
.ai-cb-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.ai-cb-btn {
  background: #fff;
  color: #2563EB;
  border: 1.5px solid #2563EB;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  font-family: inherit;
  line-height: 1.4;
}
.ai-cb-btn:hover { background: #EFF6FF; transform: translateY(-1px); }
.ai-cb-btn:active { transform: translateY(0); }
.ai-cb-btn-primary {
  background: linear-gradient(135deg, #DC2626, #EF4444);
  color: #fff;
  border-color: transparent;
  font-size: 15px;
  padding: 14px 18px;
  font-weight: bold;
  box-shadow: 0 4px 12px rgba(239,68,68,0.3);
  text-align: center;
}
.ai-cb-btn-primary:hover { background: linear-gradient(135deg, #B91C1C, #DC2626); }
.ai-cb-btn-sub {
  background: transparent;
  color: #6B7280;
  border-color: #D1D5DB;
  font-size: 12px;
  padding: 8px 12px;
  text-align: center;
}
.ai-cb-btn-sub:hover { background: #F3F4F6; }

/* ========== 通知バッジ (SP) ========== */
.ai-cb-bubble-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #DC2626;
  color: #fff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 11px;
  font-weight: bold;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  border: 2px solid #fff;
}
