/* ══════════════════════════════════════
   ai-consultant.css — 長照 AI 顧問
   ══════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Noto Sans TC', system-ui, sans-serif;
  background: #F8FAFC; color: #1E293B;
  display: flex; flex-direction: column; height: 100%;
}

/* ── Shell ── */
.ai-shell { display: flex; flex: 1; overflow: hidden; }

/* ── Sidebar ── */
.ai-sidebar {
  width: 260px; flex-shrink: 0;
  background: #1E293B; color: #CBD5E1;
  display: flex; flex-direction: column;
  border-right: 1px solid #334155;
}
.ai-sidebar-top {
  padding: 1rem;
  border-bottom: 1px solid #334155;
}
.ai-new-btn {
  width: 100%; padding: .7rem 1rem;
  background: #4F7EFF; color: #fff; border: none;
  border-radius: .625rem; font-family: inherit;
  font-size: .9rem; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; gap: .5rem;
  transition: background .15s;
}
.ai-new-btn:hover { background: #3B6FEE; }
.ai-sidebar-brand { padding: .875rem 1rem .5rem; }
.ai-sidebar-brand strong { display: block; color: #fff; font-size: .9rem; }
.ai-sidebar-brand small { font-size: .75rem; color: #94A3B8; }

.ai-sidebar-section { padding: .75rem 1rem .4rem; }
.ai-sidebar-section-label {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
  color: #64748B; font-weight: 700; margin-bottom: .5rem;
}
.ai-topic-chip {
  display: block; width: 100%;
  padding: .55rem .75rem; background: none; border: none;
  font-family: inherit; font-size: .8125rem; color: #94A3B8;
  text-align: left; cursor: pointer; border-radius: .5rem;
  transition: background .12s, color .12s; line-height: 1.35;
  margin-bottom: .2rem;
}
.ai-topic-chip:hover { background: #334155; color: #fff; }
.ai-topic-chip.active { background: #334155; color: #fff; }

.ai-sidebar-bottom {
  margin-top: auto; padding: .875rem 1rem;
  border-top: 1px solid #334155; font-size: .75rem; color: #64748B;
}
.ai-sidebar-bottom a { color: #4F7EFF; text-decoration: none; }

/* ── Main area ── */
.ai-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* Topbar */
.ai-topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .875rem 1.5rem;
  background: #fff; border-bottom: 1px solid #E2E8F0;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  flex-shrink: 0;
}
.ai-topbar-back { color: #4F7EFF; text-decoration: none; font-size: .875rem; font-weight: 500; }
.ai-topbar-back:hover { text-decoration: underline; }
.ai-topbar-title { flex: 1; font-weight: 700; font-size: 1rem; }
.ai-topbar-model {
  font-size: .75rem; color: #94A3B8;
  background: #F1F5F9; padding: .25rem .6rem; border-radius: 99px;
}

/* Messages area */
.ai-messages {
  flex: 1; overflow-y: auto; padding: 1.5rem;
  display: flex; flex-direction: column; gap: 1.25rem;
  scroll-behavior: smooth;
}

/* Message bubbles */
.ai-msg { display: flex; gap: .875rem; max-width: 760px; }
.ai-msg.user { flex-direction: row-reverse; margin-left: auto; }

.ai-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.125rem; flex-shrink: 0; margin-top: .1rem;
}
.ai-msg.assistant .ai-avatar { background: linear-gradient(135deg,#4F7EFF,#7C3AED); }
.ai-msg.user .ai-avatar      { background: #E2E8F0; }

.ai-bubble {
  flex: 1; padding: .875rem 1.1rem; border-radius: 1rem;
  line-height: 1.65; font-size: .9375rem; max-width: 620px;
}
.ai-msg.assistant .ai-bubble {
  background: #fff; border: 1px solid #E2E8F0;
  border-radius: .25rem 1rem 1rem 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.ai-msg.user .ai-bubble {
  background: #4F7EFF; color: #fff;
  border-radius: 1rem .25rem 1rem 1rem;
}

/* Markdown in bubbles */
.ai-bubble h3 { font-size: 1rem; font-weight: 700; margin: .75rem 0 .35rem; color: #1E293B; }
.ai-bubble h3:first-child { margin-top: 0; }
.ai-bubble p  { margin-bottom: .6rem; }
.ai-bubble p:last-child { margin-bottom: 0; }
.ai-bubble ul, .ai-bubble ol { padding-left: 1.25rem; margin-bottom: .6rem; }
.ai-bubble li { margin-bottom: .25rem; }
.ai-bubble strong { font-weight: 700; color: #1E293B; }
.ai-bubble code  { background: #F1F5F9; padding: .1rem .3rem; border-radius: .25rem; font-size: .85em; }
.ai-bubble table { border-collapse: collapse; width: 100%; margin: .75rem 0; font-size: .875rem; }
.ai-bubble th, .ai-bubble td { padding: .4rem .7rem; border: 1px solid #E2E8F0; text-align: left; }
.ai-bubble th { background: #F8FAFC; font-weight: 700; color: #475569; }
.ai-bubble hr { border: none; border-top: 1px solid #E2E8F0; margin: .75rem 0; }

/* Action buttons inside bubble */
.ai-actions-wrap { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .875rem; }
.ai-action-btn {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .45rem .9rem; border-radius: .5rem;
  font-size: .8125rem; font-weight: 700; text-decoration: none;
  border: 1.5px solid #4F7EFF; color: #4F7EFF; background: #EEF2FF;
  transition: all .15s; cursor: pointer;
}
.ai-action-btn:hover { background: #4F7EFF; color: #fff; }
.ai-action-btn.primary { background: #4F7EFF; color: #fff; }
.ai-action-btn.primary:hover { background: #3B6FEE; }

/* Typing indicator */
.ai-typing { display: flex; gap: .875rem; align-items: flex-start; }
.ai-typing .ai-avatar { background: linear-gradient(135deg,#4F7EFF,#7C3AED); }
.ai-typing-bubble {
  background: #fff; border: 1px solid #E2E8F0;
  border-radius: .25rem 1rem 1rem 1rem;
  padding: .875rem 1.1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.ai-typing-dots { display: flex; gap: .35rem; }
.ai-typing-dots span {
  width: 8px; height: 8px; border-radius: 50%;
  background: #94A3B8; animation: aiDot 1.4s ease infinite;
}
.ai-typing-dots span:nth-child(2) { animation-delay: .2s; }
.ai-typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes aiDot { 0%,60%,100%{opacity:.3;transform:scale(1)} 30%{opacity:1;transform:scale(1.2)} }

/* Welcome screen */
.ai-welcome {
  max-width: 600px; margin: 0 auto; text-align: center;
  padding: 2rem 1rem 1rem;
}
.ai-welcome-icon { font-size: 3rem; margin-bottom: .75rem; }
.ai-welcome h2  { font-size: 1.625rem; font-weight: 900; margin-bottom: .5rem; }
.ai-welcome p   { color: #64748B; line-height: 1.6; margin-bottom: 1.5rem; }
.ai-welcome-chips { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.ai-start-chip {
  padding: .55rem 1rem; border: 2px solid #E2E8F0;
  border-radius: 99px; background: #fff;
  font-family: inherit; font-size: .875rem; font-weight: 500; color: #475569;
  cursor: pointer; transition: all .15s;
}
.ai-start-chip:hover { border-color: #4F7EFF; color: #4F7EFF; background: #EEF2FF; }

/* Error / setup notice */
.ai-notice {
  background: #FEF3C7; border: 1.5px solid #FDE68A; border-radius: .875rem;
  padding: 1rem 1.25rem; font-size: .875rem; color: #92400E; line-height: 1.6;
}
.ai-notice strong { display: block; font-size: 1rem; margin-bottom: .3rem; }
.ai-notice code { background: #FDE68A; padding: .1rem .4rem; border-radius: .25rem; font-size: .8rem; }

/* Input area */
.ai-input-area {
  background: #fff; border-top: 1px solid #E2E8F0;
  padding: 1rem 1.5rem; flex-shrink: 0;
}
.ai-input-row {
  display: flex; gap: .75rem; align-items: flex-end;
  background: #F8FAFC; border: 2px solid #E2E8F0; border-radius: .875rem;
  padding: .6rem .6rem .6rem 1rem;
  transition: border-color .2s;
}
.ai-input-row:focus-within { border-color: #4F7EFF; }
.ai-input {
  flex: 1; border: none; background: transparent;
  font-family: inherit; font-size: .9375rem; color: #1E293B;
  resize: none; line-height: 1.5; max-height: 180px;
  overflow-y: auto; outline: none;
}
.ai-input::placeholder { color: #94A3B8; }
.ai-send-btn {
  flex-shrink: 0; width: 38px; height: 38px;
  background: #4F7EFF; color: #fff; border: none;
  border-radius: .5rem; cursor: pointer; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.ai-send-btn:hover { background: #3B6FEE; }
.ai-send-btn:disabled { background: #CBD5E1; cursor: not-allowed; }
.ai-input-footer {
  display: flex; justify-content: space-between;
  font-size: .75rem; color: #94A3B8; margin-top: .4rem; padding: 0 .25rem;
}

/* Subsidy highlight box (inside bubble) */
.ai-subsidy-box {
  background: linear-gradient(135deg,#EEF2FF,#F5F3FF);
  border: 1px solid #C7D2FE; border-radius: .625rem;
  padding: .75rem 1rem; margin: .75rem 0;
}
.ai-subsidy-box .row { display: flex; justify-content: space-between; font-size: .875rem; padding: .2rem 0; }
.ai-subsidy-box .row .label { color: #6366F1; }
.ai-subsidy-box .row .val   { font-weight: 700; color: #1E293B; }
.ai-subsidy-box .row.total  { border-top: 1px solid #C7D2FE; margin-top: .35rem; padding-top: .4rem; font-size: 1rem; }

/* Mobile */
@media (max-width: 700px) {
  .ai-sidebar { display: none; }
  .ai-messages { padding: 1rem; }
  .ai-input-area { padding: .75rem 1rem; }
}
