/* ===== CapSource brand tokens ===== */
:root{
  --cs-orange-600:#e05e32;
  --cs-orange-500:#f0922b;
  --cs-saffron-400:#f7b267;
  --ink-950:#0b0d12;
  --ink-900:#111827;
  --ink-800:#1f2937;
  --ink-700:#374151;
  --paper:#0f1117;          /* dark card bg */
  --paper-2:#141823;
  --text:#e5e7eb;
  --muted:#9ca3af;
  --ring:#93c5fd;
  --radius:16px;
  --shadow:0 12px 38px rgba(0,0,0,.35);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color:var(--text);
  background: radial-gradient(1000px 600px at 100% 0%, #1b202f 0%, #0e111a 40%, #0b0d12 100%);
}

/* ===== App shell variants ===== */
.capchat{
  /* container for both modes */
}

/* ---------- FULLSCREEN MODE ---------- */
.capchat--full{
  display:grid;
  grid-template-rows:auto 1fr auto;
  min-height:100dvh;
}

.full-nav{
  position:sticky; top:0; z-index:40;
  backdrop-filter: blur(8px);
  background: color-mix(in srgb, var(--paper) 80%, transparent);
  border-bottom:1px solid #202634;
}
.full-nav-inner{
  max-width:1100px; margin:0 auto; padding:14px 16px;
  display:flex; align-items:center; gap:14px; justify-content:space-between;
}
.brand{
  display:flex; align-items:center; gap:10px; text-decoration:none; color:var(--text);
}
.brand img{ height:28px; border-radius:8px }
.brand span{ font-weight:700; letter-spacing:.2px }

.full-main{
  max-width:1100px; margin:0 auto; padding:24px 16px 28px;
  display:grid; grid-template-columns: 1fr; gap:18px;
}
@media (min-width: 960px){
  .full-main{ grid-template-columns: 420px 1fr }
}

.sidebar-card{
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%);
  border:1px solid #1f2533; border-radius: var(--radius); box-shadow: var(--shadow);
  padding:18px;
}
.sidebar-title{ font-weight:700; font-size:14px; color:#cbd5e1; text-transform:uppercase; letter-spacing:.08em; }
.sidebar-meta{ color:var(--muted); font-size:13px; margin-top:8px; line-height:1.4 }

/* ---------- WIDGET MODE ---------- */
.capchat-launcher{
  position:fixed; right:20px; bottom:20px; z-index:9999;
}
.launch-btn{
  height:52px; width:52px; border-radius:50%;
  background: linear-gradient(135deg, var(--cs-orange-600), var(--cs-orange-500));
  border:none; color:white; font-size:24px; cursor:pointer; box-shadow: var(--shadow);
  display:grid; place-items:center;
}
.launch-btn:focus{ outline:none; box-shadow:0 0 0 3px var(--ring) }

/* Drawer */
.capchat-drawer{
  position:fixed; right:20px; bottom:20px; z-index:10000;
  width:360px; max-width:calc(100vw - 24px);
  height:520px; max-height:calc(100dvh - 24px);
  transform: translateY(16px) scale(.98);
  opacity:0; pointer-events:none;
  transition: .18s ease-in-out;
}
.capchat-drawer.open{ opacity:1; transform: translateY(0) scale(1); pointer-events:auto }

.chat-container{
  height:100%; display:flex; flex-direction:column;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%);
  border:1px solid #1f2533; box-shadow: var(--shadow);
  overflow:hidden;
}

/* Shared header/body/footer for both modes */
.chat-header{
  display:flex; align-items:center; gap:10px; justify-content:space-between;
  padding:12px 14px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--cs-orange-600) 80%, #000 20%), var(--cs-orange-500));
  border-bottom:1px solid #361b12;
}
.header-left{ display:flex; align-items:center; gap:10px }
.header-left img{ height:22px; border-radius:6px }
.header-left h3{ margin:0; font-size:15px; letter-spacing:.3px }
.reset-button, .close-button{
  background:transparent; border:1px solid #ffffff40; color:white; border-radius:10px;
  padding:6px 10px; font-size:12px; cursor:pointer;
}
.close-button{ margin-left:8px }

.chat-body{
  padding:14px; overflow:auto; height:100%;
  scrollbar-width: thin; scrollbar-color:#2d3547 transparent;
}
.chat-body::-webkit-scrollbar{ width:6px }
.chat-body::-webkit-scrollbar-track{ background:transparent }
.chat-body::-webkit-scrollbar-thumb{ background:#2d3547; border-radius:3px }
.chat-body::-webkit-scrollbar-thumb:hover{ background:#3d4a62 }
.messages-container{ display:flex; flex-direction:column; gap:10px }

/* bubbles */
.message{ max-width:85% }
.message.bot{
  align-self:flex-start;
  background: linear-gradient(135deg, #0f1a25 0%, #142030 100%);
  border:1px solid #203246;
  color:#dbeafe;
  padding:14px 16px;
  border-radius:14px;
  box-shadow: inset 0 1px 0 #ffffff0a, 0 2px 8px rgba(0,0,0,0.15);
  line-height: 1.6;
  font-size: 14px;
}
.message.bot strong{
  color: #f7b267;
  font-weight: 600;
}
.message.bot em{
  color: #93c5fd;
  font-style: italic;
}
.message.bot a{
  color: #60a5fa;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.message.bot a:hover{
  color: #93c5fd;
}
.message.user{
  align-self:flex-end;
  background: linear-gradient(135deg, var(--cs-orange-600), var(--cs-orange-500));
  color:white;
  padding:14px 16px;
  border-radius:14px 14px 2px 14px;
  line-height: 1.5;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(224, 94, 50, 0.3);
}
.message.typing{ opacity:.8; font-style:italic }

/* Typing cursor animation */
.typing-cursor{
  display: inline;
  animation: blink 0.7s infinite;
  color: var(--cs-orange-500);
  font-weight: 300;
}
@keyframes blink{
  0%, 50%{ opacity: 1; }
  51%, 100%{ opacity: 0; }
}

.feedback-buttons{ display:flex; gap:6px; margin:-4px 0 2px 2px }
.feedback-buttons button{
  height:28px; width:32px; border-radius:10px; border:1px solid #2a3245; background:#121a28; color:#cbd5e1; cursor:pointer;
}
.feedback-buttons button:hover{ background:#1a2335 }
.feedback-buttons button:disabled:hover{ background:#121a28 }
.feedback-thanks{ color:var(--muted); font-size:11px; margin-left:4px; align-self:center }

/* inputs */
.chat-footer{
  padding:10px; border-top:1px solid #1f2533; background: #0e131e; display:flex; gap:10px; align-items: flex-end;
}
.chat-input{
  flex:1; border:1px solid #283046; border-radius:14px; padding:10px 12px;
  background:#0c1220; color:#e5e7eb; outline:none;
  resize: none;
  min-height: 42px;
  overflow: hidden;
  line-height: 1.4;
  font-family: inherit;
  font-size: 14px;
}
.chat-input:focus{ box-shadow:0 0 0 2px var(--ring) }
.send-button{
  width:42px; height:42px; border-radius:12px; border:none; cursor:pointer; color:white;
  background: linear-gradient(135deg, var(--cs-orange-600), var(--cs-orange-500));
}

/* dropdown inside bot bubble */
.dropdown{
  margin-top:8px; width:100%; background:#0c1220; color:#e5e7eb;
  border:1px solid #283046; border-radius:10px; padding:8px 10px; outline:none;
}
.dropdown:focus{ box-shadow:0 0 0 2px var(--ring) }

/* ---------- FULLSCREEN chat panel ---------- */
.full-chat{
  min-height:520px;
}
.full-card{
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%);
  border:1px solid #1f2533; box-shadow: var(--shadow);
  overflow:hidden; display:flex; flex-direction:column;
}

/* ---------- WELCOME BACK BANNER ---------- */
.welcome-back-banner{
  background: linear-gradient(135deg, #1a2332 0%, #0f1a25 100%);
  border: 1px solid #2d4a6a;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.welcome-back-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.welcome-back-header span{
  font-weight: 600;
  color: #93c5fd;
}
.toggle-history-btn{
  background: transparent;
  border: 1px solid #3b82f6;
  color: #60a5fa;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.toggle-history-btn:hover{
  background: #1e3a5f;
}

/* ---------- HISTORY PANEL ---------- */
.history-panel{
  background: #0c1220;
  border: 1px solid #1f2533;
  border-radius: 10px;
  margin-bottom: 10px;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  max-height: 300px;
  opacity: 1;
}
.history-panel.collapsed{
  max-height: 0;
  opacity: 0;
  border: none;
  margin: 0;
}
.history-content{
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}
.history-item{
  background: #141c2b;
  border: 1px solid #1f2937;
  border-radius: 8px;
  padding: 10px 12px;
}
.history-item-header{
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.history-date{
  color: #9ca3af;
  font-size: 12px;
}
.history-role{
  background: #1e3a5f;
  color: #60a5fa;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: capitalize;
}
.history-preview{
  color: #d1d5db;
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: 4px;
}
.history-turns{
  color: #6b7280;
  font-size: 11px;
}
.history-continue{
  color: #60a5fa;
  font-size: 11px;
  margin-top: 6px;
  opacity: 0;
  transition: opacity 0.15s;
}
.history-item:hover{
  background: #1a2538;
  border-color: #2d4a6a;
}
.history-item:hover .history-continue{
  opacity: 1;
}

/* ---------- EMAIL PROMPT ---------- */
.email-prompt{
  background: linear-gradient(135deg, #1a2332 0%, #0f1a25 100%) !important;
  border: 1px solid #2d4a6a !important;
}
.email-prompt-content p{
  margin: 0 0 12px 0;
  color: #dbeafe;
}
.email-form{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.email-input{
  flex: 1;
  min-width: 140px;
  background: #0c1220;
  border: 1px solid #283046;
  border-radius: 8px;
  padding: 8px 12px;
  color: #e5e7eb;
  outline: none;
}
.email-input:focus{
  box-shadow: 0 0 0 2px var(--ring);
}
.email-submit-btn{
  background: linear-gradient(135deg, var(--cs-orange-600), var(--cs-orange-500));
  border: none;
  color: white;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
}
.email-submit-btn:hover{
  opacity: 0.9;
}
.email-skip-btn{
  background: transparent;
  border: 1px solid #374151;
  color: #9ca3af;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}
.email-skip-btn:hover{
  background: #1f2937;
}
