/* ============================================================
   Welcart Chat – フロントエンド
   オオツカ熱帯魚カラー:
     プライマリブルー : #3D97DF
     ダークブルー     : #2878BB
     白ベース         : #ffffff
     ライトブルー     : #EBF5FC
     ボーダー         : #BDD9F0
     テキスト         : #2c3e50
   ============================================================ */

:root {
  --wcc-primary:    #3D97DF;
  --wcc-primary-dk: #2878BB;
  --wcc-white:      #ffffff;
  --wcc-bg:         #ffffff;
  --wcc-surface:    #EBF5FC;
  --wcc-surface2:   #D5EBF8;
  --wcc-border:     #BDD9F0;
  --wcc-text:       #2c3e50;
  --wcc-muted:      #7a99b0;
  --wcc-you-bg:     #3D97DF;
  --wcc-you-txt:    #ffffff;
  --wcc-staff-bg:   #EBF5FC;
  --wcc-staff-txt:  #2c3e50;
  --wcc-danger:     #e74c3c;
  --wcc-shadow:     0 8px 32px rgba(61,151,223,.18), 0 2px 8px rgba(61,151,223,.08);
  --wcc-radius-lg:  14px;
  --wcc-radius-msg: 12px;
  --wcc-sz:         54px;
  --wcc-z:          99999;
}

#wcc-launcher *, #wcc-window * { box-sizing: border-box; }

/* ============================================================
   ランチャーボタン
   ============================================================ */
#wcc-launcher {
  position:        fixed;
  bottom:          100px;
  right:           28px;
  width:           var(--wcc-sz);
  height:          var(--wcc-sz);
  border-radius:   50%;
  background:      var(--wcc-primary);
  color:           var(--wcc-white);
  display:         flex;
  align-items:     center;
  justify-content: center;
  cursor:          pointer;
  box-shadow:      0 4px 16px rgba(61,151,223,.50);
  transition:      transform .18s ease, background .18s ease, box-shadow .18s;
  z-index:         var(--wcc-z);
  -webkit-tap-highlight-color: transparent;
  user-select:     none;
}
#wcc-launcher:hover {
  background:  var(--wcc-primary-dk);
  transform:   scale(1.07);
  box-shadow:  0 6px 22px rgba(61,151,223,.60);
}
#wcc-launcher:focus {
  outline:        3px solid rgba(61,151,223,.45);
  outline-offset: 3px;
}
#wcc-launcher:active { transform: scale(.93); }

.wcc-launcher-icon { width: 26px; height: 26px; }

/* ---- 未読バッジ ---- */
.wcc-badge {
  position:       absolute;
  top:            1px; right: 1px;
  min-width:      19px; height: 19px;
  padding:        0 4px;
  border-radius:  10px;
  background:     #e74c3c;
  color:          #fff;
  font:           bold 11px/19px system-ui, sans-serif;
  text-align:     center;
  border:         2px solid var(--wcc-white);
  pointer-events: none;
  animation:      wcc-pop .18s ease;
}
@keyframes wcc-pop {
  from { transform: scale(.3); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}

/* ============================================================
   チャットウィンドウ
   ============================================================ */
#wcc-window {
  position:       fixed;
  bottom:         166px; right: 22px;
  width:          355px;
  max-height:     565px;
  border-radius:  var(--wcc-radius-lg);
  background:     var(--wcc-bg);
  box-shadow:     var(--wcc-shadow);
  display:        flex;
  flex-direction: column;
  overflow:       hidden;
  z-index:        calc(var(--wcc-z) - 1);
  animation:      wcc-slide-up .2s ease;
  border:         1px solid var(--wcc-border);
}
#wcc-window[hidden] { display: none !important; }

@keyframes wcc-slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- ヘッダー ---- */
.wcc-header {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding:         12px 16px;
  background:      var(--wcc-primary);
  color:           var(--wcc-white);
  flex-shrink:     0;
}
.wcc-header-info  { display: flex; align-items: center; gap: 9px; }
.wcc-header-dot   {
  width: 8px; height: 8px; border-radius: 50%;
  background: #7fe8a2;
  box-shadow: 0 0 0 2px rgba(127,232,162,.3);
}
.wcc-header-title {
  font-weight:    700;
  font-size:      14px;
  letter-spacing: .02em;
}
.wcc-icon-btn {
  background: none; border: none;
  color: rgba(255,255,255,.75);
  cursor: pointer; padding: 4px; border-radius: 5px;
  display: flex; align-items: center;
  transition: color .12s, background .12s;
}
.wcc-icon-btn:hover  { color: #fff; background: rgba(255,255,255,.18); }
.wcc-icon-btn svg    { width: 19px; height: 19px; }

/* ---- イントロ画面 ---- */
.wcc-intro {
  padding:        26px 22px 20px;
  display:        flex;
  flex-direction: column;
  align-items:    center;
  gap:            10px;
  overflow-y:     auto;
  flex:           1;
  background:     var(--wcc-surface);
}
.wcc-intro-avatar {
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--wcc-primary);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 12px rgba(61,151,223,.35);
}
.wcc-intro-avatar svg { width: 32px; height: 32px; color: rgba(255,255,255,.95); }
.wcc-intro-greeting   { font-size: 16px; font-weight: 700; color: var(--wcc-primary-dk); margin: 0; }
.wcc-intro-sub        { font-size: 12px; color: var(--wcc-muted); margin: 0; text-align: center; line-height: 1.65; }
.wcc-intro-fields     { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.wcc-field {
  width: 100%; padding: 9px 13px;
  border: 1px solid var(--wcc-border); border-radius: 7px;
  font-size: 14px; background: var(--wcc-white);
  outline: none; transition: border-color .18s, box-shadow .18s;
  font-family: inherit; color: var(--wcc-text);
}
.wcc-field:focus {
  border-color: var(--wcc-primary);
  box-shadow: 0 0 0 3px rgba(61,151,223,.15);
}
.wcc-start-btn {
  width: 100%; padding: 11px;
  background: var(--wcc-primary);
  color: var(--wcc-white);
  border: none; border-radius: 7px;
  font-size: 14px; font-weight: 700; cursor: pointer;
  box-shadow: 0 3px 10px rgba(61,151,223,.35);
  transition: background .18s, transform .1s;
  margin-top: 2px;
}
.wcc-start-btn:hover  { background: var(--wcc-primary-dk); }
.wcc-start-btn:active { transform: scale(.97); }

/* ---- チャット本体 ---- */
.wcc-body { display: flex; flex-direction: column; flex: 1; overflow: hidden; min-height: 0; }
.wcc-body[hidden] { display: none !important; }

/* メッセージリスト */
.wcc-messages {
  flex: 1; overflow-y: auto; padding: 14px 12px;
  display: flex; flex-direction: column; gap: 8px;
  scroll-behavior: smooth;
  background: var(--wcc-white);
}
.wcc-messages::-webkit-scrollbar { width: 4px; }
.wcc-messages::-webkit-scrollbar-track { background: transparent; }
.wcc-messages::-webkit-scrollbar-thumb { background: var(--wcc-surface2); border-radius: 2px; }

.wcc-bubble-wrap { display: flex; flex-direction: column; max-width: 80%; }
.wcc-bubble-wrap.you   { align-self: flex-end;   align-items: flex-end; }
.wcc-bubble-wrap.staff { align-self: flex-start; }

.wcc-bubble {
  padding: 9px 13px;
  border-radius: var(--wcc-radius-msg);
  font-size: 14px; line-height: 1.6;
  word-break: break-word; white-space: pre-wrap;
}
.wcc-bubble-wrap.you .wcc-bubble {
  background: var(--wcc-primary);
  color: var(--wcc-you-txt);
  border-bottom-right-radius: 3px;
  box-shadow: 0 2px 6px rgba(61,151,223,.25);
}
.wcc-bubble-wrap.staff .wcc-bubble {
  background: var(--wcc-staff-bg);
  color: var(--wcc-staff-txt);
  border-bottom-left-radius: 3px;
  border: 1px solid var(--wcc-border);
}
.wcc-bubble-meta { font-size: 10px; color: var(--wcc-muted); margin-top: 3px; padding: 0 3px; }

.wcc-system-msg {
  align-self: flex-start;
  font-size: 11px; color: var(--wcc-muted);
  background: var(--wcc-surface);
  padding: 6px 14px; border-radius: 12px;
  border: 1px solid var(--wcc-border);
  margin: 3px 0;
  line-height: 1.7;
  text-align: left;
  max-width: 90%;
}
.wcc-system-msg a {
  color: var(--wcc-primary-dk);
  text-decoration: underline;
}

/* ---- フッター ---- */
.wcc-footer {
  display: flex; align-items: flex-end; gap: 7px;
  padding: 8px 10px 11px;
  border-top: 1px solid var(--wcc-surface2);
  background: var(--wcc-white);
  flex-shrink: 0;
}
.wcc-textarea {
  flex: 1; resize: none;
  border: 1px solid var(--wcc-border); border-radius: 10px;
  padding: 8px 11px; font-size: 14px; line-height: 1.45;
  font-family: inherit; max-height: 120px; overflow-y: auto;
  outline: none; transition: border-color .18s, box-shadow .18s;
  color: var(--wcc-text);
  background: var(--wcc-white);
}
.wcc-textarea:focus {
  border-color: var(--wcc-primary);
  box-shadow: 0 0 0 3px rgba(61,151,223,.12);
}
.wcc-send-btn {
  width: 37px; height: 37px; border-radius: 50%;
  background: var(--wcc-primary);
  color: var(--wcc-white); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(61,151,223,.4);
  transition: background .18s, transform .1s;
}
.wcc-send-btn:hover  { background: var(--wcc-primary-dk); }
.wcc-send-btn:active { transform: scale(.90); }
.wcc-send-btn svg    { width: 17px; height: 17px; }

/* ============================================================
   モバイル
   ============================================================ */
@media (max-width: 480px) {
  #wcc-window {
    width: 100%; right: 0; bottom: 0;
    border-radius: var(--wcc-radius-lg) var(--wcc-radius-lg) 0 0;
    max-height: 85dvh;
  }
  #wcc-launcher { bottom: 72px; right: 16px; }
}

/* ランチャー：初期は非表示、JS で display:flex → フェードイン */
@keyframes wcc-launcher-in {
  from { opacity: 0; transform: scale(.6); }
  to   { opacity: 1; transform: scale(1); }
}
#wcc-launcher.wcc-launcher-visible {
  animation: wcc-launcher-in .35s cubic-bezier(.34,1.56,.64,1) forwards;
}

/* ============================================================
   吹き出し（コールアウト）
   ============================================================ */
.wcc-callout {
  position:      absolute;
  bottom:        calc(100% + 10px);
  right:         0;
  width:         210px;
  background:    #fff;
  border:        1px solid var(--wcc-border);
  border-radius: 12px;
  padding:       12px 32px 12px 14px;
  box-shadow:    0 4px 16px rgba(61,151,223,.18);
  font-size:     12px;
  line-height:   1.65;
  color:         var(--wcc-text);
  pointer-events: auto;
  animation:     wcc-callout-in .3s ease;
}
.wcc-callout[hidden] { display: none !important; }

@keyframes wcc-callout-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 吹き出しの三角 */
.wcc-callout::after {
  content:      '';
  position:     absolute;
  bottom:       -8px;
  right:        20px;
  border:       8px solid transparent;
  border-bottom: none;
  border-top-color: #fff;
  filter:       drop-shadow(0 2px 1px rgba(61,151,223,.15));
}
.wcc-callout::before {
  content:      '';
  position:     absolute;
  bottom:       -9px;
  right:        19px;
  border:       9px solid transparent;
  border-bottom: none;
  border-top-color: var(--wcc-border);
}

.wcc-callout p {
  margin: 0 0 4px;
  font-size: 12px;
}
.wcc-callout p:last-of-type { margin-bottom: 0; }
.wcc-callout p:first-child {
  font-weight: 700;
  color: var(--wcc-primary);
}

/* 吹き出し閉じるボタン */
.wcc-callout-close {
  position:   absolute;
  top:        6px; right: 8px;
  background: none; border: none;
  color:      var(--wcc-muted);
  font-size:  12px; line-height: 1;
  cursor:     pointer; padding: 2px;
  border-radius: 4px;
  transition: color .15s;
}
.wcc-callout-close:hover { color: var(--wcc-text); }


.wcc-status-banner {
  display:      flex;
  align-items:  flex-start;
  gap:          7px;
  padding:      8px 14px;
  background:   #fff8e6;
  border-bottom: 1px solid #f0d080;
  color:        #7a5800;
  font-size:    12px;
  line-height:  1.6;
  flex-shrink:  0;
}
.wcc-status-banner[hidden] { display: none !important; }

/* ヘッダードット: 営業時間外はオレンジ */
.wcc-header-dot--away {
  background: #f0a030 !important;
  box-shadow: 0 0 0 2px rgba(240,160,48,.3) !important;
  animation:  none !important;
}
