:root {
  --bg: #050710;
  --bg-alt: #0c0f1a;
  --sidebar-bg: #070914;
  --border: #262b40;
  --accent: #4cc9f0;
  --accent-soft: rgba(76, 201, 240, 0.16);
  --text-main: #f5f7ff;
  --text-soft: #a5afd9;
  --text-muted: #6c7394;
  --danger: #ff5c7a;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.55);
  --font-main: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-main);
  background: radial-gradient(circle at top, #1a2240 0, #050710 40%, #000 100%);
  color: var(--text-main);
}

/* Layout general */

#app {
  min-height: 100vh;
  display: flex;
}

/* Sidebar */

#sidebar {
  width: 320px;
  max-width: 100%;
  background: linear-gradient(180deg, var(--sidebar-bg), #050710);
  border-right: 1px solid var(--border);
  padding: 16px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 6px 0 28px rgba(0, 0, 0, 0.6);
}

.sidebar-header {
  padding: 10px 12px;
  border-radius: var(--radius-lg);
  background: radial-gradient(circle at top left, #222856, #070914);
  border: 1px solid rgba(110, 125, 255, 0.35);
}

.agent-name {
  font-weight: 700;
  font-size: 16px;
}

.agent-sub {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 2px;
}

/* Bloque de contexto */

.chat-context {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(8, 11, 30, 0.9);
  border: 1px dashed rgba(92, 99, 153, 0.6);
}

.chat-context h2,
.options h2 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}

.msg {
  font-size: 12px;
  line-height: 1.4;
  margin: 4px 0;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
}

.msg-user {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.msg-agent {
  background: rgba(76, 201, 240, 0.06);
  border: 1px solid var(--accent-soft);
}

.msg .from {
  font-weight: 600;
  margin-right: 4px;
  color: var(--accent);
}

/* Lista de opciones */

.options {
  flex: 1;
  display: flex;
  flex-direction: column;
}

#optionsList {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  max-height: 100%;
}

.option-item {
  margin-bottom: 6px;
}

.option-btn {
  width: 100%;
  text-align: left;
  background: rgba(12, 16, 40, 0.9);
  border-radius: var(--radius-md);
  border: 1px solid rgba(58, 67, 130, 0.8);
  padding: 8px 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.16s ease-out;
}

.option-btn span.idx {
  padding: 3px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  font-size: 11px;
  color: var(--accent);
  flex-shrink: 0;
}

.option-btn span.title {
  flex: 1;
}

.option-btn:hover {
  border-color: var(--accent);
  background: rgba(22, 30, 72, 0.95);
  transform: translateY(-1px);
}

.option-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(76, 201, 240, 0.2),
    0 0 32px rgba(76, 201, 240, 0.22);
}

/* Main */

#main {
  flex: 1;
  padding: 20px 26px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#main-header {
  background: rgba(6, 10, 30, 0.9);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  border: 1px solid rgba(53, 61, 110, 0.9);
  box-shadow: var(--shadow-soft);
}

#diagramTitle {
  margin: 0 0 4px;
  font-size: 18px;
}

#diagramSubtitle {
  margin: 0;
  font-size: 13px;
  color: var(--text-soft);
}

/* Contenedor del diagrama */

#diagramContainer {
  flex: 1;
  background: radial-gradient(circle at top, #151b3a, #050710);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(53, 61, 110, 0.9);
  padding: 12px 18px 18px;
  box-shadow: var(--shadow-soft);
  overflow: auto;
}

/* Ajustes para los SVG de Mermaid */

#diagramContainer svg {
  max-width: 100%;
  height: auto;
}

/* Responsive */

@media (max-width: 900px) {
  #app {
    flex-direction: column;
  }

  #sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.6);
  }

  #main {
    padding: 16px;
  }
}
