:root{
  --bg0:#070A14; --bg1:#0B1020;
  --card: rgba(255,255,255,0.06);
  --border: rgba(255,255,255,0.10);
  --text:#EAF0FF; --muted: rgba(234,240,255,0.75);
  --pink:#F2187D; --blue:#143C8C;

  --good:#10b981; --bad:#ef4444;
  --shadow: 0 22px 70px rgba(0,0,0,0.55);
  --shadow2: 0 16px 30px rgba(0,0,0,0.35);

  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  --ring: 0 0 0 3px rgba(242,24,125,0.18);

  --radius-lg: 22px;
  --radius-md: 18px;
}

*{ box-sizing:border-box; }
html, body{ height: 100%; }

body{
  margin:0;
  overflow: hidden;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 20% 10%, rgba(242,24,125,0.22), transparent 60%),
    radial-gradient(900px 500px at 80% 20%, rgba(20,60,140,0.22), transparent 55%),
    linear-gradient(180deg, var(--bg0) 0%, var(--bg1) 100%);
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 18px;
}

/* Main card */
.app{
  width: min(1220px, 100%);
  height: calc(100vh - 36px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 16px;
  overflow: hidden;
  position: relative;
  backdrop-filter: blur(10px);
}

/* Layout */
.layout{
  height: 100%;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 14px;
  overflow: hidden;
}

.layout.sb-collapsed{ grid-template-columns: 1fr; }
.layout.sb-collapsed .sidebar{ display:none; }

@media (max-width: 980px){
  .layout{ grid-template-columns: 1fr; }
  .sidebar{ display:none; }
}

/* Sidebar */
.sidebar{
  height: 100%;
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  display:flex;
  flex-direction: column;
  overflow: hidden;
}

.sbTop{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
}

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

.sbLogo{
  width: 34px; height: 34px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--pink), #6B5BFF 50%, var(--blue));
  box-shadow: 0 0 22px rgba(242,24,125,0.22);
  border: 1px solid rgba(255,255,255,0.10);
}

.sbTitle{ font-weight: 950; font-size: 14px; line-height: 1.1; }
.sbSub{
  margin-top: 2px;
  font-size: 12px;
  opacity: 0.72;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.sbIconBtn{
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  padding: 8px 10px;
  font-weight: 900;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.sbIconBtn:hover{
  transform: translateY(-1px);
  box-shadow: var(--shadow2);
  background: rgba(255,255,255,0.08);
}

.sbSearchWrap{ margin-top: 12px; }
.sbSearch{
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
  font-weight: 750;
}
.sbSearch:focus{ box-shadow: var(--ring); }

.sbList{
  margin-top: 12px;
  overflow-y: auto;
  padding-right: 6px;
  flex: 1;
}

.q-item{
  padding: 10px 12px;
  border-radius: 14px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.35;
  opacity: 0.92;
  border: 1px solid transparent;
  transition: background .12s ease, border-color .12s ease, transform .12s ease;
  user-select: none;
}
.q-item:hover{
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.10);
  transform: translateY(-1px);
}
.q-item.active{
  background: rgba(242,24,125,0.10);
  border-color: rgba(242,24,125,0.26);
  box-shadow: 0 10px 26px rgba(242,24,125,0.12);
}
.q-meta{ margin-top: 6px; font-size: 11px; opacity: 0.60; }

.sbFooter{
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
}

.sbBtn{
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  padding: 10px 12px;
  font-weight: 850;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.sbBtn:hover{
  transform: translateY(-1px);
  box-shadow: var(--shadow2);
}
.sbHint{ font-size: 11px; opacity: 0.68; }

/* Main chat */
.mainChat{
  height: 100%;
  display:flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  position: relative; /* needed for micFab positioning */
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
}

.brand{ display:flex; align-items:center; gap:10px; }
.dot{
  width:12px; height:12px; border-radius:999px;
  background: linear-gradient(135deg, var(--pink), var(--blue));
  box-shadow: 0 0 18px rgba(242,24,125,0.35);
}
.title{ font-weight: 950; font-size: 18px; line-height: 1.0; }
.sub{ font-size: 12px; color: var(--muted); margin-top: 2px; }

.topActions{ display:flex; align-items:center; gap:10px; flex-wrap: wrap; }

.toggleBtn{
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 900;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  cursor:pointer;
}
.toggleBtn:hover{ background: rgba(255,255,255,0.08); }

.badge{
  display:inline-flex; align-items:center; gap:8px;
  padding: 8px 12px; border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  font-size: 13px; white-space: nowrap;
}
.led{
  width:8px; height:8px; border-radius:999px;
  background: var(--bad);
  box-shadow: 0 0 12px rgba(239,68,68,0.35);
}
.led.ok{
  background: var(--good);
  box-shadow: 0 0 12px rgba(16,185,129,0.35);
}

.controls{
  margin-top: 12px;
  display:flex;
  gap:10px;
  flex-wrap: wrap;
  align-items:center;
  justify-content:space-between;
}
.left-controls, .right-controls{
  display:flex; gap:10px; flex-wrap: wrap; align-items:center;
}

select, button{
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  padding: 10px 12px;
  font-weight: 850;
  outline: none;
}
button{
  cursor:pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
button:hover{ transform: translateY(-1px); box-shadow: var(--shadow2); }
button:focus{ box-shadow: var(--ring); }

.muted{ font-weight: 750; opacity: .92; }
.tiny{ font-size: 12px; opacity: .75; }

.chatShell{
  flex: 1;
  min-height: 0;
  overflow: hidden;
  margin-top: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.22);
}
.chatbox{
  height: 100%;
  overflow-y: auto;
  padding: 18px 18px 110px 18px;
}

.row{ display:flex; gap: 10px; margin: 14px 0; }
.row.user{ justify-content: flex-end; }
.row.system{ justify-content: flex-start; }

.bubble{
  max-width: 78%;
  border-radius: 22px;
  padding: 12px 16px;
  line-height: 1.55;
  font-size: 15px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.bubble.user{
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  padding: 12px 18px;
}

.bubble.system{
  background: transparent;
  border: none;
  padding: 0;
  border-radius: 0;
  max-width: 82%;
}
.bubble.system .systemCard{
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 18px;
  padding: 14px 16px;
}

.meta{ margin-top: 6px; font-size: 11px; opacity: 0.55; }

.sysAvatar{
  width: 22px; height: 22px;
  flex: 0 0 22px;
  border-radius: 8px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  margin-top: 2px;
}
.sysAvatar svg{ width: 14px; height: 14px; opacity: 0.9; }

.row.partial{ justify-content:flex-end; opacity:0.65; }
.bubble.partial{
  background: rgba(255,255,255,0.06);
  border: 1px dashed rgba(255,255,255,0.18);
  border-radius: 999px;
  padding: 10px 16px;
}

/* Footer */
.footer{
  margin-top: 12px;
  display:flex;
  flex-direction: column;
  gap:10px;
}

.inputRow{
  display:flex;
  gap:8px;
  align-items:center;
  width: 100%;
}

.textInput{
  flex: 1;
  min-width: 0; /* important for flex shrinking */
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
  font-weight: 800;
  width: 100%;
}
.textInput:focus{ box-shadow: var(--ring); }

.sendBtn{ 
  border-radius: 16px; 
  padding: 12px 16px; 
  font-weight: 900; 
  white-space: nowrap;
}
/* ✅ Mic: SIDE RAIL (right-center), smaller & pro */
.micFab{
  position: relative;
  width: 44px;  /* slightly smaller */
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: linear-gradient(135deg, var(--pink) 0%, #6B5BFF 45%, var(--blue) 100%);
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  z-index: 5;
  flex-shrink: 0; /* prevent shrinking */
}
.micFab:hover{
  transform: translateY(-1px);
  filter: brightness(1.03);
  box-shadow: 0 16px 40px rgba(0,0,0,0.45);
}
.micFab:active{ transform: scale(0.96); }

.micIcon{ 
  width: 18px; 
  height: 18px; 
  fill: rgba(255,255,255,0.96); 
}

/* Listening pulse animation */
@keyframes micPulse {
  0%   { box-shadow: 0 12px 30px rgba(0,0,0,0.35), 0 0 0 0 rgba(242,24,125,0.30); }
  70%  { box-shadow: 0 12px 30px rgba(0,0,0,0.35), 0 0 0 12px rgba(242,24,125,0.00); }
  100% { box-shadow: 0 12px 30px rgba(0,0,0,0.35), 0 0 0 0 rgba(242,24,125,0.00); }
}
.micFab.listening{
  animation: micPulse 1.25s ease-out infinite;
  filter: brightness(1.06);
}
/* =========================================================
   ✅ Footer icons: Mic beside Send + Send as icon
   - Keeps layout compact and professional
========================================================= */
.iconBtn{
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease, filter .12s ease;
  flex: 0 0 auto;
}
.iconBtn:hover{ transform: translateY(-1px); box-shadow: var(--shadow2); background: rgba(255,255,255,0.08); }
.iconBtn:active{ transform: scale(0.97); }

.iconBtn .icon{
  width: 18px;
  height: 18px;
  fill: rgba(255,255,255,0.96);
}

/* Mic keeps the Sampurna gradient like the brand button */
.micBtn{
  background: linear-gradient(135deg, var(--pink) 0%, #6B5BFF 45%, var(--blue) 100%);
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
}
.micBtn:hover{ filter: brightness(1.03); }

/* Listening pulse animation (same behavior as old micFab) */
@keyframes micPulseSmall {
  0%   { box-shadow: 0 12px 30px rgba(0,0,0,0.35), 0 0 0 0 rgba(242,24,125,0.30); }
  70%  { box-shadow: 0 12px 30px rgba(0,0,0,0.35), 0 0 0 12px rgba(242,24,125,0.00); }
  100% { box-shadow: 0 12px 30px rgba(0,0,0,0.35), 0 0 0 0 rgba(242,24,125,0.00); }
}
.micBtn.listening{
  animation: micPulseSmall 1.25s ease-out infinite;
  filter: brightness(1.06);
}

/* Send icon stays clean (no gradient) */
.sendBtn{
  background: rgba(255,255,255,0.08);
}

/* Make sure footer input row stays tight on small screens */
@media (max-width: 520px){
  .iconBtn{ width: 42px; height: 42px; border-radius: 14px; }
  .iconBtn .icon{ width: 17px; height: 17px; }
}
