/* ============================================================
   Navnit Insurance — 365 Assistant
   Floating widget card skin
   (same IDs/classes as before — app.js untouched)
   ============================================================ */

:root {
  --navy:             #17253a;
  --indigo:           #3835a5;
  --royal-blue:       #2f66b6;
  --electric-blue:    #0e5dd8;
  --cyan:             #55c6ea;
  --ink:              #181a23;
  --muted:            #626978;
  --line:             #d9dce5;
  --surface:          #ffffff;
  --message:          #eaf8ff;
  --danger:           #ef4444;
  --ok:               #1be28e;
  --radius:           28px;
  --shadow:           0 24px 60px rgba(5,17,37,.32);
  --input-bg:         #ffffff;
  --icon-btn-hover:   rgba(255,255,255,.16);

  /* mapped onto the widget's existing token names so nothing else changes */
  --bg:               var(--surface);
  --panel:            var(--navy);
  --panel-2:          var(--surface);
  --border:           var(--line);
  --text:              var(--ink);
  --grad-start:       #326dbb;
  --grad-end:         #3330a4;
  --title-color:      #191b78;
  --subtext-color:    #22252f;
  --pink:             #ee007a;
  --pink-hover:       #d60068;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 12% 18%, rgba(31,93,164,.25), transparent 36%),
    linear-gradient(135deg, #1c2a40, #101a2a);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   APP — the floating widget card itself
   ============================================================ */
.app {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 88vh;
  max-height: 700px;
  background: #ffffff;
  border-radius: 26px;
  overflow: hidden;
  box-shadow: var(--shadow), 0 2px 0 rgba(255,255,255,.04) inset;
  display: flex;
  flex-direction: column;
  transition: transform .25s ease, opacity .25s ease;
}
/* Closed state — the ✕ button hides the whole card */
.app.closed {
  opacity: 0;
  transform: translateY(24px) scale(.96);
  pointer-events: none;
}

/* ============================================================
   SIDEBAR — hidden drawer, opened from the ⋯ button
   ============================================================ */
.sidebar {
  position: absolute;
  inset: 0 20% 0 0;
  background: var(--navy);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transform: translateX(-105%);
  transition: transform .25s ease;
  z-index: 30;
}
.sidebar.open { transform: translateX(0); }

.sidebar-scrim {
  position: absolute;
  inset: 0;
  background: rgba(10,15,30,.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
  z-index: 20;
}
.sidebar.open ~ .sidebar-scrim,
#sidebar.open + .sidebar-scrim {
  opacity: 1;
  pointer-events: auto;
}

#recent-chats { overflow-y: auto; flex: 1; min-height: 0; }

.brand-container { display: flex; flex-direction: column; align-items: flex-start; gap: 0; padding: 4px 6px; }
.brand-container img { width: 120px; height: auto; }
.brand-sub { font-size: 12px; color: var(--cyan); padding-left: 2px; }

.new-chat {
  width: 100%;
  background: rgba(238, 0, 122, 0.14);
  color: #ff8fc9;
  border: 1px solid rgba(238, 0, 122, 0.35);
  padding: 10px 12px;
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.25s ease;
  flex-shrink: 0;
}

/* Hover Effect */
.new-chat:hover {
  background: linear-gradient(
    135deg,
    #ee007a,
    #ff3b9d
  );
  color: #ffffff;
  border-color: #ff3b9d;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(238, 0, 122, 0.35);
}

/* Click Effect */
.new-chat:active {
  transform: translateY(0);
  box-shadow: 0 3px 8px rgba(238, 0, 122, 0.25);
}
.side-section {
  color: #ffffff;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 0 6px;
  margin-top: 6px;
  flex-shrink: 0;
}
.side-empty  { color: rgba(255,255,255,.6); font-size: 13px; padding: 6px; }
.side-footer { margin-top: auto; color: rgba(255,255,255,.5); font-size: 11px; padding: 6px; flex-shrink: 0; }

.chat-item:hover { background: rgba(255,255,255,.08) !important; }

/* ============================================================
   MAIN
   ============================================================ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

/* ============================================================
   TOPBAR — gradient header, matches the reference card
   ============================================================ */
.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px;
  background: linear-gradient(110deg, #326dbb 0%, #3f35a6 75%, #3330a4 100%);
  color: #ffffff;
}

.topbar-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.topbar-logo {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #ffffff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}
.topbar-logo img { width: 100%; height: 100%; object-fit: contain; }

.topbar-info { min-width: 0; }
.topbar-title {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-status {
  font-size: 12px;
  color: rgba(255,255,255,.85);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(27,226,142,.2);
}

.topbar-actions { display: flex; gap: 6px; flex-shrink: 0; }
.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 0;
  background: rgba(255,255,255,.14);
  color: #ffffff;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 15px;
  line-height: 1;
  transition: background .15s;
}
.icon-btn:hover { background: var(--icon-btn-hover); }

/* ============================================================
   CHAT — scrollable area
   ============================================================ */
#chat, .chat {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px 18px 8px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  justify-content: flex-start;
}

/* ============================================================
   HERO
   ============================================================ */
.hero {
  width: 100%;
  text-align: center;
  margin: auto 0;
  padding: 6px 2px 18px;
}
.hero.hidden { display: none; }

.hero-badge { display: none; } /* not part of the widget look */

.hero-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--title-color);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
}
.icon svg { width: 22px; height: 22px; stroke: #f39a0a; }
.flag { font-size: 16px; }

.hero-subtext {
  color: var(--subtext-color);
  font-size: 13.5px;
  line-height: 1.5;
  padding: 0 6px;
}

/* Stats — gradient pill matching the header */
.hero-stats {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin-top: 22px;
  padding: 16px 6px;
  border-radius: 18px;
  background: linear-gradient(105deg, #377fb7, #3c2f93);
  box-shadow: 0 14px 30px rgba(50,61,153,.25);
}
.stat { flex: 1; min-width: 0; }
.value { font-size: 19px; font-weight: 800; color: #ffffff; }
.label { font-size: 10.5px; color: rgba(255,255,255,.85); margin-top: 2px; }
.divider { width: 1px; height: 26px; background: rgba(255,255,255,.35); flex-shrink: 0; }

/* Quick action chips — pastel pills, one hue per action */
.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}
.chip {
  padding: 9px 15px;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #2c2350;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform .12s, filter .15s;
}
.chip:hover { transform: translateY(-1px); filter: brightness(0.97); }
.chip .dot { display: none; }

.chips .chip:nth-child(1) { background: #e7f2ff; } /* Motor  — light blue   */
.chips .chip:nth-child(2) { background: #ece8ff; } /* Health — light violet */
.chips .chip:nth-child(3) { background: #ffe4f0; } /* Life   — pink         */
.chips .chip:nth-child(4) { background: #ffead7; } /* Renew  — peach        */
.chips .chip:nth-child(5) { background: #fff6ca; } /* Others — pale yellow  */

/* ============================================================
   MESSAGES
   ============================================================ */
#messages, .messages {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 16px;
}
.msg { display: flex; gap: 8px; animation: fade .25s ease; }
.msg.user { justify-content: flex-end; }

.avatar { width: 26px; height: 26px; border-radius: 50%; flex: 0 0 26px; display: grid; place-items: center; font-size: 12px; }
.avatar.assistant { background: linear-gradient(135deg, var(--grad-start), var(--grad-end)); color: #fff; }
.avatar.user { background: var(--indigo); color: #fff; }

.bubble {
  max-width: 80%;
  padding: 10px 13px;
  border-radius: 15px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}
.msg.assistant .bubble {
  background: var(--message);
  color: var(--text);
  border-bottom-left-radius: 5px;
}
.msg.user .bubble {
  background: var(--pink);
  color: #ffffff;
  border-bottom-right-radius: 5px;
}

.bubble ul { margin: 6px 0 6px 16px; padding: 0; }
.bubble li { margin-bottom: 3px; line-height: 1.45; }
.bubble strong { font-weight: 700; }
.bubble em { font-style: italic; }
.bubble br { display: block; margin: 3px 0; content: ""; }
.section-heading { margin-top: 4px; }

/* Chips rendered inline inside a message (lead-form insurance picker) */
.messages .chips { justify-content: flex-start; margin-top: 4px; }

/* Typing indicator */
.typing { display: inline-flex; gap: 4px; padding: 2px 0; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--pink); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }

@keyframes blink { 0%,80%,100% { opacity:.2 } 40% { opacity:1 } }
@keyframes fade  { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:none; } }

/* ============================================================
   COMPOSER — pill input + circular pink send button
   ============================================================ */
.composer {
  flex-shrink: 0;
  padding: 10px 16px 16px;
  background: #ffffff;
}
.composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--input-bg);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 8px 8px 8px 16px;
  box-shadow: var(--shadow);
  transition: border-color .2s, box-shadow .2s;
}
.composer-inner:focus-within {
  border-color: var(--grad-start);
  box-shadow: 0 0 0 3px rgba(61,108,230,.12);
}

#input {
  flex: 1;
  resize: none;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  padding: 8px 0;
  max-height: 100px;
  overflow-y: auto;
}
#input::placeholder { color: var(--muted); }

.send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  background: linear-gradient(145deg, #f00083, #d60068);
  color: #ffffff;
  font-size: 16px;
  display: grid;
  place-items: center;
  transition: transform .1s, filter .2s, box-shadow .2s;
  box-shadow: 0 10px 20px rgba(226,0,112,.25);
  flex-shrink: 0;
}
.send-btn:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 14px 24px rgba(226,0,112,.34); }
.send-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

.composer-hint {
  margin: 8px 4px 0;
  color: var(--muted);
  font-size: 10.5px;
  text-align: center;
}

.error { color: var(--danger); font-size: 12px; margin-top: 6px; }

/* ============================================================
   MOBILE — widget fills the viewport
   ============================================================ */
@media (max-width: 520px) {
  body { padding: 0; }
  .app {
    max-width: 100%;
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  .sidebar { inset: 0 15% 0 0; }
}