:root {
  --verde: #00c83c;
  --verde-dark: #007c20;
  --verde-soft: #f0fdf4;
  --negro: #1a1a1a;
  --gris: #3f3f3f;
  --gris-texto: #52665a;
  --borde: #dde8dd;
  --blanco: #ffffff;
  --naranja: #fe9200;
  --font-body: "Montserrat", system-ui, sans-serif;
  --font-display: "Montserrat", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Montserrat", system-ui, sans-serif;
  font-optical-sizing: auto;
}

html,
body {
  height: 100%;
}

body {
  overflow: hidden;
  font-family: var(--font-body);
  background: var(--verde-soft);
  color: var(--negro);
}

.strip,
.bottom-strip {
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--verde-dark),
    var(--verde),
    #52ef00,
    #9eff66,
    var(--naranja)
  );
}

.header {
  height: 62px;
  background: var(--negro);
  color: var(--blanco);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 140px;
}

.brand-logo {
  height: 34px;
  width: auto;
  display: block;
  object-fit: contain;
}

.header-chip {
  border: 1px solid rgba(0, 200, 60, 0.25);
  background: rgba(0, 200, 60, 0.08);
  color: var(--verde);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
}

.layout {
  height: calc(100vh - 68px);
  display: flex;
  position: relative;
}

/* ============================
   SIDEBAR
============================ */

.sidebar-shell {
  position: relative;
  width: 280px;
  flex-shrink: 0;
  background: var(--negro);
  transition: width 0.28s ease;
  overflow: visible;
}

.sidebar {
  width: 280px;
  height: calc(100vh - 68px);
  background: var(--negro);
  color: var(--blanco);
  padding: 18px 14px;
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  transition: width 0.28s ease, padding 0.28s ease;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

.sidebar-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.32);
  margin: 12px 6px 8px;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.module-button {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 10px;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: 0.18s ease;
}

.module-button:hover {
  background: rgba(255, 255, 255, 0.05);
}

.module-button.active {
  background: rgba(0, 200, 60, 0.11);
  border-color: rgba(0, 200, 60, 0.28);
}

.module-button span {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.07);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.module-button.active span {
  background: var(--verde);
}

.module-button div {
  transition: opacity 0.18s ease, visibility 0.18s ease;
  min-width: 0;
}

.module-button strong {
  display: block;
  color: inherit;
  font-size: 13px;
  font-weight: 600;
}

.module-button small {
  display: block;
  color: rgba(255, 255, 255, 0.32);
  font-size: 11px;
  margin-top: 2px;
}

.sidebar-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 14px 0;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.documents-panel {
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.documents-status {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  padding: 10px;
  border-radius: 10px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.58);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--naranja);
  flex-shrink: 0;
}

.status-dot.ok {
  background: var(--verde);
}

.status-dot.empty {
  background: rgba(255, 255, 255, 0.25);
}

.docs-list {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.doc-item {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.48);
  padding: 7px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  word-break: break-word;
}

.sidebar-note {
  margin: 12px 6px;
  font-size: 11px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.25);
}

.sidebar-toggle {
  position: absolute;
  top: 50%;
  right: -18px;
  transform: translateY(-50%);
  width: 22px;
  height: 88px;
  border: 1px solid rgba(0, 200, 60, 0.18);
  border-left: none;
  border-radius: 0 14px 14px 0;
  background: #111111;
  color: rgba(255, 255, 255, 0.72);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 60;
  box-shadow: 4px 0 10px rgba(0, 0, 0, 0.18);
  transition: background 0.2s ease, color 0.2s ease;
}

.sidebar-toggle:hover {
  background: #1c1c1c;
  color: var(--verde);
}

.sidebar-toggle svg {
  width: 14px;
  height: 14px;
  transition: transform 0.28s ease;
}

.sidebar-shell.collapsed {
  width: 74px;
}

.sidebar-shell.collapsed .sidebar {
  width: 74px;
  padding: 18px 10px;
  overflow-y: hidden;
}

.sidebar-shell.collapsed .sidebar-title,
.sidebar-shell.collapsed .documents-panel,
.sidebar-shell.collapsed .sidebar-divider {
  display: none;
}

.sidebar-shell.collapsed .module-button {
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0 auto 14px auto;
  display: grid;
  place-items: center;
  justify-content: center;
  align-items: center;
  gap: 0;
  border-radius: 14px;
}

.sidebar-shell.collapsed .module-button div {
  display: none;
}

.sidebar-shell.collapsed .module-button span {
  width: 34px;
  height: 34px;
  margin: 0;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.sidebar-shell.collapsed .module-button.active {
  background: rgba(0, 200, 60, 0.13);
  border-color: rgba(0, 200, 60, 0.32);
}

.sidebar-shell.collapsed .module-button.active span {
  background: var(--verde);
}

.sidebar-shell.collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

/* ============================
   CONTENIDO PRINCIPAL
============================ */

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.welcome {
  flex: 1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 20px;
  padding: 36px;
  text-align: center;
}

.welcome-mark {
  width: 76px;
  height: 76px;
  border-radius: 22px;
  background: var(--negro);
  display: grid;
  place-items: center;
  box-shadow: 0 12px 30px rgba(0, 124, 32, 0.16);
  overflow: hidden;
}

.welcome-mark img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  display: block;
}

.welcome h1 {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 400;
  line-height: 1.1;
}

.welcome h1 em {
  color: var(--verde-dark);
}

.welcome p {
  max-width: 540px;
  color: var(--gris-texto);
  line-height: 1.65;
  font-size: 15px;
}

.cards {
  width: min(720px, 100%);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 8px;
}

.welcome-card {
  background: var(--blanco);
  border: 1px solid var(--borde);
  border-radius: 16px;
  padding: 18px;
  cursor: pointer;
  text-align: left;
  display: grid;
  gap: 7px;
  transition: 0.18s ease;
}

.welcome-card:hover {
  border-color: var(--verde);
  box-shadow: 0 10px 24px rgba(0, 124, 32, 0.09);
  transform: translateY(-1px);
}

.welcome-card span {
  font-size: 22px;
}

.welcome-card strong {
  font-size: 14px;
}

.welcome-card small {
  color: var(--gris-texto);
  line-height: 1.45;
}

/* ============================
   CONVERSACIÓN + AVATAR
============================ */

.conversation-shell {
  flex: 1;
  display: none;
  min-height: 0;
  overflow: hidden;
  background: var(--verde-soft);
}

.conversation-shell.active {
  display: flex;
}

.messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 26px 30px;
  overflow-y: auto;
  min-width: 0;
}

.conversation-shell.option-1 .messages {
  width: 70%;
  flex: 0 0 70%;
}

.avatar-panel {
  display: none;
  width: 30%;
  flex: 0 0 30%;
  padding: 26px 28px 26px 10px;
  border-left: 1px solid rgba(0, 124, 32, 0.08);
  background:
    radial-gradient(circle at center, rgba(0, 200, 60, 0.11), transparent 45%),
    linear-gradient(180deg, #f2fff6, #eefbf2);
  align-items: center;
  justify-content: center;
}

.conversation-shell.option-1 .avatar-panel {
  display: flex;
}

.avatar-card {
  width: min(340px, 100%);
  min-height: 460px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(0, 124, 32, 0.12);
  box-shadow: 0 24px 60px rgba(0, 124, 32, 0.12);
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  justify-items: center;
  padding: 18px;
  position: sticky;
  top: 24px;
}

.avatar-status {
  justify-self: start;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(0, 200, 60, 0.1);
  color: var(--verde-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.avatar-frame {
  width: 100%;
  display: grid;
  place-items: center;
  padding: 14px;
}

.avatar-frame img {
  width: 100%;
  max-width: 280px;
  max-height: 360px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 18px 24px rgba(0, 0, 0, 0.16));
}

.avatar-card.speaking {
  border-color: rgba(0, 200, 60, 0.35);
  box-shadow:
    0 24px 60px rgba(0, 124, 32, 0.14),
    0 0 0 6px rgba(0, 200, 60, 0.08);
}

.avatar-card.speaking .avatar-status {
  background: var(--verde);
  color: var(--negro);
}

.avatar-caption {
  color: var(--gris-texto);
  font-size: 12px;
  text-align: center;
  line-height: 1.4;
}

/* ============================
   MENSAJES
============================ */

.message-row {
  display: flex;
  gap: 10px;
}

.message-row.user {
  flex-direction: row-reverse;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 4px;
  font-weight: 600;
}

.avatar.bot {
  background: var(--negro);
  color: var(--verde);
  font-family: var(--font-display);
}

.avatar.bot img {
  width: 21px;
  height: 21px;
  object-fit: contain;
  display: block;
}

.avatar.user {
  background: var(--gris);
  color: var(--blanco);
  font-size: 11px;
}

.bubble {
  max-width: 76%;
  padding: 15px 18px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.bubble.bot {
  background: var(--blanco);
  border: 1px solid var(--borde);
  border-bottom-left-radius: 4px;
}

.bubble.user {
  background: var(--negro);
  color: var(--blanco);
  border-bottom-right-radius: 4px;
}

/* ============================
   INPUT
============================ */

.input-area {
  display: none;
  background: var(--blanco);
  border-top: 1px solid var(--borde);
  padding: 14px 24px;
}

.mode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--gris-texto);
  margin-bottom: 10px;
}

.mode-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-left strong {
  color: var(--verde-dark);
}

.mode-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.home-button {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(0, 124, 32, 0.18);
  background: rgba(0, 200, 60, 0.08);
  color: var(--verde-dark);
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: 0.18s ease;
  flex-shrink: 0;
}

.home-button:hover {
  background: var(--verde);
  color: var(--negro);
  border-color: var(--verde);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 124, 32, 0.15);
}

.home-icon {
  width: 18px;
  height: 18px;
}

.input-row {
  display: flex;
  gap: 9px;
  align-items: flex-end;
}

textarea {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  border-radius: 12px;
  border: 1.5px solid var(--borde);
  padding: 11px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  background: var(--verde-soft);
}

textarea:focus {
  background: var(--blanco);
  border-color: var(--verde);
}

.send-button,
.secondary-button,
.voice-toggle-button,
.mic-button {
  height: 44px;
  border-radius: 12px;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 700;
  flex-shrink: 0;
}

.send-button {
  width: 48px;
  border: none;
  background: var(--negro);
  color: var(--verde);
  font-size: 20px;
}

.send-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.secondary-button {
  border: 1.5px solid var(--borde);
  background: transparent;
  color: var(--gris-texto);
  padding: 0 16px;
}

.secondary-button:hover {
  border-color: var(--verde);
  color: var(--verde-dark);
}

.voice-toggle-button {
  height: 36px;
  border: 1px solid rgba(0, 124, 32, 0.18);
  background: rgba(0, 200, 60, 0.08);
  color: var(--verde-dark);
  border-radius: 999px;
  padding: 0 14px;
  font-size: 11px;
}

.voice-toggle-button.active {
  background: var(--verde);
  color: var(--negro);
  border-color: var(--verde);
}

.voice-toggle-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.mic-button {
  width: 46px;
  border: 1.5px solid var(--borde);
  background: var(--verde-soft);
  color: var(--verde-dark);
  font-size: 18px;
}

.mic-button:hover:not(:disabled) {
  border-color: var(--verde);
  color: var(--verde-dark);
}

.mic-button.active {
  background: var(--verde);
  color: var(--negro);
  border-color: var(--verde);
  box-shadow: 0 0 0 4px rgba(0, 200, 60, 0.12);
}

.mic-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.hint {
  text-align: right;
  color: #a5baa5;
  font-size: 11px;
  margin-top: 6px;
}

.hint.voice-on {
  color: var(--verde-dark);
  font-weight: 600;
}

/* ============================
   RESPONSIVE
============================ */

@media (max-width: 1100px) {
  .conversation-shell.option-1 .messages {
    width: 64%;
    flex-basis: 64%;
  }

  .avatar-panel {
    width: 36%;
    flex-basis: 36%;
    padding-right: 16px;
  }

  .avatar-card {
    min-height: 380px;
  }
}

@media (max-width: 800px) {
  .layout {
    height: calc(100vh - 68px);
  }

  .sidebar-shell {
    display: none;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .bubble {
    max-width: 86%;
  }

  .mode-row {
    align-items: flex-start;
  }

  .input-row {
    flex-wrap: wrap;
  }

  textarea {
    min-width: 100%;
    order: -1;
  }

  .conversation-shell,
  .conversation-shell.option-1 {
    display: none;
  }

  .conversation-shell.active {
    display: flex;
  }

  .conversation-shell.option-1.active {
    flex-direction: column;
  }

  .conversation-shell.option-1 .messages {
    width: 100%;
    flex: 1;
  }

  .conversation-shell.option-1 .avatar-panel {
    display: none;
  }
}