/* ================================================================
   UPICON MSME AI सहायक — style.css
   Government of Uttar Pradesh · Professional Color System
   Fully Responsive: Mobile 320px → Tablet → Desktop → Wide
   ================================================================ */

/* ── CSS Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
button { cursor: pointer; font-family: inherit; }
textarea, select, input { font-family: inherit; }
svg { display: block; flex-shrink: 0; }

/* ── Design Tokens — Government Blue Palette ── */
:root {
  /* Primary — Deep Government Blue (NIC / INDIA.GOV inspired) */
  --navy:         #0A3161;
  --navy-dark:    #061E3D;
  --navy-mid:     #0E4080;
  --navy-lt:      #1252A3;

  /* Accent — Indian Saffron (tricolor) */
  --saffron:      #E8660A;
  --saffron-lt:   #F07A2A;
  --saffron-pale: #FEF3E8;

  /* Neutral Government Greys */
  --gray-900:     #111827;
  --gray-800:     #1F2937;
  --gray-700:     #374151;
  --gray-600:     #4B5563;
  --gray-500:     #6B7280;
  --gray-400:     #9CA3AF;
  --gray-300:     #D1D5DB;
  --gray-200:     #E5E7EB;
  --gray-100:     #F3F4F6;
  --gray-50:      #F9FAFB;
  --white:        #FFFFFF;

  /* Semantic */
  --success:      #16A34A;
  --success-bg:   #F0FDF4;
  --error:        #DC2626;
  --error-bg:     #FEF2F2;
  --warning:      #D97706;
  --info:         #0369A1;

  /* Surfaces (light theme — professional government) */
  --surface-page: #F0F4F8;
  --surface-card: #FFFFFF;
  --surface-sidebar: #FFFFFF;
  --surface-topbar: #0A3161;
  --surface-ribbon: #F8F9FB;
  --surface-input: #FFFFFF;
  --surface-hover: #EFF4FF;

  /* Borders */
  --border-light: #E2E8F0;
  --border-mid:   #CBD5E1;
  --border-dark:  #94A3B8;

  /* Text */
  --text-primary:   #0F172A;
  --text-secondary: #475569;
  --text-muted:     #94A3B8;
  --text-on-navy:   #FFFFFF;
  --text-on-saffron:#FFFFFF;

  /* Shadows */
  --shadow-xs:    0 1px 2px rgba(0,0,0,.06);
  --shadow-sm:    0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:    0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --shadow-xl:    0 20px 25px rgba(0,0,0,.1), 0 10px 10px rgba(0,0,0,.04);
  --shadow-sidebar: 4px 0 24px rgba(0,0,0,.12);

  /* Layout */
  --sidebar-w:    288px;
  --topbar-h:     56px;
  --ribbon-h:     44px;
  --input-bar-h:  auto;

  /* Typography */
  --font-sans:    'Inter', 'Noto Sans Devanagari', system-ui, -apple-system, sans-serif;
  --font-deva:    'Noto Sans Devanagari', 'Inter', sans-serif;

  /* Radius */
  --r-sm:  6px;
  --r-md:  10px;
  --r-lg:  14px;
  --r-xl:  20px;
  --r-full:9999px;

  /* Transitions */
  --transition: 200ms cubic-bezier(.4,0,.2,1);
}

/* ── Base Layout ── */
html, body {
  height: 100%;
  background: var(--surface-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
}

/* ── Sidebar Overlay (mobile) ── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(2px);
  animation: fadeIn var(--transition);
}
.sidebar-overlay.visible { display: block; }
@keyframes fadeIn { from { opacity:0 } to { opacity:1 } }

/* ════════════════════════════════════════
   SIDEBAR
════════════════════════════════════════ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  height: 100%;
  width: var(--sidebar-w);
  background: var(--surface-sidebar);
  border-right: 1px solid var(--border-light);
  box-shadow: var(--shadow-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 300;
  transform: translateX(-100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
.sidebar.open { transform: translateX(0); }

/* Sidebar Header */
.sb-header {
  padding: 0 16px;
  height: 56px;
  background: var(--navy);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.sb-logo { display: flex; align-items: center; gap: 10px; }
.sb-logo-emblem {
  width: 34px; height: 34px; flex-shrink: 0;
}
.sb-logo-emblem svg { width: 34px; height: 34px; border-radius: 6px; }
.sb-logo-text { display: flex; flex-direction: column; gap: 1px; }
.sb-logo-title {
  font-size: 15px; font-weight: 700;
  color: var(--white); letter-spacing: .3px; line-height: 1;
}
.sb-logo-sub {
  font-size: 11px; color: rgba(255,255,255,.7);
  font-family: var(--font-deva); line-height: 1;
}
.sb-close {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  background: rgba(255,255,255,.12); border: none;
  color: white; display: flex; align-items: center; justify-content: center;
  display: none; /* shown on mobile */
  transition: background var(--transition);
}
.sb-close:hover { background: rgba(255,255,255,.22); }
.sb-close svg { width: 16px; height: 16px; }

/* Sidebar Tabs */
.sb-tabs {
  display: flex; border-bottom: 1px solid var(--border-light);
  background: var(--gray-50); flex-shrink: 0;
}
.sb-tab {
  flex: 1; padding: 11px 8px;
  background: transparent; border: none; border-bottom: 2px solid transparent;
  color: var(--text-secondary); font-size: 12.5px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  transition: all var(--transition); position: relative;
}
.sb-tab svg { width: 13px; height: 13px; }
.sb-tab.active {
  color: var(--navy); border-bottom-color: var(--navy);
  background: var(--white);
}
.sb-tab:hover:not(.active) { color: var(--text-primary); background: var(--surface-hover); }

.kb-count-badge {
  background: var(--saffron); color: white;
  font-size: 10px; font-weight: 700;
  min-width: 17px; height: 17px; border-radius: var(--r-full);
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 4px; line-height: 1;
}

/* Sidebar Panels */
.sb-panel {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.btn-new-chat {
  margin: 12px;
  padding: 10px 16px;
  background: var(--navy); color: white;
  border: none; border-radius: var(--r-md);
  font-size: 13.5px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  transition: background var(--transition);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.btn-new-chat:hover { background: var(--navy-mid); }
.btn-new-chat svg { width: 14px; height: 14px; }

.sb-section-label {
  padding: 8px 16px 6px;
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-muted); flex-shrink: 0;
}

.quick-topics {
  flex: 1; overflow-y: auto; padding: 4px 10px 12px;
  display: flex; flex-direction: column; gap: 3px;
}
.quick-topics::-webkit-scrollbar { width: 3px; }
.quick-topics::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 2px; }

.topic-chip {
  padding: 8px 12px; text-align: left;
  background: transparent; border: 1px solid var(--border-light);
  border-radius: var(--r-sm); color: var(--text-secondary);
  font-size: 12.5px; font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topic-chip:hover {
  background: var(--surface-hover); border-color: var(--navy-lt);
  color: var(--navy); transform: translateX(2px);
}

/* ── Knowledge Panel ── */
.kb-dropzone {
  margin: 12px;
  padding: 20px 12px;
  border: 2px dashed var(--border-mid);
  border-radius: var(--r-lg); text-align: center;
  background: var(--gray-50);
  transition: all var(--transition);
  flex-shrink: 0;
}
.kb-dropzone:hover,
.kb-dropzone.drag-active {
  border-color: var(--navy); background: var(--surface-hover);
}
.kbdz-icon { font-size: 28px; margin-bottom: 6px; }
.kbdz-title {
  font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 3px;
}
.kbdz-sub { font-size: 11.5px; color: var(--text-muted); margin-bottom: 8px; }
.kbdz-formats {
  font-size: 10px; color: var(--text-muted); letter-spacing: .5px;
  font-family: monospace; margin-bottom: 12px;
}
.btn-browse {
  padding: 7px 18px; background: var(--white);
  border: 1px solid var(--border-mid); border-radius: var(--r-sm);
  color: var(--navy); font-size: 12.5px; font-weight: 600;
  transition: all var(--transition);
}
.btn-browse:hover { background: var(--navy); color: white; border-color: var(--navy); }

.kb-cat-row {
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px 10px; flex-shrink: 0;
}
.kb-cat-label {
  font-size: 12px; color: var(--text-secondary); font-weight: 600;
  white-space: nowrap;
}
.kb-cat-select {
  flex: 1; background: var(--white);
  border: 1px solid var(--border-mid); border-radius: var(--r-sm);
  color: var(--text-primary); font-size: 12px; padding: 5px 8px;
  outline: none;
}
.kb-cat-select:focus { border-color: var(--navy); box-shadow: 0 0 0 2px rgba(10,49,97,.15); }

.kb-doc-count {
  color: var(--navy); font-weight: 700; font-size: 12px;
}

.kb-doc-list {
  flex: 1; overflow-y: auto; padding: 0 10px 12px;
}
.kb-doc-list::-webkit-scrollbar { width: 3px; }
.kb-doc-list::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 2px; }

.kb-empty {
  padding: 28px 12px; text-align: center;
  color: var(--text-muted);
}
.kb-empty svg { width: 36px; height: 36px; margin: 0 auto 10px; opacity: .4; }
.kb-empty p { font-size: 12.5px; line-height: 1.7; }

.kb-doc-card {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 10px; border-radius: var(--r-md);
  background: var(--white); border: 1px solid var(--border-light);
  margin-bottom: 6px; transition: border-color var(--transition);
}
.kb-doc-card:hover { border-color: var(--border-dark); }
.kbdc-icon {
  width: 34px; height: 34px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.kbdc-body { flex: 1; min-width: 0; }
.kbdc-name {
  font-size: 12px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 3px;
}
.kbdc-meta {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  font-size: 10.5px; color: var(--text-muted);
}
.kbdc-tag {
  background: var(--surface-hover); color: var(--navy);
  padding: 1px 6px; border-radius: var(--r-full);
  font-size: 10px; font-weight: 600;
}
.kbdc-date { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.kbdc-del {
  background: transparent; border: none; color: var(--text-muted);
  padding: 4px; border-radius: var(--r-sm); flex-shrink: 0;
  transition: all var(--transition);
}
.kbdc-del:hover { background: var(--error-bg); color: var(--error); }
.kbdc-del svg { width: 13px; height: 13px; }

/* Sidebar Footer */
.sb-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border-light);
  background: var(--gray-50);
  display: flex; align-items: flex-start; gap: 7px;
  font-size: 11px; color: var(--text-muted); line-height: 1.5;
  flex-shrink: 0;
}
.sb-footer svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 1px; }


/* ════════════════════════════════════════
   MAIN LAYOUT
════════════════════════════════════════ */
.layout-main {
  display: flex; flex-direction: column;
  height: 100vh;
  /* On desktop, leave space for sidebar */
  margin-left: 0;
  transition: margin-left .28s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}

/* ════════════════════════════════════════
   TOP BAR
════════════════════════════════════════ */
.topbar {
  height: var(--topbar-h);
  background: var(--navy);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  gap: 12px; flex-shrink: 0;
  position: relative; z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }

.btn-menu {
  width: 36px; height: 36px; flex-shrink: 0;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--r-sm); color: white;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.btn-menu:hover { background: rgba(255,255,255,.2); }
.btn-menu svg { width: 16px; height: 16px; }

.topbar-brand {
  display: flex; align-items: center; gap: 8px;
  min-width: 0; overflow: hidden;
}
.topbar-gov {
  font-size: 11px; font-weight: 600;
  color: rgba(255,255,255,.7);
  white-space: nowrap;
  display: none; /* shown ≥480px */
}
.topbar-sep {
  color: rgba(255,255,255,.3);
  display: none;
}
.topbar-name {
  font-size: 15px; font-weight: 700; color: white;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.topbar-right {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}

.kb-status {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: var(--r-full);
  background: rgba(22,163,74,.2); border: 1px solid rgba(22,163,74,.35);
  color: #86EFAC; font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}
.kb-status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--success);
  animation: pulse-dot 2s ease-in-out infinite;
}
.kb-status-text { display: none; } /* shown ≥600px */
@keyframes pulse-dot { 0%,100%{opacity:1} 50%{opacity:.4} }

.model-pill {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--r-full); padding: 5px 12px;
}
.model-live {
  width: 6px; height: 6px; border-radius: 50%;
  background: #4ADE80; box-shadow: 0 0 6px #4ADE80;
  animation: pulse-dot 2s ease-in-out infinite;
}
.model-pill select {
  background: transparent; border: none; color: white;
  font-size: 12px; font-weight: 600; outline: none; cursor: pointer;
}
.model-pill select option { background: var(--navy-dark); color: white; }

.lang-switch {
  display: flex; border-radius: var(--r-full);
  overflow: hidden; border: 1px solid rgba(255,255,255,.2);
}
.lang-btn {
  padding: 5px 10px; border: none; background: transparent;
  color: rgba(255,255,255,.7); font-size: 12px; font-weight: 700;
  transition: all var(--transition); line-height: 1;
}
.lang-btn.active { background: var(--saffron); color: white; }
.lang-btn:hover:not(.active) { background: rgba(255,255,255,.1); color: white; }


/* ════════════════════════════════════════
   GOVERNMENT RIBBON
════════════════════════════════════════ */
.gov-ribbon {
  height: var(--ribbon-h);
  background: var(--surface-ribbon);
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center;
  flex-shrink: 0;
  overflow: hidden;
}
.gov-ribbon-inner {
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px; width: 100%;
  max-width: 1200px; margin: 0 auto;
}
.gov-ashoka {
  color: var(--navy); flex-shrink: 0;
}
.gov-ashoka svg { width: 26px; height: 26px; }
.gov-ribbon-text {
  display: flex; flex-direction: column; gap: 1px;
  min-width: 0;
}
.gov-ribbon-title {
  font-size: 12.5px; font-weight: 700; color: var(--navy);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gov-ribbon-sub {
  font-size: 11px; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}


/* ════════════════════════════════════════
   MESSAGES AREA
════════════════════════════════════════ */
.messages-wrap {
  flex: 1; overflow-y: auto;
  background: var(--surface-page);
  padding: 20px 0 8px;
  scroll-behavior: smooth;
}
.messages-wrap::-webkit-scrollbar { width: 5px; }
.messages-wrap::-webkit-scrollbar-track { background: transparent; }
.messages-wrap::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }

/* Welcome Screen */
.welcome {
  max-width: 680px; margin: 24px auto 32px;
  padding: 0 20px; text-align: center;
  animation: slideUp .5s ease;
}
@keyframes slideUp { from{opacity:0;transform:translateY(16px)} to{opacity:1;transform:none} }

.welcome-emblem {
  width: 68px; height: 68px; margin: 0 auto 16px;
  color: var(--navy); opacity: .7;
}
.welcome-emblem svg { width: 68px; height: 68px; }

.welcome-tag {
  display: inline-block; padding: 4px 14px;
  background: var(--surface-hover); border: 1px solid var(--border-light);
  border-radius: var(--r-full); font-size: 11.5px; font-weight: 700;
  color: var(--navy); letter-spacing: .3px; margin-bottom: 18px;
}
.welcome-title {
  font-size: clamp(26px, 5vw, 38px);
  font-weight: 700; line-height: 1.2;
  color: var(--text-primary); margin-bottom: 14px;
  font-family: var(--font-deva);
}
.welcome-title strong { color: var(--navy); }
.welcome-desc {
  font-size: clamp(13px, 2vw, 15px);
  color: var(--text-secondary); line-height: 1.7; margin-bottom: 22px;
}
.d-md { display: none; }
.welcome-chips {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
}
.wchip {
  padding: 6px 14px;
  background: var(--white); border: 1px solid var(--border-light);
  border-radius: var(--r-full); font-size: 12.5px; color: var(--text-secondary);
  font-weight: 500; box-shadow: var(--shadow-xs);
}

/* Messages List */
#messagesList {
  max-width: 800px; margin: 0 auto; padding: 0 16px;
}

.msg-row {
  display: flex; gap: 11px; margin-bottom: 20px;
  animation: slideUp .3s ease;
}
.msg-row.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 32px; height: 32px; border-radius: var(--r-md);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}
.bot-av {
  background: var(--navy); color: white;
}
.bot-av svg { width: 16px; height: 16px; }
.user-av {
  background: var(--gray-200); color: var(--gray-600);
  font-family: var(--font-deva);
}

.msg-content { flex: 1; min-width: 0; }

.msg-bubble {
  display: inline-block; max-width: 100%;
  padding: 11px 15px; border-radius: var(--r-lg);
  font-size: 14px; line-height: 1.75;
  word-break: break-word;
}
.bot .msg-bubble {
  background: var(--surface-card);
  border: 1px solid var(--border-light);
  border-bottom-left-radius: var(--r-sm);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}
.user .msg-bubble {
  background: var(--navy);
  color: white;
  border-bottom-right-radius: var(--r-sm);
}
.bot .msg-bubble strong { color: var(--navy); }
.bot .msg-bubble ul, .bot .msg-bubble ol { padding-left: 18px; margin: 6px 0; }
.bot .msg-bubble li { margin-bottom: 3px; }
.bot .msg-bubble code {
  font-family: monospace; font-size: 12.5px;
  background: var(--gray-100); padding: 1px 5px; border-radius: 4px;
  color: var(--navy);
}
.bot .msg-bubble p { margin-bottom: 6px; }
.bot .msg-bubble p:last-child { margin-bottom: 0; }

.msg-meta {
  display: flex; align-items: center; gap: 7px; margin-top: 5px;
}
.user .msg-meta { justify-content: flex-end; }
.msg-time { font-size: 11px; color: var(--text-muted); }

.btn-tts {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: var(--r-full);
  background: var(--gray-100); border: 1px solid var(--border-light);
  color: var(--text-secondary); font-size: 11px; font-weight: 600;
  transition: all var(--transition);
}
.btn-tts:hover { background: var(--navy); color: white; border-color: var(--navy); }
.btn-tts.playing { background: var(--saffron); color: white; border-color: var(--saffron); }
.btn-tts svg { width: 11px; height: 11px; }

/* Typing */
.typing-row {
  display: flex; gap: 11px; max-width: 800px;
  margin: 0 auto 20px; padding: 0 16px;
}
.typing-bubble {
  padding: 12px 16px;
  background: var(--surface-card); border: 1px solid var(--border-light);
  border-radius: var(--r-lg); border-bottom-left-radius: var(--r-sm);
  display: flex; gap: 5px; align-items: center;
  box-shadow: var(--shadow-xs);
}
.typing-bubble .dot {
  width: 7px; height: 7px; background: var(--gray-400); border-radius: 50%;
  animation: dotBounce 1.2s ease-in-out infinite;
}
.typing-bubble .dot:nth-child(2) { animation-delay: .2s; }
.typing-bubble .dot:nth-child(3) { animation-delay: .4s; }
@keyframes dotBounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-7px)} }

.scroll-spacer { height: 12px; }


/* ════════════════════════════════════════
   INPUT BAR
════════════════════════════════════════ */
.input-bar {
  background: var(--surface-card);
  border-top: 1px solid var(--border-light);
  padding: 12px 16px 14px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  flex-shrink: 0; z-index: 10;
  box-shadow: 0 -2px 8px rgba(0,0,0,.05);
}
.input-wrap { max-width: 800px; margin: 0 auto; }
.input-box {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--white); border: 1.5px solid var(--border-mid);
  border-radius: var(--r-xl); padding: 8px 8px 8px 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input-box:focus-within {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(10,49,97,.12);
}

.input-box textarea {
  flex: 1; background: transparent; border: none; outline: none; resize: none;
  color: var(--text-primary); font-size: 14px; line-height: 1.6;
  max-height: 160px; min-height: 24px; scrollbar-width: none;
  padding: 2px 0;
}
.input-box textarea::-webkit-scrollbar { display: none; }
.input-box textarea::placeholder { color: var(--text-muted); }

.ib-actions { display: flex; gap: 5px; align-items: flex-end; flex-shrink: 0; }

.ib-btn {
  width: 36px; height: 36px; border-radius: var(--r-sm);
  background: var(--gray-100); border: 1px solid var(--border-light);
  color: var(--text-secondary); display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
  transition: all var(--transition);
}
.ib-btn:hover { background: var(--surface-hover); color: var(--navy); border-color: var(--navy-lt); }
.ib-btn svg { width: 16px; height: 16px; }

.voice-btn.recording {
  background: rgba(220,38,38,.08); border-color: rgba(220,38,38,.4);
  color: var(--error); animation: pulse-rec 1s ease-in-out infinite;
}
@keyframes pulse-rec { 0%,100%{box-shadow:0 0 0 0 rgba(220,38,38,.35)} 50%{box-shadow:0 0 0 7px rgba(220,38,38,0)} }

.ib-send {
  width: 36px; height: 36px; border-radius: var(--r-sm);
  background: var(--navy); border: none; color: white;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}
.ib-send:hover { background: var(--navy-mid); transform: scale(1.04); }
.ib-send:active { transform: scale(.97); }
.ib-send:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.ib-send svg { width: 14px; height: 14px; }

.input-hint {
  margin-top: 7px; font-size: 11px; color: var(--text-muted); text-align: center;
}
.input-hint.recording-active { color: var(--error); }


/* ════════════════════════════════════════
   UPLOAD MODAL
════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.55); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.upload-modal {
  background: var(--white); border-radius: var(--r-xl);
  padding: 36px 40px; text-align: center;
  max-width: 340px; width: 100%;
  box-shadow: var(--shadow-xl);
  animation: slideUp .3s ease;
}
.upm-spinner {
  width: 52px; height: 52px; margin: 0 auto 14px;
  color: var(--navy);
  animation: rotate 1.2s linear infinite;
}
.upm-spinner svg { width: 52px; height: 52px; }
@keyframes rotate { to { transform: rotate(360deg); } }
.upm-title { font-size: 17px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.upm-file  { font-size: 12.5px; color: var(--text-muted); margin-bottom: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upm-bar   { height: 5px; background: var(--gray-200); border-radius: 3px; overflow: hidden; margin-bottom: 10px; }
.upm-fill  { height: 100%; background: linear-gradient(90deg, var(--navy), var(--navy-lt)); border-radius: 3px; transition: width .3s; }
.upm-status { font-size: 13px; color: var(--text-secondary); font-weight: 500; }


/* ════════════════════════════════════════
   TOAST
════════════════════════════════════════ */
.toast-stack {
  position: fixed; bottom: 90px; right: 16px;
  z-index: 600; display: flex; flex-direction: column; gap: 7px;
  max-width: 320px; width: calc(100% - 32px);
}
.toast {
  padding: 11px 16px; border-radius: var(--r-md);
  background: var(--gray-900); color: white;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideInR .25s ease;
  display: flex; align-items: center; gap: 8px;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--error); }
@keyframes slideInR { from{transform:translateX(110%);opacity:0} to{transform:none;opacity:1} }

/* Utility */
[hidden] { display: none !important; }


/* ════════════════════════════════════════
   RESPONSIVE — MOBILE FIRST
════════════════════════════════════════ */

/* ── 480px+ ── */
@media (min-width: 480px) {
  .topbar-gov, .topbar-sep { display: block; }
  .kb-status-text { display: inline; }
  .d-md { display: inline; }
}

/* ── 640px+ ── */
@media (min-width: 640px) {
  .topbar { padding: 0 20px; }
  .input-bar { padding: 14px 20px 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  #messagesList { padding: 0 24px; }
  .welcome { padding: 0 28px; }
  .model-pill { padding: 5px 14px; }
  .lang-btn { padding: 5px 13px; }
  .toast-stack { bottom: 100px; }
}

/* ── 768px+ (Tablet) — sidebar pushes content ── */
@media (min-width: 768px) {
  .sidebar {
    transform: translateX(0);
    position: relative; /* part of flow, not overlay */
    height: 100vh;
    flex-shrink: 0;
  }
  .sb-close { display: none !important; }
  .sidebar-overlay { display: none !important; }

  /* Layout becomes row */
  body { display: flex; height: 100vh; overflow: hidden; }
  .sidebar { position: sticky; top: 0; height: 100vh; }
  .layout-main { flex: 1; min-width: 0; height: 100vh; }

  /* Menu button still toggles on tablet for space saving */
  .btn-menu { display: flex; }
  .topbar-name { font-size: 16px; }
  .gov-ribbon-sub { display: block; }
}

/* ── 1024px+ (Desktop) ── */
@media (min-width: 1024px) {
  :root { --sidebar-w: 300px; }
  .topbar { height: 60px; }
  .topbar-name { font-size: 17px; }
  .model-pill select { font-size: 13px; }
  .input-box textarea { font-size: 15px; }
  .msg-bubble { font-size: 14.5px; }
  .welcome-title { font-size: 40px; }
}

/* ── 1280px+ ── */
@media (min-width: 1280px) {
  :root { --sidebar-w: 310px; }
  #messagesList { max-width: 860px; }
  .input-wrap { max-width: 860px; }
  .welcome { max-width: 720px; }
}

/* ── Touch device tweaks ── */
@media (hover: none) and (pointer: coarse) {
  .topic-chip { padding: 10px 12px; }
  .btn-tts { padding: 5px 10px; }
  .ib-btn, .ib-send { width: 40px; height: 40px; }
}

/* ── High contrast / accessibility ── */
@media (forced-colors: active) {
  .model-live, .kb-status-dot { forced-color-adjust: none; }
}

/* ── Print ── */
@media print {
  .sidebar, .topbar, .gov-ribbon, .input-bar { display: none; }
  .messages-wrap { overflow: visible; height: auto; }
}
