/* ════════════════════════════════════════════════════════════════
   MOMENT OF TRUTH — CHAT WIDGET
   Estilos del asistente conversacional como overlay flotante.
   El chat en sí mantiene su paleta oscura original (es un "modo"
   distinto al sitio claro — como abrir una consola/terminal premium).

   Estructura:
     #chat-toggle   → botón flotante, esquina inferior derecha
     #chat-overlay  → fondo oscuro + blur sobre el sitio
     #chat-panel    → la ventana del chat en sí (contenido de app.js)
   ════════════════════════════════════════════════════════════════ */

/* ── VARIABLES PROPIAS DEL CHAT (paleta oscura original) ─────────*/
:root {
  --chat-bg:      #0F0E0C;
  --chat-bg2:     #141210;
  --chat-bg3:     #1A1814;
  --chat-border:  #252118;
  --chat-border2: #302A1E;
  --chat-text:    #E8E4DC;
  --chat-text2:   #A09880;
  --chat-text3:   #5A5448;
  --chat-gold:    #C8A96E;
  --chat-green:   #7A8C5C;
}

/* ── BOTÓN FLOTANTE ──────────────────────────────────────────────*/
#chat-toggle {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  z-index: 200;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--canvas);
  border: 1px solid var(--clay);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(43, 38, 34, 0.25);
  transition: transform 0.25s var(--ease), background 0.25s var(--ease);
}

#chat-toggle:hover {
  transform: scale(1.06);
  background: var(--clay);
}

#chat-toggle svg { width: 24px; height: 24px; }

/* Icono "abrir" / "cerrar" — se intercambian con una clase */
#chat-toggle .icon-close { display: none; }
#chat-toggle.is-open .icon-chat  { display: none; }
#chat-toggle.is-open .icon-close { display: flex; }


/* ── OVERLAY (fondo desenfocado) ─────────────────────────────────*/
#chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(43, 38, 34, 0.45);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s var(--ease), visibility 0.3s var(--ease);
}

#chat-overlay.is-open {
  opacity: 1;
  visibility: visible;
}


/* ── PANEL DEL CHAT ──────────────────────────────────────────────*/
#chat-panel {
  position: fixed;
  z-index: 160;
  bottom: 0;
  right: 0;
  width: min(420px, 100vw);
  height: min(680px, 100dvh);
  background: var(--chat-bg);
  color: var(--chat-text);
  font-family: 'Georgia', 'Times New Roman', serif;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;

  /* Animación de entrada: se desliza desde abajo-derecha */
  transform: translateY(100%);
  opacity: 0;
  transition: transform 0.35s var(--ease), opacity 0.35s var(--ease);
}

#chat-overlay.is-open #chat-panel {
  transform: translateY(0);
  opacity: 1;
}

/* En escritorio, el panel "flota" con bordes redondeados y margen */
@media (min-width: 640px) {
  #chat-panel {
    bottom: 1.75rem;
    right: 1.75rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--chat-border);
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(15, 14, 12, 0.35);
  }
}

/* En móvil: pantalla completa */
@media (max-width: 639px) {
  #chat-panel { width: 100vw; height: 100dvh; }
}


/* ── SCROLLBAR (dentro del chat) ──────────────────────────────────*/
#chat-panel ::-webkit-scrollbar { width: 3px; }
#chat-panel ::-webkit-scrollbar-thumb { background: var(--chat-border2); border-radius: 2px; }


/* ── HEADER DEL CHAT ───────────────────────────────────────────── */
.chat-header {
  padding: 14px 18px;
  border-bottom: 0.5px solid #1E1C18;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chat-header__brand {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--chat-text3);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.chat-header__title { font-size: 15px; color: var(--chat-text); }

.chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--chat-text3);
  letter-spacing: 0.08em;
}

.chat-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chat-green);
  box-shadow: 0 0 5px var(--chat-green);
}


/* ── MENSAJES ────────────────────────────────────────────────────*/
#msgs {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px 0;
}

.msg-wrap {
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  animation: chatFadeIn 0.2s ease;
}

.msg-wrap.user      { align-items: flex-end; }
.msg-wrap.assistant { align-items: flex-start; }

.msg-label {
  font-size: 9px;
  letter-spacing: 0.12em;
  color: #3A3628;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.bubble {
  max-width: 84%;
  padding: 11px 15px;
  font-size: 13px;
  line-height: 1.75;
  letter-spacing: 0.01em;
  white-space: pre-wrap;
}

.user .bubble {
  background: var(--chat-bg3);
  border: 0.5px solid var(--chat-border);
  border-radius: 11px 11px 2px 11px;
  color: #C8C2B4;
}

.assistant .bubble {
  background: #131210;
  border: 0.5px solid #1E1B14;
  border-radius: 11px 11px 11px 2px;
  color: var(--chat-text);
}

.action-tag {
  margin-top: 8px;
  padding: 5px 9px;
  background: #0A0908;
  border: 0.5px solid #1E1814;
  border-radius: 4px;
  font-size: 10px;
  color: var(--chat-green);
  font-family: monospace;
  letter-spacing: 0.04em;
}
.action-tag.error { color: #8C5C5C; }


/* ── TYPING INDICATOR ────────────────────────────────────────────*/
.typing { display: flex; gap: 5px; align-items: center; padding: 2px 0; }

.typing span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #3A3628;
  animation: chatPulse 1.2s ease-in-out infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }


/* ── QUICK REPLIES ───────────────────────────────────────────────*/
#quick {
  padding: 0 18px 10px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.quick-btn {
  background: none;
  border: 0.5px solid #1E1C18;
  color: var(--chat-text3);
  padding: 5px 11px;
  font-size: 11px;
  cursor: pointer;
  border-radius: 20px;
  font-family: 'Georgia', serif;
  transition: all 0.15s;
}
.quick-btn:hover { color: #C8C2B4; border-color: #3A3628; }


/* ── INPUT ROW ───────────────────────────────────────────────────*/
.input-row {
  padding: 12px 18px 16px;
  border-top: 0.5px solid #161410;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

#inp {
  flex: 1;
  background: var(--chat-bg2);
  border: 0.5px solid var(--chat-border);
  color: var(--chat-text);
  padding: 9px 13px;
  font-size: 13px;
  font-family: 'Georgia', serif;
  line-height: 1.6;
  border-radius: 8px;
  outline: none;
  resize: none;
  caret-color: var(--chat-gold);
  max-height: 120px;
  transition: border-color 0.15s;
}
#inp:focus { border-color: #352E22; }
#inp::placeholder { color: #3A3628; }

#send-btn {
  background: var(--chat-gold);
  border: none;
  color: var(--chat-bg);
  width: 38px;
  height: 38px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
#send-btn:hover    { opacity: 0.85; }
#send-btn:disabled { opacity: 0.3; cursor: default; }


/* ── CALENDARIO ──────────────────────────────────────────────────*/
.cal-wrap {
  background: var(--chat-bg2);
  border: 0.5px solid var(--chat-border);
  border-radius: 12px;
  padding: 18px;
  margin-top: 10px;
  width: 100%;
  max-width: 360px;
}

.cal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.cal-service-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--chat-gold);
}

.cal-close {
  background: none;
  border: none;
  color: var(--chat-text3);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.cal-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.cal-nav {
  background: none;
  border: 0.5px solid var(--chat-border);
  color: var(--chat-text2);
  width: 26px;
  height: 26px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cal-nav:hover { background: var(--chat-bg3); }

.cal-month-label { font-size: 13px; color: var(--chat-text); }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin-bottom: 10px;
}

.cal-day-name {
  font-size: 9px;
  color: var(--chat-text3);
  text-align: center;
  padding-bottom: 6px;
  letter-spacing: 0.06em;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  font-size: 11px;
}

.cal-day.past    { color: #3A3628; }
.cal-day.blocked { color: #3A3628; opacity: 0.35; }

.cal-day.available {
  color: var(--chat-text);
  cursor: pointer;
  border: 0.5px solid var(--chat-border);
}
.cal-day.available:hover { background: var(--chat-bg3); }

.cal-day.partial {
  color: var(--chat-text);
  cursor: pointer;
  border: 0.5px solid var(--chat-border);
  opacity: 0.6;
}
.cal-day.partial:hover { opacity: 1; background: var(--chat-bg3); }

.cal-day.selected {
  background: var(--chat-gold) !important;
  color: var(--chat-bg) !important;
  border-color: var(--chat-gold) !important;
  opacity: 1 !important;
}

.cal-legend {
  display: flex;
  gap: 12px;
  font-size: 9px;
  color: var(--chat-text3);
  margin-bottom: 14px;
}
.cal-legend span { display: flex; align-items: center; gap: 4px; }
.ld { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }


/* ── TURNOS (SHIFTS) ─────────────────────────────────────────────*/
.shifts-section {
  border-top: 0.5px solid var(--chat-border);
  padding-top: 14px;
}

.shifts-date {
  font-size: 11px;
  color: var(--chat-text2);
  margin-bottom: 10px;
  letter-spacing: 0.03em;
}

.shifts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.shift-card {
  border: 0.5px solid var(--chat-border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.shift-card:hover  { background: var(--chat-bg3); border-color: var(--chat-border2); }
.shift-card.taken  { opacity: 0.3; cursor: not-allowed; pointer-events: none; }
.shift-card.chosen { border-color: var(--chat-gold); background: var(--chat-bg3); }

.shift-title { font-size: 12px; color: var(--chat-text); margin-bottom: 2px; }
.shift-time  { font-size: 10px; color: var(--chat-text3); }

.shift-badge {
  display: inline-block;
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 20px;
  margin-top: 5px;
  background: #1E2818;
  color: var(--chat-green);
  letter-spacing: 0.04em;
}
.shift-badge.full { background: var(--chat-bg3); color: #3A3628; }


/* ── CONFIRMACIÓN DE RESERVA ──────────────────────────────────────*/
.confirm-row {
  margin-top: 14px;
  border-top: 0.5px solid var(--chat-border);
  padding-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.confirm-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  color: var(--chat-text2);
}
.confirm-info strong { color: var(--chat-text); font-weight: normal; }

.confirm-btn {
  background: var(--chat-gold);
  border: none;
  color: var(--chat-bg);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 11px;
  font-family: 'Georgia', serif;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: 0.04em;
  transition: opacity 0.15s;
}
.confirm-btn:hover { opacity: 0.85; }


/* ── ANIMACIONES ─────────────────────────────────────────────────*/
@keyframes chatFadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes chatPulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50%       { opacity: 1;   transform: scale(1.1); }
}


/* ── RESPONSIVE ──────────────────────────────────────────────────*/
@media (max-width: 480px) {
  .bubble   { max-width: 95%; }
  .cal-wrap { max-width: 100%; }
}
