/* ==========================================
   CSETC CHATBOT - PANTALLA COMPLETA
   Basado en el diseño de /web-oaes/chatbot.html
   ========================================== */

/* Reset y Variables Base */
* {
  box-sizing: border-box;
}

:root {
  --color-primary: #755956;
  --color-primary-dark: #5d4643;
  --color-secondary: #937e71;
  --color-text: #332F2E;
  --color-text-light: #6B6360;
  --color-text-lighter: #8C8480;
  --color-bg-light: #FAF9F8;
  --color-bg-lighter: #F5F3F2;
  --color-border: #EAE7E5;
  --font-family: "Frutiger", "Frutiger LT Std", "Helvetica Neue", Arial, sans-serif;
}

/* ==========================================
   BOTÓN FLOTANTE GLOBAL (Launcher)
   ========================================== */
#csetc-launcher {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  background: transparent;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  text-decoration: none;
}

#csetc-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

#csetc-launcher svg {
  width: 60px;
  height: 60px;
  fill: white;
}

/* ==========================================
   CHATBOT PANTALLA COMPLETA
   ========================================== */
.chatbot-page {
  display: flex;
  height: calc(100vh - 96px);
  height: calc(100dvh - 96px);
  overflow: hidden;
  background: var(--color-bg-light);
  font-family: var(--font-family);
}

body.admin-bar .chatbot-page {
  height: calc(100vh - 128px);
  height: calc(100dvh - 128px);
}

@media (max-width: 782px) {
  .chatbot-page {
    height: calc(100vh - 64px);
    height: calc(100dvh - 64px);
  }

  body.admin-bar .chatbot-page {
    height: calc(100vh - 110px);
    height: calc(100dvh - 110px);
  }
}

/* Sidebar */
.chatbot-sidebar {
  width: 300px;
  flex-shrink: 0;
  background: white;
  border-right: 1px solid var(--color-border);
  display: none;
  flex-direction: column;
  padding: 2rem;
  overflow-y: auto;
}

@media (min-width: 1024px) {
  .chatbot-sidebar {
    display: flex;
  }
}

/* Mobile: sidebar as slide-in drawer */
@media (max-width: 1023px) {
  .chatbot-sidebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    width: 300px;
    max-width: 85vw;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    border-right: none;
  }

  .chatbot-sidebar--open {
    transform: translateX(0);
  }
}

/* Overlay */
.chatbot-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 99;
}

.chatbot-sidebar-overlay.active {
  display: block;
}

/* Topbar mobile (título + botón cerrar) */
.chatbot-sidebar__topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
}

@media (max-width: 1023px) {
  .chatbot-sidebar__topbar {
    display: flex;
  }
}

.chatbot-sidebar__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  color: var(--color-text-light);
  transition: background 150ms ease;
  padding: 0;
}

.chatbot-sidebar__close:hover {
  background: var(--color-bg-lighter);
  color: var(--color-text);
}

.chatbot-sidebar__header {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--color-border);
}

.chatbot-sidebar__header h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--color-primary);
}

.chatbot-sidebar__header p {
  font-size: 0.875rem;
  color: var(--color-text-light);
  line-height: 1.5;
  margin: 0;
}

.chatbot-sidebar__suggestions {
  margin-bottom: 2rem;
}

.chatbot-sidebar__suggestions h4 {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-lighter);
  margin-bottom: 1rem;
}

.suggestion-btn {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.875rem;
  background: var(--color-bg-light);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  text-align: left;
  font-size: 0.875rem;
  color: var(--color-text);
  cursor: pointer;
  transition: all 150ms ease;
  margin-bottom: 0.5rem;
}

.suggestion-btn svg {
  flex-shrink: 0;
  color: var(--color-primary);
}

.suggestion-btn:hover {
  background: white;
  border-color: var(--color-primary);
  color: #1A1817;
  transform: translateX(4px);
}

.suggestion-btn:last-child {
  margin-bottom: 0;
}

.chatbot-sidebar__info {
  margin-top: auto;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

.info-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  font-size: 0.875rem;
  color: var(--color-text-light);
}

.info-item svg {
  flex-shrink: 0;
  color: var(--color-secondary);
}

/* Container Principal */
.chatbot-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: white;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;

}

/* Header del Chat */
.chatbot-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--color-border);
  background: white;
}

/* Status row (En línia + FAQs button) */
.chatbot-header__status-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Botón FAQs (solo móvil) */
.chatbot-header__faqs {
  display: none;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  background: var(--color-bg-lighter);
  border: 1px solid var(--color-border);
  border-radius: 0.4rem;
  font-family: var(--font-family);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-text-light);
  cursor: pointer;
  transition: all 150ms ease;
  white-space: nowrap;
  line-height: 1;
}

.chatbot-header__faqs:hover {
  background: white;
  border-color: var(--color-primary);
  color: var(--color-primary);
}

@media (max-width: 1023px) {
  .chatbot-header__faqs {
    display: flex;
  }
}

@media (max-width: 640px) {
  .chatbot-header {
    padding: 0.75rem 1rem;
  }

  .chatbot-messages {
    padding: 0.75rem;
    gap: 1rem;
  }

  .chatbot-input {
    padding: 0.625rem 0.75rem;
  }

  .chatbot-input__hint {
    display: none;
  }

  .chatbot-input__textarea {
    font-size: 0.8rem;
    padding: 0.5rem 0.625rem;
  }

  .message__content {
    max-width: 92%;
  }

  .message__avatar {
    width: 28px;
    height: 28px;
  }

  .message__avatar svg {
    width: 14px;
    height: 14px;
  }
}

.chatbot-header__title {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.chatbot-header__title h2 {
  font-size: 1.25rem;
  margin-bottom: 0;
  margin-top: 0;
}

.chatbot-header__title .status-text {
  font-size: 0.875rem;
  color: var(--color-text-lighter);
}

.chatbot-header__reset {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary-dark);
  border: none;
  border-radius: 0.75rem;
  color: white;
  cursor: pointer;
  transition: all 150ms ease;
  padding: 0;
  flex-shrink: 0;
}

.chatbot-header__reset:hover {
  background: var(--color-primary);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.chatbot-header__reset svg {
  width: 20px !important;
  height: 20px !important;
  stroke: currentColor;
  fill: none;
  display: block;
}

.status-indicator {
  width: 12px;
  height: 12px;
  background: var(--color-secondary);
  border-radius: 50%;
  position: relative;
  animation: pulse 2s infinite;
}

.status-indicator::before {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  background: var(--color-secondary);
  border-radius: 50%;
  animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

@keyframes ping {

  75%,
  100% {
    transform: scale(2);
    opacity: 0;
  }
}

/* Área de Mensajes */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background: var(--color-bg-light);
}

/* Mensajes */
.message {
  display: flex;
  gap: 1rem;
  animation: messageSlideIn 0.3s ease;
}

.message--user {
  flex-direction: row-reverse;
}

.message--user .message__content {
  align-items: flex-end;
}

.message--user .message__bubble {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: white;
  border-radius: 0.75rem 0.75rem 0 0.75rem;
}

.message--user .message__avatar {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
}

.message--assistant .message__bubble {
  background: white;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem 0.75rem 0.75rem 0;
}

.message--assistant .message__avatar {
  background: linear-gradient(135deg, var(--color-secondary) 0%, var(--color-primary) 100%);
}

.message__avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: white;
}

.message__avatar svg {
  width: 20px;
  height: 20px;
}

.message__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 70%;
}

.message__bubble {
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  line-height: 1.6;
  word-wrap: break-word;
}

.message__bubble strong {
  font-weight: 600;
}

.message__bubble h2,
.message__bubble h3 {
  margin: 0.5rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
}

.message__bubble ul {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.message__bubble p {
  margin: 0.5rem 0;
}

.message__time {
  font-size: 0.75rem;
  color: var(--color-text-lighter);
  padding: 0 0.5rem;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
}

.typing-indicator .dot {
  width: 8px;
  height: 8px;
  background: #B5ADA8;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite;
}

.typing-indicator .dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {

  0%,
  60%,
  100% {
    transform: translateY(0);
  }

  30% {
    transform: translateY(-10px);
  }
}

/* Selector de Municipios */
.csetc-muni-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.625rem;
  margin-top: 0.75rem;
}

@media (max-width: 767px) {
  .csetc-muni-grid {
    grid-template-columns: 1fr;
  }
}

.csetc-muni-btn {
  width: 100%;
  background: white;
  border: 2px solid var(--color-border);
  padding: 0.875rem 0.5rem;
  border-radius: 0.75rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: center;
  transition: all 0.2s ease;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.csetc-muni-btn:hover {
  background: var(--color-bg-lighter);
  border-color: var(--color-primary);
  color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Botones de Acción */
.csetc-action-btn {
  display: block;
  margin-top: 0.5rem;
  background: linear-gradient(135deg, var(--color-secondary) 0%, var(--color-primary) 100%);
  color: white;
  text-decoration: none;
  padding: 0.625rem 1rem;
  border-radius: 0.5rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.875rem;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.csetc-action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
  color: white;
}

/* Input Area */
.chatbot-input {
  padding: 2rem 1rem;
  background: white;
  border-top: 1px solid var(--color-border);
}

@media (min-width: 767px) {
  .chatbot-input {
    padding: 2rem;
  }
}

.chatbot-input__form {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.chatbot-input__textarea {
  flex: 1;
  padding: 0.5rem 0.875rem;
  border: 2px solid var(--color-border);
  border-radius: 0.75rem;
  font-family: var(--font-family);
  font-size: 1rem;
  line-height: 1.5;
  resize: none;
  max-height: 150px;
  transition: border-color 150ms ease;
}

.chatbot-input__textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.chatbot-input__textarea::placeholder {
  color: #B5ADA8;
}

.chatbot-input__submit {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary-dark);
  color: white;
  border: none;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 300ms ease;
  padding: 0;
}

.chatbot-input__submit svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.chatbot-input__submit:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  background: var(--color-primary);
}

.chatbot-input__submit:active:not(:disabled) {
  transform: translateY(0);
}

.chatbot-input__submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.chatbot-input__hint {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--color-text-lighter);
  text-align: center;
}

.chatbot-input__disclaimer {
  margin-top: 0.375rem;
  font-size: 0.7rem;
  color: var(--color-text-lighter);
  text-align: center;
  opacity: 0.75;
}

.chatbot-sidebar__disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--color-bg-lighter);
  border-radius: 0.5rem;
  border: 1px solid var(--color-border);
}

.chatbot-sidebar__disclaimer svg {
  flex-shrink: 0;
  color: var(--color-text-lighter);
  margin-top: 1px;
}

.chatbot-sidebar__disclaimer p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--color-text-lighter);
  line-height: 1.4;
}

.chatbot-sidebar__scroll-indicator {
  position: sticky;
  bottom: 1.5rem;
  display: flex;
  justify-content: center;
  padding: 1.5rem 0 0;
  pointer-events: auto;
  cursor: pointer;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  animation: sidebarBounce 1.8s ease-in-out infinite;
}

.chatbot-sidebar__scroll-indicator.hidden {
  opacity: 0;
  visibility: hidden;
}

.chatbot-sidebar__scroll-indicator svg {
  display: block;
  width: 36px;
  height: 36px;
  padding: 8px;
  background: #fff;
  border: 1.5px solid var(--color-border);
  border-radius: 50%;
  color: var(--color-secondary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.chatbot-sidebar__scroll-indicator:hover svg {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-color: var(--color-secondary);
}

@keyframes sidebarBounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(4px);
  }
}

/* Scrollbar personalizado */
.chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: #D9D5D2;
}

/* Responsive */
@media (max-width: 1023px) {
  .message__content {
    max-width: 88%;
  }
}

/* ==========================================
   FUNNEL CHOICE BUTTONS
   ========================================== */

.csetc-choice-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.csetc-choice-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background: #f8fafc;
  border: 1.5px solid var(--color-border);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: border-color 150ms ease, background 150ms ease, transform 100ms ease;
  width: 100%;
  font-family: inherit;
}

.csetc-choice-btn:hover:not(:disabled) {
  border-color: var(--color-primary);
  background: #eff6ff;
  transform: translateY(-1px);
}

.csetc-choice-btn:active:not(:disabled) {
  transform: translateY(0);
}

.csetc-choice-btn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.csetc-choice-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
  line-height: 1;
}

.csetc-choice-text {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.csetc-choice-label {
  font-weight: 600;
  color: var(--color-text);
  font-size: 0.9rem;
  line-height: 1.2;
}

.csetc-choice-desc {
  font-size: 0.775rem;
  color: var(--color-text-lighter);
  line-height: 1.3;
}