/* Colores institucionales de SUPARA */
:root { --color-primary: #003366; --color-secondary: #0055A0; }

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background: #111b21;
  display: flex;
  justify-content: center;
  align-items: center;
}

.wa-container {
  width: 100%;
  max-width: 500px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #efeae2;
}

.wa-header {
  background: var(--color-primary);
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  z-index: 10;
}

.wa-header-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wa-avatar-wrap {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wa-avatar-wrap svg { filter: drop-shadow(0 1px 1px rgba(0,0,0,0.2)); }

.wa-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wa-header-name {
  color: white;
  font-weight: 700;
  font-size: 17px;
  line-height: 1.2;
}

.wa-header-subtitle {
  color: rgba(255,255,255,0.7);
  font-size: 12px;
}

.wa-header-status {
  color: rgba(255,255,255,0.75);
  font-size: 12px;
}

/* Punto verde de "En linea" */
.wa-online-dot {
  color: #25d366;
}

.wa-menu { position: relative; }

.wa-menu-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  padding: 7px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  font-size: 22px;
  line-height: 1;
  letter-spacing: 1px;
}

.wa-menu-btn:hover {
  background: rgba(255,255,255,0.15);
  color: white;
}

.wa-menu-btn:focus-visible,
.wa-send-btn:focus-visible,
.wa-dropdown button:focus-visible,
.wa-chip:focus-visible,
.wa-retry-btn:focus-visible,
.wa-link-chip:focus-visible {
  outline: 3px solid rgba(255,255,255,0.9);
  outline-offset: 2px;
}

.wa-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: white;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  min-width: 190px;
  z-index: 100;
  overflow: hidden;
}

.wa-dropdown.open { display: block; }

.wa-dropdown button {
  width: 100%;
  padding: 13px 18px;
  background: none;
  border: none;
  text-align: left;
  font-size: 14px;
  font-family: inherit;
  color: #333;
  cursor: pointer;
  transition: background 0.15s;
}

.wa-dropdown button:hover { background: #f5f5f5; }

.wa-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background-color: #efeae2;
  background-image: url(data:image/svg+xml,%3Csvg width=60 height=60 viewBox=0 0 60 60 xmlns=http://www.w3.org/2000/svg%3E%3Cg fill=none fill-rule=evenodd%3E%3Cg fill=%23b2a898 fill-opacity=0.12%3E%3Cpath d=M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z/%3E%3C/g%3E%3C/g%3E%3C/svg%3E);
}

.wa-messages::-webkit-scrollbar { width: 5px; }
.wa-messages::-webkit-scrollbar-track { background: transparent; }
.wa-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.18); border-radius: 3px; }

.message {
  max-width: 78%;
  padding: 7px 10px 20px 10px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.message.user {
  align-self: flex-end;
  background: var(--color-primary);
  color: white;
  border-bottom-right-radius: 2px;
  margin-right: 10px;
}

.message.user::after {
  content: '';
  position: absolute;
  right: -8px;
  bottom: 0;
  border-left: 8px solid var(--color-primary);
  border-top: 8px solid transparent;
}

.message.assistant {
  align-self: flex-start;
  background: white;
  color: #111;
  border-bottom-left-radius: 2px;
  margin-left: 10px;
}

.message.assistant::after {
  content: '';
  position: absolute;
  left: -8px;
  bottom: 0;
  border-right: 8px solid white;
  border-top: 8px solid transparent;
}

.message.assistant a {
  color: var(--color-primary);
  word-break: break-all;
}

.message-sender {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 3px;
}

.wa-bubble-content { white-space: pre-wrap; }

.message.waiting .wa-bubble-content {
  opacity: 0.7;
  font-style: italic;
}

.wa-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 38px;
  height: 20px;
}

.wa-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #87939a;
  animation: waTyping 1.2s infinite ease-in-out;
}

.wa-typing span:nth-child(2) { animation-delay: 0.15s; }
.wa-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes waTyping {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.wa-suggestions {
  align-self: flex-start;
  max-width: calc(100% - 20px);
  margin: 8px 10px 4px;
}

.wa-helper-note {
  color: #54656f;
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 12px;
  line-height: 1.4;
  margin-bottom: 8px;
}

.wa-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.wa-chip {
  border: 1px solid color-mix(in srgb, var(--color-primary) 35%, white);
  background: white;
  color: var(--color-primary);
  border-radius: 16px;
  padding: 8px 11px;
  font: inherit;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.wa-chip:hover {
  background: color-mix(in srgb, var(--color-primary) 8%, white);
}

.wa-link-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  margin-bottom: 2px;
}

.wa-link-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 6px 9px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--color-primary) 10%, white);
  color: var(--color-primary);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
}

.wa-retry-btn {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin-top: 8px;
  padding: 7px 11px;
  border: 1px solid color-mix(in srgb, var(--color-primary) 35%, white);
  border-radius: 15px;
  background: white;
  color: var(--color-primary);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
}

.wa-time {
  position: absolute;
  bottom: 4px;
  right: 8px;
  font-size: 11px;
  color: rgba(255,255,255,0.65);
  white-space: nowrap;
}

.message.assistant .wa-time { color: #aaa; }

.wa-footer {
  background: #f0f2f5;
  padding: 8px 10px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
  border-top: 1px solid #d1d7db;
}

.wa-footer textarea {
  flex: 1;
  border: none;
  outline: none;
  background: white;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  line-height: 1.4;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
  overflow-y: auto;
}

.wa-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--color-primary);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.1s;
  box-shadow: 0 2px 5px rgba(0,0,0,0.25);
}

.wa-send-btn:hover { background: var(--color-secondary); }
.wa-send-btn:active { transform: scale(0.92); }
.wa-send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

@media (max-width: 520px) {
  .wa-container { max-width: 100%; }
  .message { max-width: 85%; font-size: 13px; }
  .wa-chip { font-size: 12px; padding: 8px 10px; }
}

.wa-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: contain;
  background: white;
  padding: 3px;
  border: 2px solid rgba(255,255,255,0.45);
  flex-shrink: 0;
}

/* Aviso de privacidad, siempre visible debajo del cuadro de texto */
.wa-privacy {
  margin: 0;
  padding: 4px 12px;
  /* Margen seguro inferior (barra de inicio del iPhone): el aviso es lo ultimo en pantalla */
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  flex-shrink: 0;
  font-size: 11px;
  line-height: 1.35;
  text-align: center;
  color: #6b7280;
  background: #f0f2f5;
}
