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

:root {
  /* Energizer Blue — iPortal palette */
  --primary:        #1565c0;
  --primary-dark:   #0d47a1;
  --primary-mid:    #1976d2;
  --primary-light:  #e3f2fd;
  --primary-border: #90caf9;

  --bg:        #f5f8ff;
  --surface:   #ffffff;
  --surface-2: #f0f4ff;
  --border:    #ccd9f0;
  --text:      #0d1b4b;
  --text-muted:#4a5a8a;
  --text-light:#8a9bcc;

  --user-bg:   #1565c0;
  --user-text: #ffffff;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.1), 0 2px 6px rgba(0,0,0,.06);
  --radius:    16px;
  --radius-sm: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ─── Launch animation ──────────────────────────────── */
@keyframes appOpen {
  from { opacity: 0; transform: scale(0.97) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.app-wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--surface);
  animation: appOpen 0.45s cubic-bezier(.34,1.56,.64,1) both;
}

/* ─── Header ─────────────────────────────────────────── */
.app-header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  border-bottom: 1px solid rgba(255,255,255,.1);
  padding: 0 32px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 12px rgba(13,71,161,.35);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
  max-width: 1100px;
  margin: 0 auto;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo-wrap {
  width: 46px;
  height: 46px;
  background: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  padding: 5px;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-name {
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 11.5px;
  color: rgba(255,255,255,.72);
  font-weight: 400;
  margin-top: 2px;
}

.header-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,.9);
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  padding: 5px 13px;
  border-radius: 20px;
}

.status-dot {
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ─── Chat Area ──────────────────────────────────────── */
.chat-main {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
  scroll-behavior: smooth;
}

.chat-messages {
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

/* ─── Messages ───────────────────────────────────────── */
.message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  max-width: 100%;
  animation: fadeUp .25s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.user-message { flex-direction: row-reverse; }

.message-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  overflow: hidden;
}

.bot-avatar {
  background: #fff;
  border: 1.5px solid var(--border);
  padding: 3px;
  box-shadow: var(--shadow-sm);
}

.avatar-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.user-avatar {
  background: var(--primary);
  color: white;
}

.message-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: calc(100% - 50px);
}

.user-message .message-content { align-items: flex-end; }

.message-bubble {
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 14.5px;
  line-height: 1.6;
  word-wrap: break-word;
}

.bot-message .message-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.user-message .message-bubble {
  background: var(--user-bg);
  color: var(--user-text);
  border-top-right-radius: 4px;
}

.message-bubble p { margin-bottom: 8px; }
.message-bubble p:last-child { margin-bottom: 0; }
.message-bubble strong { font-weight: 600; }
.message-bubble em { font-style: italic; color: var(--text-muted); }

/* ─── Welcome ────────────────────────────────────────── */
.welcome-message .message-bubble {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--surface) 100%);
  border-color: var(--primary-border);
}

/* ─── Quote Cards ────────────────────────────────────── */
.quotes-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quote-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  animation: fadeUp .2s ease both;
}

.quote-text {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  font-style: italic;
  margin-bottom: 10px;
}

.quote-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.page-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.page-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--primary);
  text-decoration: none;
  padding: 5px 11px;
  border-radius: 6px;
  border: 1px solid var(--primary-border);
  background: var(--primary-light);
  transition: all .15s ease;
  white-space: nowrap;
}

.page-link:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.page-link svg { flex-shrink: 0; }

/* ─── Not Found ──────────────────────────────────────── */
.not-found-card {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 14px;
  color: #92400e;
  line-height: 1.6;
}

/* ─── Follow-up ──────────────────────────────────────── */
.followup-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-light);
  margin-bottom: 6px;
}

.followup-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

/* ─── Chips ──────────────────────────────────────────── */
.chip {
  display: inline-block;
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  padding: 7px 13px;
  border-radius: 20px;
  cursor: pointer;
  transition: all .15s ease;
  font-family: var(--font);
  text-align: left;
  line-height: 1.4;
}

.chip:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(21,101,192,.3);
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 4px;
}

/* ─── Thinking / Loading ─────────────────────────────── */
.live-searching {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-top-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.live-label {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  transition: opacity .2s ease;
}

.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--primary-mid);
  border-radius: 50%;
  animation: typing .9s infinite ease-in-out;
  flex-shrink: 0;
}

.typing-dot:nth-child(2) { animation-delay: .15s; }
.typing-dot:nth-child(3) { animation-delay: .3s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ─── Error ──────────────────────────────────────────── */
.error-bubble {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13.5px;
  color: #dc2626;
  line-height: 1.5;
}

/* ─── Input ──────────────────────────────────────────── */
.chat-footer {
  border-top: 1px solid var(--border);
  padding: 16px 32px 20px;
  background: var(--surface);
  flex-shrink: 0;
  box-shadow: 0 -2px 12px rgba(13,71,161,.06);
}

.input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.input-box {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 10px 10px 10px 16px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.input-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21,101,192,.12);
  background: var(--surface);
}

.input-box textarea {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 14.5px;
  color: var(--text);
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
}

.input-box textarea::placeholder { color: var(--text-light); }

.send-btn {
  width: 38px;
  height: 38px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all .15s ease;
}

.send-btn:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: scale(1.05);
}

.send-btn:disabled {
  background: var(--border);
  color: var(--text-light);
  cursor: not-allowed;
  transform: none;
}

.input-footer-note {
  font-size: 11.5px;
  color: var(--text-light);
  text-align: center;
  line-height: 1.5;
}

.input-footer-note a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.input-footer-note a:hover { text-decoration: underline; }

/* ─── Energizer Footer ───────────────────────────────── */
.energizer-footer {
  background: #f0f0f0;
  border-top: 1px solid #d0d0d0;
  padding: 14px 32px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-shrink: 0;
}

.footer-logo {
  height: 26px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
  margin-top: 1px;
}

.footer-text {
  font-size: 11px;
  color: #666;
  line-height: 1.65;
  max-width: 1000px;
}

/* ─── Scrollbar ──────────────────────────────────────── */
.chat-main::-webkit-scrollbar { width: 5px; }
.chat-main::-webkit-scrollbar-track { background: transparent; }
.chat-main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.chat-main::-webkit-scrollbar-thumb:hover { background: var(--primary-border); }

/* ─── Responsive ─────────────────────────────────────── */
@media (max-width: 600px) {
  .chat-messages { padding: 20px 16px; }
  .chat-footer { padding: 12px 16px 16px; }
  .app-header { padding: 0 16px; }
  .header-inner { height: 62px; }
  .brand-name { font-size: 17px; }
  .brand-sub { display: none; }
  .chip { font-size: 12px; padding: 6px 11px; }
  .energizer-footer { padding: 12px 16px; flex-direction: column; gap: 8px; }
}
