/* =====================================================================================
   Menú lateral de agentes + tarjeta del agente seleccionado.
   Paleta y medidas tomadas de assets/lateral_menu_agents/Chainlit Agentes.dc.html.
   ===================================================================================== */

:root {
  --ag-bg: #1d1d1d;
  --ag-panel: #171717;
  --ag-border: #2b2b2b;
  --ag-card: #1f1f1f;
  --ag-card-2: #232323;
  --ag-hover: #242424;
  --ag-text: #ececec;
  --ag-dim: #8b8b8b;
  --ag-dim-2: #6f6f6f;
  --ag-accent: #ff0b63;
  --ag-accent-soft: #2a1a21;
  --ag-sidebar-w: 300px;
}

/* El tema claro de Chainlit dejaría el panel oscuro flotando sobre fondo blanco. */
html:not(.dark) {
  --ag-panel: #f7f7f8;
  --ag-border: #e4e4e7;
  --ag-card: #ffffff;
  --ag-card-2: #fafafa;
  --ag-hover: #f0f0f1;
  --ag-text: #1d1d1d;
  --ag-dim: #6b6b6b;
  --ag-dim-2: #8a8a8a;
  --ag-accent-soft: #fde7ef;
}

#agents-sidebar,
#agents-sidebar * {
  box-sizing: border-box;
  font-family: Inter, -apple-system, "Segoe UI", sans-serif;
}

/* ---- Panel ------------------------------------------------------------------------ */
#agents-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--ag-sidebar-w);
  height: 100vh;
  background: var(--ag-panel);
  border-right: 1px solid var(--ag-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 40;
  color: var(--ag-text);
  transition: transform .18s ease;
}

#agents-sidebar.collapsed {
  transform: translateX(-100%);
}

/* Se empuja la app en lugar de superponer el panel, para no tapar el chat. */
body.agents-open #root {
  margin-left: var(--ag-sidebar-w);
  width: calc(100% - var(--ag-sidebar-w));
}

.ag-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 12px 12px 16px;
  flex: none;
}

.ag-dots {
  display: grid;
  grid-template-columns: 7px 7px;
  grid-template-rows: 7px 7px;
  gap: 2px;
  flex: none;
}

.ag-dots i { background: var(--ag-accent); border-radius: 50%; }
.ag-dots i:nth-child(2), .ag-dots i:nth-child(3) { opacity: .55; }

.ag-title { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }

.ag-count {
  margin-left: auto;
  font-size: 11px;
  color: #767676;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ag-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  color: #bdbdbd;
  background: none;
  border: 0;
  flex: none;
}

.ag-toggle:hover { background: var(--ag-hover); color: var(--ag-text); }

/* Botón flotante para recuperar el panel cuando está oculto. */
#agents-reopen {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 41;
  display: none;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--ag-hover);
  color: var(--ag-text);
  border: 1px solid var(--ag-border);
  cursor: pointer;
}

body:not(.agents-open) #agents-reopen { display: flex; }

.ag-search { padding: 0 12px 10px 12px; flex: none; }

.ag-search input {
  width: 100%;
  background: var(--ag-hover);
  border: 1px solid #2f2f2f;
  border-radius: 10px;
  padding: 8px 11px;
  color: var(--ag-text);
  font-size: 12.5px;
  outline: none;
}

.ag-search input:focus { border-color: #4a4a4a; }
.ag-search input::placeholder { color: #7e7e7e; }

.ag-tree { flex: 1; overflow-y: auto; padding: 2px 8px 16px 8px; }
.ag-tree::-webkit-scrollbar { width: 8px; }
.ag-tree::-webkit-scrollbar-thumb { background: #3a3a3a; border-radius: 8px; }
.ag-tree::-webkit-scrollbar-track { background: transparent; }

/* ---- Niveles del árbol ------------------------------------------------------------- */
.ag-div > .ag-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 8px;
  cursor: pointer;
  border-radius: 8px;
}

.ag-div > .ag-row:hover { background: #1f1f1f; }

.ag-div > .ag-row .ag-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ag-dim);
  line-height: 1.35;
}

.ag-rama > .ag-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px 6px 19px;
  cursor: pointer;
  border-radius: 8px;
}

.ag-rama > .ag-row:hover { background: #1f1f1f; }
.ag-rama > .ag-row .ag-label { font-size: 12.5px; font-weight: 500; color: #cfcfcf; }

.ag-materia {
  padding: 7px 8px 4px 34px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ag-dim-2);
}

.ag-chev { font-size: 9px; color: #6e6e6e; width: 8px; flex: none; }

.ag-agent {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px 7px 34px;
  margin: 1px 0;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  border: 0;
  width: 100%;
  text-align: left;
}

.ag-agent:hover { background: var(--ag-hover); }

.ag-agent .ag-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex: none;
  background: #4a4a4a;
}

.ag-agent .ag-name {
  font-size: 12.5px;
  line-height: 1.35;
  color: #bdbdbd;
  text-wrap: pretty;
}

.ag-agent.active { background: var(--ag-accent-soft); }
.ag-agent.active .ag-dot { background: var(--ag-accent); }
.ag-agent.active .ag-name { color: #ffffff; font-weight: 500; }

.ag-empty {
  padding: 24px 12px;
  font-size: 12.5px;
  color: var(--ag-dim-2);
  text-align: center;
}

/* ---- Tarjeta del agente ------------------------------------------------------------ */
#agent-card {
  max-width: 880px;
  margin: 10px auto 4px auto;
  border: 1px solid #2c2c2c;
  background: var(--ag-card);
  border-radius: 14px;
  overflow: hidden;
  color: var(--ag-text);
  font-family: Inter, -apple-system, "Segoe UI", sans-serif;
}

.ac-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }

.ac-icon {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 8px;
  background: #2b1620;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ac-icon i { width: 9px; height: 9px; border-radius: 50%; background: var(--ag-accent); }

.ac-meta { min-width: 0; }

.ac-name {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ac-path {
  font-size: 11px;
  color: #7e7e7e;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ac-docs-btn {
  margin-left: auto;
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid #333;
  border-radius: 999px;
  font-size: 12px;
  color: #c9c9c9;
  cursor: pointer;
  background: none;
  white-space: nowrap;
}

.ac-docs-btn:hover { background: #272727; border-color: #3f3f3f; }

.ac-docs {
  border-top: 1px solid #2c2c2c;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
  background: #1b1b1b;
}

.ac-docs.hidden { display: none; }

.ac-doc {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--ag-card-2);
  border: 1px solid #2e2e2e;
  border-radius: 10px;
}

.ac-doc:hover { border-color: #3d3d3d; }
.ac-doc .ac-doc-ico { font-size: 12px; color: var(--ag-dim); line-height: 1.4; }
.ac-doc-name { font-size: 12.5px; line-height: 1.4; color: #e2e2e2; text-wrap: pretty; }

.ac-doc-tag {
  font-size: 10.5px;
  margin-top: 4px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.ac-doc-tag.main { color: var(--ag-accent); }
.ac-doc-tag.base { color: #7e7e7e; }

@media (max-width: 900px) {
  #agents-sidebar { width: 86vw; }
  body.agents-open #root { margin-left: 0; width: 100%; }
}
