:root{
  --bg:#0b1220;
  --bg2:#101a2e;
  --card:#ffffff;
  --text:#e7eefc;
  --muted:#9db0d2;
  --line:rgba(0,0,0,.08);
  --btn:#1f6feb;
}

*{box-sizing:border-box}

html,body{
  margin:0;
  padding:0;
  height:100%;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial;
  background:#f6f7fb;
  color:#111;
}

/* ---------- Header ---------- */
.topbar{
  position:sticky;
  top:0;
  z-index:20;
  background:linear-gradient(180deg,var(--bg),var(--bg2));
  color:var(--text);
  padding:12px 16px;
}

.title{
  font-size:20px;
  font-weight:800;
}

.subtitle{
  font-size:12px;
  color:var(--muted);
}

/* ---------- Buttons ---------- */
.btn{
  background:var(--btn);
  color:#fff;
  border:none;
  border-radius:12px;
  padding:10px 14px;
  font-weight:700;
}

.btn.ghost{
  background:transparent;
  color:#fff;
  border:1px solid rgba(255,255,255,.2);
}

.iconBtn{
  width:38px;
  height:38px;
  border-radius:10px;
  border:1px solid var(--line);
  background:#fff;
  font-size:18px;
  font-weight:700;
}

/* ---------- Layout ---------- */
.container{
  max-width:980px;
  margin:0 auto;
  padding:12px;
}

.panel{
  background:#fff;
  border-radius:18px;
  padding:14px;
  box-shadow:0 8px 20px rgba(0,0,0,.06);
}

/* ---------- Tabs ---------- */
.tabs{
  display:flex;
  gap:8px;
  margin-bottom:12px;
}

.tab{
  flex:1;
  text-align:center;
  padding:10px;
  border-radius:999px;
  background:#eef2ff;
  font-weight:700;
}

/* ---------- Inbox ---------- */
.list{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.item{
  background:#fff;
  border-radius:16px;
  padding:14px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  box-shadow:0 4px 12px rgba(0,0,0,.06);
}

.badge{
  background:#eef2ff;
  padding:4px 10px;
  border-radius:999px;
  font-size:13px;
  font-weight:700;
}

.badge.blue{
  background:#1f6feb;
  color:#fff;
}

/* ---------- Chat ---------- */
#viewDetail{
  display:flex;
  flex-direction:column;
  height:calc(100vh - 64px);
}

.msgsWrap{
  flex:1;
  overflow-y:auto;
  padding:8px;
}

.msg{
  margin-bottom:10px;
}

.msgRow{
  display:flex;
  gap:10px;
}

.avatar{
  width:36px;
  height:36px;
  border-radius:50%;
  color:#fff;
  font-weight:800;
  display:flex;
  align-items:center;
  justify-content:center;
}

.msgBody{
  flex:1;
  background:#f6f7fb;
  border-radius:14px;
  padding:10px;
}

.muted{
  color:#667;
  font-size:12px;
}

/* ---------- Composer ---------- */
.composer{
  position:sticky;
  bottom:0;
  background:#fff;
  padding:10px;
  display:flex;
  gap:10px;
  border-top:1px solid var(--line);
}

textarea{
  flex:1;
  resize:none;
  border-radius:14px;
  padding:10px;
  border:1px solid var(--line);
  font-size:15px;
}

/* ---------- Mobile ---------- */
@media (max-width: 640px){
  .container{padding:8px}
  .panel{padding:10px}
}

/* --- Cliente/Proyecto selects --- */
.tagbar{
  display:flex;
  gap:8px;
  width:100%;
  margin-bottom:8px;
}
.tagbar select{
  flex:1;
  border-radius:12px;
  padding:10px;
  border:1px solid var(--line);
  background:#fff;
  font-size:14px;
}
@media (max-width: 640px){
  .tagbar{flex-direction:column}
}
.tagpill{
  display:inline-block;
  font-size:12px;
  font-weight:700;
  padding:4px 10px;
  border-radius:999px;
  background:#eef2ff;
  margin-right:6px;
}

/* --- Composer always visible --- */
.composerRow{
  display:flex;
  gap:10px;
  align-items:flex-end;
}
.composerRow textarea{
  flex:1;
}
.tagbar{
  display:flex;
  gap:8px;
  width:100%;
  margin-bottom:8px;
}
.tagbar select{
  flex:1;
  border-radius:12px;
  padding:10px;
  border:1px solid var(--line);
  background:#fff;
  font-size:14px;
}
@media (max-width: 640px){
  .tagbar{flex-direction:column}
}

/* --- Tags en mensajes --- */
.tagpill{
  display:inline-block;
  font-size:12px;
  font-weight:800;
  padding:4px 10px;
  border-radius:999px;
  background:#eef2ff;
  margin-right:6px;
  margin-top:2px;
}

/* --- Autocomplete (@ y /) --- */
.suggestBox{
  position:sticky;
  bottom:0;
  margin-top:8px;
  border:1px solid var(--line);
  border-radius:14px;
  background:#fff;
  overflow:hidden;
  box-shadow:0 8px 20px rgba(0,0,0,.10);
}
.suggestItem{
  padding:10px 12px;
  font-weight:700;
  border-bottom:1px solid rgba(0,0,0,.06);
}
.suggestItem:last-child{border-bottom:none}
.suggestItem:hover{background:#f2f5ff; cursor:pointer}

/* --- Autocomplete dropdown: arriba del input, no al costado --- */
.composer{ position:sticky; bottom:0; }
.composer{ position:relative; } /* importante: referencia para absolute */

.suggestBox{
  position:absolute !important;
  left:10px;
  right:10px;
  bottom:90px;           /* queda arriba de textarea+botón */
  max-height:220px;
  overflow:auto;
  z-index:9999;
}

@media (max-width: 640px){
  .suggestBox{ bottom:130px; } /* en mobile hay más alto por selects */
}

/* --- Chips Cliente/Proyecto en mensajes --- */
.tagrow{ margin-top:6px; display:flex; gap:6px; flex-wrap:wrap; }
.tagpill{
  display:inline-flex;
  align-items:center;
  gap:6px;
  font-size:12px;
  font-weight:800;
  padding:4px 10px;
  border-radius:999px;
  background:#eef2ff;
  border:1px solid rgba(31,111,235,.15);
}
.tagpill b{ font-weight:900; }

/* ===== Fix chat para que el composer no tape mensajes ===== */
.msgsWrap{ padding-bottom:160px; }

/* ===== Composer layout ===== */
.composer{ position:sticky; bottom:0; background:#fff; border-top:1px solid var(--line); padding:10px; }
.composerRow{ display:flex; gap:10px; align-items:flex-end; }
.composerRow textarea{ flex:1; resize:none; min-height:46px; }

/* ===== Chips seleccionados (Cliente/Proyecto) ===== */
.chipBar{ display:flex; gap:8px; flex-wrap:wrap; margin-bottom:8px; }
.chip{
  display:inline-flex; align-items:center; gap:8px;
  padding:6px 10px; border-radius:999px;
  background:#eef2ff; border:1px solid rgba(31,111,235,.18);
  font-weight:800; font-size:13px;
}
.chip .x{
  width:18px; height:18px; border-radius:50%;
  display:inline-flex; align-items:center; justify-content:center;
  background:#dbe7ff; cursor:pointer; font-weight:900;
}

/* ===== Dropdown autocompletar ===== */
.suggestBox{
  position:absolute;
  left:10px; right:10px;
  bottom:86px;               /* arriba del textarea */
  background:#fff;
  border:1px solid var(--line);
  border-radius:14px;
  overflow:hidden;
  box-shadow:0 10px 22px rgba(0,0,0,.12);
  max-height:240px;
  overflow:auto;
  z-index:9999;
}
.suggestItem{
  padding:12px 14px;
  font-weight:800;
  border-bottom:1px solid rgba(0,0,0,.06);
  cursor:pointer;
}
.suggestItem:last-child{ border-bottom:none; }
.suggestItem:hover{ background:#f2f5ff; }

@media (max-width: 640px){
  .suggestBox{ bottom:132px; } /* mobile: más alto */
  .msgsWrap{ padding-bottom:210px; }
}

/* --- textarea más grande y cómodo --- */
#bodyInput{
  min-height:72px;
  line-height:1.3;
  padding:12px;
  font-size:16px;
  border-radius:14px;
}
.composerRow{ align-items:stretch; }
.composerRow .btn{ height:48px; align-self:flex-end; }

/* opción activa con teclado */
.suggestItem.active{
  background:#e8f0ff;
}
