/* WP AI Chat - chat-widget.css */
#wpaichat-root { font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif; }

/* ---- テーマ変数（dark） ---- */
#wpaichat-root.theme-dark {
  --bg:      #111;
  --bg2:     #1a1a1a;
  --bg3:     #222;
  --border:  #2a2a2a;
  --text:    #e0e0e0;
  --text2:   #888;
  --user-bg: #1f1a10;
  --ai-bg:   #1a1a1a;
  --radius:  14px;
  --shadow:  0 8px 40px rgba(0,0,0,.6);
}
/* ---- テーマ変数（light） ---- */
#wpaichat-root.theme-light {
  --bg:      #fff;
  --bg2:     #f5f5f5;
  --bg3:     #ebebeb;
  --border:  #ddd;
  --text:    #1a1a1a;
  --text2:   #666;
  --user-bg: #fff8ec;
  --ai-bg:   #f5f5f5;
  --radius:  14px;
  --shadow:  0 8px 40px rgba(0,0,0,.15);
}

/* ---- アクセントカラー（JSから--accentで注入） ---- */
#wpaichat-root { --accent: #f5a623; --accent-d: #c07d10; }

/* ---- FAB ---- */
#wpaichat-fab {
  position: fixed;
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--accent);
  border: none; cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
  display: flex; align-items: center; justify-content: center;
  z-index: 99998;
  transition: transform .2s, box-shadow .2s;
  font-size: 26px;
}
#wpaichat-fab:hover { transform: scale(1.08); }
#wpaichat-fab .wpc-badge {
  position: absolute; top: -4px; right: -4px;
  background: #e24b4a; color: #fff;
  font-size: 11px; font-weight: 700;
  width: 18px; height: 18px; border-radius: 50%;
  display: none; align-items: center; justify-content: center;
}
#wpaichat-fab .wpc-badge.show { display: flex; }

/* ---- ウィンドウ ---- */
#wpaichat-win {
  position: fixed;
  width: 380px; max-width: calc(100vw - 40px);
  height: 580px; max-height: calc(100vh - 120px);
  min-width: 280px; min-height: 360px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: none; flex-direction: column;
  z-index: 99999; overflow: hidden;
  animation: wpc-in .25s ease;
}
#wpaichat-win.open { display: flex; }
@keyframes wpc-in {
  from { opacity:0; transform:translateY(16px) scale(.97); }
  to   { opacity:1; transform:translateY(0)    scale(1);   }
}

/* ---- リサイズハンドル ---- */
#wpaichat-resize {
  position: absolute; top: 0; left: 0;
  width: 22px; height: 22px; cursor: nw-resize; z-index: 10;
}
#wpaichat-resize::before {
  content: '';
  position: absolute; top: 5px; left: 5px;
  width: 10px; height: 10px;
  border-top: 2px solid #666; border-left: 2px solid #666;
  border-radius: 2px 0 0 0; opacity: .5; transition: opacity .15s;
}
#wpaichat-resize:hover::before { opacity: 1; }

/* ---- ヘッダー ---- */
#wpaichat-header {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 14px 16px; display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
#wpaichat-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
#wpaichat-header-text { flex: 1; }
#wpaichat-header-title { font-size: 14px; font-weight: 700; color: var(--text); }
#wpaichat-header-sub   { font-size: 11px; color: var(--text2); margin-top: 1px; }
#wpaichat-close {
  background: none; border: none; cursor: pointer;
  color: var(--text2); font-size: 20px; padding: 4px; border-radius: 4px; transition: color .15s;
}
#wpaichat-close:hover { color: var(--text); }

/* ---- 免責 ---- */
#wpaichat-disclaimer {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 8px 14px; font-size: 11px; color: var(--text2); line-height: 1.5; flex-shrink: 0;
}

/* ---- メッセージ ---- */
#wpaichat-messages {
  flex: 1; overflow-y: auto; padding: 16px 14px;
  display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth;
}
#wpaichat-messages::-webkit-scrollbar { width: 4px; }
#wpaichat-messages::-webkit-scrollbar-thumb { background: #444; border-radius: 2px; }

.wpc-msg { display: flex; gap: 8px; max-width: 90%; }
.wpc-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.wpc-msg.ai   { align-self: flex-start; }
.wpc-bubble {
  padding: 10px 14px; border-radius: 12px;
  font-size: 14px; line-height: 1.65; color: var(--text);
}
.wpc-msg.user .wpc-bubble { background: var(--user-bg); border: 1px solid var(--border); border-radius: 12px 2px 12px 12px; }
.wpc-msg.ai   .wpc-bubble { background: var(--ai-bg);   border: 1px solid var(--border); border-radius: 2px 12px 12px 12px; }
.wpc-icon {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; margin-top: 2px;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.wpc-msg.ai   .wpc-icon { background: var(--accent); }
.wpc-msg.user .wpc-icon { background: var(--bg3); }

/* ---- チップ ---- */
.wpc-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 14px 10px; flex-shrink: 0; }
.wpc-chip {
  padding: 7px 14px; border-radius: 99px;
  border: 1px solid var(--accent); color: var(--accent);
  background: transparent; cursor: pointer; font-size: 13px; transition: background .15s, color .15s;
}
.wpc-chip:hover { background: var(--accent); color: #111; }

/* ---- タイピング ---- */
.wpc-typing { display: flex; gap: 5px; align-items: center; padding: 4px 0; }
.wpc-typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--text2);
  animation: wpc-dot 1.2s infinite;
}
.wpc-typing span:nth-child(2) { animation-delay: .2s; }
.wpc-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes wpc-dot { 0%,80%,100%{transform:translateY(0)} 40%{transform:translateY(-5px)} }

/* ---- 入力 ---- */
#wpaichat-input-area {
  border-top: 1px solid var(--border); padding: 12px 14px;
  display: flex; gap: 8px; align-items: flex-end; flex-shrink: 0; background: var(--bg2);
}
#wpaichat-input {
  flex: 1; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text);
  font-size: 14px; padding: 9px 12px; resize: none; outline: none;
  line-height: 1.5; max-height: 100px; overflow-y: auto; font-family: inherit; transition: border-color .15s;
}
#wpaichat-input::placeholder { color: var(--text2); }
#wpaichat-input:focus { border-color: var(--accent); }
#wpaichat-send {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--accent); border: none; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; transition: opacity .15s;
  font-size: 18px;
}
#wpaichat-send:hover { opacity: .85; }
#wpaichat-send:disabled { opacity: .3; cursor: default; }

/* ---- フッター ---- */
#wpaichat-footer {
  padding: 6px 14px 10px; display: flex; flex-wrap: wrap;
  justify-content: center; align-items: center; gap: 8px; flex-shrink: 0;
}
#wpaichat-footer button {
  background: none; border: none; cursor: pointer;
  font-size: 12px; color: var(--text2); padding: 2px 4px; transition: color .15s;
}
#wpaichat-footer button:hover { color: var(--text); }
.wpc-cta-link {
  font-size: 12px; color: var(--accent); text-decoration: none;
  padding: 3px 10px; border: 1px solid var(--accent);
  border-radius: 99px; transition: background .15s, color .15s;
}
.wpc-cta-link:hover { background: var(--accent); color: #111; }

/* ---- エスカレーション ---- */
#wpaichat-esc-form {
  padding: 14px; display: none; flex-direction: column; gap: 10px;
  flex-shrink: 0; background: var(--bg2); border-top: 1px solid var(--border);
}
#wpaichat-esc-form.show { display: flex; }
#wpaichat-esc-form input {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 9px 12px; font-size: 14px; outline: none; font-family: inherit;
}
#wpaichat-esc-form input:focus { border-color: var(--accent); }
#wpaichat-esc-title { font-size: 13px; font-weight: 600; color: var(--text); }
#wpaichat-esc-sub   { font-size: 12px; color: var(--text2); }
#wpaichat-esc-submit {
  padding: 10px; background: var(--accent); color: #111;
  border: none; border-radius: 8px; font-size: 14px; font-weight: 700; cursor: pointer;
}

/* ---- スマホ ---- */
@media (max-width: 480px) {
  #wpaichat-win { right: 12px !important; width: calc(100vw - 24px) !important; }
}
