/* ================================================================
   Virtual Ambassador ITEBIS — app.css
   Theme  : White dominant · Maroon & Gold accents
   Fonts  : Plus Jakarta Sans + Cormorant Garamond
   ================================================================ */

/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --maroon:        #7B1D1D;
  --maroon-dk:     #5A1212;
  --maroon-lt:     #9B2C2C;
  --maroon-pale:   #FEF2F2;
  --maroon-soft:   #FDEAEA;

  --gold:          #B8860B;
  --gold-lt:       #D4AF37;
  --gold-pale:     #FFFBEB;
  --gold-soft:     #FEF3C7;

  --white:         #FFFFFF;
  --off-white:     #FAFAF8;
  --g50:           #F9FAFB;
  --g100:          #F3F4F6;
  --g200:          #E5E7EB;
  --g300:          #D1D5DB;
  --g400:          #9CA3AF;
  --g500:          #6B7280;
  --g600:          #4B5563;
  --g700:          #374151;
  --g800:          #1F2937;
  --g900:          #111827;

  --success:       #059669;
  --success-bg:    #ECFDF5;
  --wa-green:      #25D366;
  --wa-hover:      #1ebe5a;

  --radius-sm:     6px;
  --radius:        10px;
  --radius-md:     14px;
  --radius-lg:     20px;
  --radius-full:   9999px;

  --shadow-sm:     0 1px 3px rgba(0,0,0,.07);
  --shadow:        0 2px 10px rgba(0,0,0,.09);
  --shadow-md:     0 4px 20px rgba(0,0,0,.11);
  --shadow-lg:     0 8px 40px rgba(0,0,0,.14);

  --font:          'Plus Jakarta Sans', sans-serif;
  --font-serif:    'Cormorant Garamond', Georgia, serif;

  /* layout */
  --header-h:      62px;
  --sidebar-w:     280px;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--g100);
  color: var(--g800);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── HEADER ───────────────────────────────────────────── */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  background: var(--white);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 20px;
  gap: 12px;
}

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

.header-logo {
  height: 38px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  flex-shrink: 0;
}

.header-logo-fallback {
  display: none;
  align-items: center;
  justify-content: center;
  width: 48px; height: 38px;
  background: var(--maroon);
  border-radius: var(--radius-sm);
  color: var(--white);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .5px;
  flex-shrink: 0;
}

.header-sep {
  width: 1px; height: 30px;
  background: var(--g200);
  flex-shrink: 0;
}

.header-titles { min-width: 0; }

.header-title {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--maroon);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-subtitle {
  font-size: 10.5px;
  color: var(--g400);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right { flex-shrink: 0; }

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--success-bg);
  border: 1px solid #A7F3D0;
  border-radius: var(--radius-full);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--success);
}

.status-badge.offline {
  background: var(--maroon-pale);
  border-color: #FECACA;
  color: var(--maroon);
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: pulseDot 2s ease-in-out infinite;
  flex-shrink: 0;
}

.status-badge.offline .status-dot { background: var(--maroon); animation: none; }

.status-dot--sm { width: 5px; height: 5px; }

@keyframes pulseDot {
  0%, 100% { opacity: 1; }
  50%       { opacity: .35; }
}

.header-gold-bar {
  height: 3px;
  background: linear-gradient(90deg, var(--maroon) 0%, var(--gold-lt) 50%, var(--maroon) 100%);
}

/* ── MAIN LAYOUT ──────────────────────────────────────── */
.main-layout {
  display: flex;
  height: calc(100vh - var(--header-h) - 3px);
  margin-top: calc(var(--header-h) + 3px);
  overflow: hidden;
}

/* ── SIDEBAR ──────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--g200);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-bottom: 20px;
  transition: transform .3s ease;
}

.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--g200); border-radius: 2px; }

/* Kira card */
.kira-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--g100);
}

.kira-avatar {
  position: relative;
  width: 48px; height: 48px;
  flex-shrink: 0;
}

.kira-avatar-ring {
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--maroon), var(--gold-lt));
}

.kira-avatar-inner {
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: var(--maroon);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  border: 2px solid var(--white);
}

.kira-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--g800);
}

.kira-role {
  font-size: 10.5px;
  color: var(--g400);
  margin-top: 1px;
}

.sidebar-intro {
  font-size: 12px;
  color: var(--g500);
  line-height: 1.6;
  padding: 12px 16px;
  border-bottom: 1px solid var(--g100);
}

.sidebar-intro strong { color: var(--maroon); }

/* Quick section */
.quick-section {
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--g100);
}

.quick-label {
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gold);
  margin-bottom: 8px;
}

.quick-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  margin-bottom: 5px;
  font-size: 12px;
  font-family: var(--font);
  color: var(--g700);
  background: var(--white);
  border: 1px solid var(--g200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .18s;
  line-height: 1.4;
}

.quick-btn:hover {
  border-color: var(--maroon);
  background: var(--maroon-pale);
  color: var(--maroon);
}

.quick-btn--gold {
  background: var(--gold-pale);
  border-color: var(--gold-soft);
  color: var(--gold);
  font-weight: 700;
}

.quick-btn--gold:hover {
  background: var(--gold-soft);
  border-color: var(--gold-lt);
  color: var(--g800);
}

/* CTA */
.sidebar-cta {
  margin: 12px 14px 0;
  padding: 14px;
  background: linear-gradient(135deg, var(--maroon-pale), var(--gold-pale));
  border: 1px solid var(--g200);
  border-radius: var(--radius-md);
}

.cta-title {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--maroon);
  margin-bottom: 4px;
}

.cta-desc {
  font-size: 11px;
  color: var(--g500);
  margin-bottom: 10px;
  line-height: 1.5;
}

.btn-cta {
  display: block;
  width: 100%;
  padding: 8px 12px;
  background: var(--maroon);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: background .2s;
}

.btn-cta:hover { background: var(--maroon-dk); }

/* ── CHAT PANEL ───────────────────────────────────────── */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--g50);
  min-width: 0;
}

/* Mobile topbar */
.chat-topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--white);
  border-bottom: 1px solid var(--g200);
  flex-shrink: 0;
}

.sidebar-toggle {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 28px; height: 28px;
  justify-content: center;
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.sidebar-toggle span {
  display: block;
  width: 18px; height: 2px;
  background: var(--g600);
  border-radius: 1px;
  transition: all .2s;
}

.sidebar-toggle.active span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.sidebar-toggle.active span:nth-child(2) { opacity: 0; }
.sidebar-toggle.active span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.topbar-ai {
  display: flex;
  align-items: center;
  gap: 9px;
}

.topbar-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--maroon);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}

.topbar-name { font-size: 13px; font-weight: 700; color: var(--g800); line-height: 1.2; }
.topbar-status { font-size: 10.5px; color: var(--success); display: flex; align-items: center; gap: 4px; }

/* ── MESSAGES ─────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--g300); border-radius: 2px; }

/* Message row */
.msg {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: msgIn .25s ease-out;
}

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

.msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
  flex-shrink: 0;
  align-self: flex-end;
}

.msg-avatar--ai {
  background: var(--maroon);
  color: var(--white);
  font-size: 16px;
}

.msg-avatar--user {
  background: linear-gradient(135deg, var(--gold), var(--gold-lt));
  color: var(--white);
  font-size: 10px;
}

.msg-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.msg--user .msg-body { align-items: flex-end; }

.msg-sender {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--g400);
  padding: 0 2px;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.65;
  word-break: break-word;
}

.msg--ai .msg-bubble {
  background: var(--white);
  border: 1px solid var(--g200);
  border-bottom-left-radius: 4px;
  color: var(--g800);
  box-shadow: var(--shadow-sm);
}

.msg--user .msg-bubble {
  background: var(--maroon);
  color: var(--white);
  border-bottom-right-radius: 4px;
}

.msg-bubble strong { font-weight: 700; }
.msg-bubble em     { font-style: italic; }

.msg-time {
  font-size: 9.5px;
  color: var(--g400);
  padding: 0 4px;
}

/* Typing indicator */
.typing-row {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: msgIn .25s ease-out;
}

.typing-bubble {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 12px 16px;
  background: var(--white);
  border: 1px solid var(--g200);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.typing-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--g400);
  animation: typingBounce 1.3s ease-in-out infinite;
}

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

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-8px); }
}

/* Streaming cursor */
.streaming-cursor {
  display: inline-block;
  width: 2px; height: 1em;
  background: var(--maroon);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink .7s step-end infinite;
}

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

/* ── INPUT BAR ────────────────────────────────────────── */
.chat-inputbar {
  background: var(--white);
  border-top: 1px solid var(--g200);
  padding: 10px 16px 12px;
  flex-shrink: 0;
}

.input-wrap {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  border: 1.5px solid var(--g200);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13.5px;
  font-family: var(--font);
  resize: none;
  outline: none;
  min-height: 44px;
  max-height: 130px;
  transition: border-color .2s;
  color: var(--g800);
  background: var(--white);
  line-height: 1.5;
}

.chat-input:focus { border-color: var(--maroon); }
.chat-input::placeholder { color: var(--g400); font-size: 13px; }

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

.send-btn:hover:not(:disabled) { background: var(--maroon-dk); transform: scale(1.04); }
.send-btn:active:not(:disabled){ transform: scale(.97); }
.send-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

.input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  padding: 0 2px;
}

.powered-by { font-size: 10px; color: var(--g400); }
.char-count  { font-size: 10px; color: var(--g400); }
.char-count.near-limit { color: var(--maroon); font-weight: 700; }

/* ── WHATSAPP FLOAT ───────────────────────────────────── */
.wa-float {
  position: fixed;
  bottom: 28px;
  left: 24px;
  right: auto;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--wa-green);
  color: var(--white);
  text-decoration: none;
  padding: 12px 18px 12px 14px;
  border-radius: var(--radius-full);
  box-shadow: 0 4px 20px rgba(37,211,102,.4);
  font-size: 13px;
  font-weight: 700;
  transition: all .25s;
}

.wa-float:hover {
  background: var(--wa-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 26px rgba(37,211,102,.5);
}

.wa-pulse {
  position: absolute;
  inset: -4px;
  border-radius: var(--radius-full);
  border: 2px solid var(--wa-green);
  animation: waPulse 2.5s ease-out infinite;
  pointer-events: none;
}

@keyframes waPulse {
  0%   { opacity: .8; transform: scale(1); }
  70%  { opacity: 0;  transform: scale(1.3); }
  100% { opacity: 0;  transform: scale(1.3); }
}

.wa-icon {
  width: 22px; height: 22px;
  flex-shrink: 0;
}

/* ── MODAL ────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(2px);
}

.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  position: relative;
  animation: modalIn .28s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(.94) translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.modal-close {
  position: absolute;
  top: 14px; right: 16px;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--g400);
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: all .15s;
  z-index: 1;
}

.modal-close:hover { background: var(--g100); color: var(--g700); }

.modal-header {
  padding: 24px 24px 16px;
  text-align: center;
  border-bottom: 1px solid var(--g100);
}

.modal-icon { font-size: 36px; margin-bottom: 8px; }

.modal-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--maroon);
  margin-bottom: 4px;
}

.modal-subtitle {
  font-size: 12.5px;
  color: var(--g500);
  line-height: 1.5;
}

/* Form */
.modal-form { padding: 20px 24px 24px; display: flex; flex-direction: column; gap: 14px; }

.form-row { display: flex; flex-direction: column; gap: 14px; }
.form-row--2col { flex-direction: row; gap: 12px; }
.form-row--2col .form-group { flex: 1; min-width: 0; }

.form-group { display: flex; flex-direction: column; gap: 4px; }

.form-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--g600);
}

.required { color: var(--maroon); }

.form-input {
  border: 1.5px solid var(--g200);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--g800);
  outline: none;
  background: var(--white);
  transition: border-color .2s;
  width: 100%;
}

.form-input:focus { border-color: var(--maroon); }
.form-input.error  { border-color: var(--maroon); background: var(--maroon-pale); }

.field-error {
  font-size: 10.5px;
  color: var(--maroon);
  min-height: 14px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}

.btn-cancel {
  padding: 9px 18px;
  background: var(--white);
  color: var(--g600);
  border: 1.5px solid var(--g200);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all .18s;
}

.btn-cancel:hover { background: var(--g50); }

.btn-submit {
  padding: 10px 22px;
  background: var(--maroon);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: background .2s;
}

.btn-submit:hover:not(:disabled) { background: var(--maroon-dk); }
.btn-submit:disabled { opacity: .5; cursor: not-allowed; }

/* ── TOAST ────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 90px; right: 24px;
  z-index: 600;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  transition: all .3s;
  pointer-events: none;
  max-width: 340px;
  background: var(--g900);
  color: var(--white);
}

.toast.show       { opacity: 1; transform: none; }
.toast.success    { background: var(--success); }
.toast.error      { background: #DC2626; }

/* ── RESPONSIVE ───────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 280px; }

  .site-header { position: fixed; }

  .sidebar {
    position: fixed;
    top: calc(var(--header-h) + 3px);
    left: 0;
    bottom: 0;
    z-index: 150;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 140;
    background: rgba(0,0,0,.4);
  }

  .sidebar-overlay.open { display: block; }

  .chat-topbar { display: flex; }

  .wa-float { bottom: 16px; left: 16px; right: auto; padding: 12px 14px; }
  .wa-label  { display: none; }

  .form-row--2col { flex-direction: column; }

  .msg { max-width: 96%; }

  .toast { right: 16px; bottom: 80px; max-width: calc(100vw - 32px); }
}

@media (max-width: 480px) {
  .chat-messages { padding: 14px 10px; }
  .chat-inputbar  { padding: 8px 10px 10px; }
  .msg-bubble     { font-size: 13px; }
  .modal-form     { padding: 16px 16px 20px; }
  .modal-header   { padding: 20px 16px 14px; }
}

/* ── OLLAMA OFFLINE BANNER ────────────────────────────── */
.offline-banner {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--maroon-pale);
  border-bottom: 1px solid #FECACA;
  font-size: 12px;
  color: var(--maroon);
  font-weight: 600;
  flex-shrink: 0;
}

.offline-banner.show { display: flex; }
