/* ── Chat Widget SRW ── */
#srw-chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5FA3D5 0%, #7ABBE8 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(74,142,200,0.40);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  transition: transform 0.2s, box-shadow 0.2s;
}
#srw-chat-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(74,142,200,0.50);
}
#srw-chat-toggle svg { width: 26px; height: 26px; fill: #fff; }

@keyframes srw-nudge {
  0%   { transform: translateY(0)    rotate(0deg);  }
  18%  { transform: translateY(-4px) rotate(-9deg); }
  36%  { transform: translateY(0)    rotate(9deg);  }
  54%  { transform: translateY(-3px) rotate(-6deg); }
  72%  { transform: translateY(0)    rotate(6deg);  }
  86%  { transform: translateY(-2px) rotate(-3deg); }
  100% { transform: translateY(0)    rotate(0deg);  }
}
#srw-chat-toggle.nudge {
  animation: srw-nudge 0.7s ease-in-out;
}

#srw-chat-panel {
  position: fixed;
  bottom: 86px;
  right: 24px;
  width: 340px;
  max-height: 520px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 40px rgba(26,35,64,0.18);
  display: flex;
  flex-direction: column;
  z-index: 8999;
  overflow: hidden;
  border: 1px solid #D8E8F4;
  opacity: 0;
  transform: translateY(12px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
#srw-chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
html.dark #srw-chat-panel {
  background: #1E293B;
  border-color: #1E3A5F;
  box-shadow: 0 8px 40px rgba(0,0,0,0.45);
}

#srw-chat-header {
  background: linear-gradient(135deg, #5FA3D5 0%, #7ABBE8 100%);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#srw-chat-header .srw-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.srw-header-title { flex: 1; }
#srw-chat-header h3 {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}
#srw-chat-header p {
  margin: 0;
  font-size: 0.70rem;
  color: rgba(255,255,255,0.82);
}
.srw-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
#srw-contact-btn {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 6px;
  padding: 3px 7px;
  cursor: pointer;
  font-size: 0.82rem;
  line-height: 1;
}
#srw-contact-btn:hover { background: rgba(255,255,255,0.30); }
#srw-chat-close {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.85);
  font-size: 1.2rem;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  flex-shrink: 0;
}
#srw-chat-close:hover { color: #fff; }

#srw-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.srw-msg {
  max-width: 88%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 0.82rem;
  line-height: 1.5;
  word-break: break-word;
}
.srw-msg-bot {
  background: #EBF5FF;
  color: #1A2340;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
html.dark .srw-msg-bot { background: #1E3A5F; color: #E2EEF8; }
.srw-msg-user {
  background: linear-gradient(135deg, #5FA3D5 0%, #7ABBE8 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}
.srw-msg code {
  background: rgba(0,0,0,0.10);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.78rem;
  font-family: monospace;
}
html.dark .srw-msg code { background: rgba(255,255,255,0.12); }
.srw-msg pre {
  background: #272822;
  color: #F8F8F2;
  padding: 8px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 6px 0;
  font-size: 0.76rem;
}
.srw-msg a { color: #4A8EC8; }
html.dark .srw-msg a { color: #60A5FA; }

.srw-typing {
  display: flex;
  gap: 4px;
  padding: 10px 12px;
  align-self: flex-start;
}
.srw-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7ABBE8;
  animation: srw-bounce 1.2s infinite;
}
.srw-typing span:nth-child(2) { animation-delay: 0.2s; }
.srw-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes srw-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* ── Formulario de contacto ── */
.srw-contact-form {
  background: #F0F7FF;
  border: 1px solid #C8D4E0;
  border-radius: 12px;
  padding: 12px;
  align-self: stretch;
  max-width: 100%;
}
html.dark .srw-contact-form {
  background: #1A2E45;
  border-color: #2A4A6A;
}
.srw-contact-form p {
  font-size: 0.80rem;
  color: #374151;
  margin: 0 0 8px 0;
  line-height: 1.4;
}
html.dark .srw-contact-form p { color: #B0C4D8; }
.srw-contact-form textarea {
  width: 100%;
  border: 1px solid #C8D4E0;
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 0.80rem;
  resize: vertical;
  min-height: 72px;
  font-family: inherit;
  background: #fff;
  color: #1A2340;
  outline: none;
  box-sizing: border-box;
  display: block;
}
.srw-contact-form textarea:focus { border-color: #5FA3D5; }
html.dark .srw-contact-form textarea {
  background: #0F172A;
  border-color: #334155;
  color: #E2EEF8;
}
.srw-contact-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 8px;
}
.srw-contact-cancel {
  background: none;
  border: 1px solid #C8D4E0;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.78rem;
  cursor: pointer;
  color: #5A6E84;
  font-family: inherit;
}
html.dark .srw-contact-cancel { border-color: #334155; color: #8FA3B8; background: none; }
.srw-contact-send {
  background: linear-gradient(135deg, #5FA3D5 0%, #7ABBE8 100%);
  border: none;
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  font-family: inherit;
}
.srw-contact-send:disabled { opacity: 0.5; cursor: default; }

#srw-chat-footer {
  padding: 10px 10px 12px;
  border-top: 1px solid #D8E8F4;
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
html.dark #srw-chat-footer { border-color: #1E3A5F; }
#srw-chat-input {
  flex: 1;
  border: 1px solid #C8D4E0;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.82rem;
  outline: none;
  resize: none;
  height: 38px;
  max-height: 100px;
  line-height: 1.4;
  font-family: inherit;
  background: #fff;
  color: #1A2340;
  transition: border-color 0.15s;
}
#srw-chat-input:focus { border-color: #5FA3D5; }
html.dark #srw-chat-input {
  background: #0F172A;
  border-color: #334155;
  color: #E2EEF8;
}
html.dark #srw-chat-input::placeholder { color: #4E6480; }
#srw-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: linear-gradient(135deg, #5FA3D5 0%, #7ABBE8 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
#srw-chat-send:hover { opacity: 0.88; }
#srw-chat-send:disabled { opacity: 0.45; cursor: default; }
#srw-chat-send svg { width: 18px; height: 18px; fill: #fff; }

@media (max-width: 480px) {
  #srw-chat-panel { width: calc(100vw - 24px); right: 12px; bottom: 80px; }
  #srw-chat-toggle { right: 12px; bottom: 16px; }
}
