/* El modal comienza oculto. Se muestra quitando esta clase via JS */
#chatModal {
  display: none;
}
#chatModal.chat-visible {
  display: flex;
}

/* Botón chat en tarjetas de reserva */
.chat-book-wrap {
  margin-top: 10px;
}
.chat-book-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
/* ============================================================
   OFICIOSGO — CHAT INTERNO
   /chat.css  (raiz del proyecto, un nivel arriba de /cliente/ y /colaborador/)
   ============================================================ */

#chatModal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(11, 16, 9, 0.55);
  backdrop-filter: blur(6px);
}

#chatModal.chat-open {
  display: flex;
}

/* Panel principal — mismo estilo que .modal-card del portal */
#chatModal .c-panel {
  position: relative;
  width: min(480px, 100%);
  height: min(600px, 85vh);
  border-radius: 28px;
  background: #fefefe;
  box-shadow: 0 30px 80px rgba(16, 24, 12, 0.24);
  border: 1px solid rgba(20, 32, 20, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: cPanelIn .2s ease;
}

@keyframes cPanelIn {
  from { opacity: 0; transform: scale(0.97) translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* Header oscuro */
#chatModal .c-head {
  background: #142014;
  padding: 15px 18px;
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
  border-radius: 28px 28px 0 0;
}

#chatModal .c-av {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: #c8f000;
  color: #142014;
  display: grid;
  place-items: center;
  font-family: "Sora", sans-serif;
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}

#chatModal .c-info {
  flex: 1;
  min-width: 0;
}

#chatModal .c-name {
  font-family: "Sora", sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: #c8f000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#chatModal .c-sub {
  font-size: 10px;
  color: rgba(200, 240, 0, 0.5);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 2px;
}

#chatModal .c-x {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(200, 240, 0, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(200, 240, 0, 0.8);
  font-size: 16px;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 0.15s;
  line-height: 1;
}

#chatModal .c-x:hover {
  background: rgba(255, 255, 255, 0.16);
}

/* Banner sin conexion */
#chatModal .c-offline {
  background: rgba(198, 72, 59, 0.1);
  border-bottom: 1px solid rgba(198, 72, 59, 0.2);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: #c6483b;
  text-align: center;
  flex-shrink: 0;
  display: none;
}

#chatModal .c-offline.on {
  display: block;
}

/* Area de mensajes */
#chatModal .c-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f7f9f5;
  scroll-behavior: smooth;
}

#chatModal .c-msgs::-webkit-scrollbar {
  width: 4px;
}

#chatModal .c-msgs::-webkit-scrollbar-thumb {
  background: rgba(20, 32, 20, 0.12);
  border-radius: 4px;
}

/* Estado vacio */
#chatModal .c-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 16px;
  color: #62705f;
}

#chatModal .c-ico {
  font-size: 40px;
  margin-bottom: 10px;
}

#chatModal .c-empty p {
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
}

/* Separador de fecha */
#chatModal .c-sep {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8a9887;
  margin: 4px 0;
}

#chatModal .c-sep::before,
#chatModal .c-sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(20, 32, 20, 0.1);
}

/* Burbujas */
#chatModal .c-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 82%;
  animation: cMsgIn 0.14s ease;
}

@keyframes cMsgIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: none; }
}

#chatModal .c-msg.mine   { align-self: flex-end;  flex-direction: row-reverse; }
#chatModal .c-msg.theirs { align-self: flex-start; }

#chatModal .c-msg .av {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: #c8f000;
  color: #142014;
  display: grid;
  place-items: center;
  font-family: "Sora", sans-serif;
  font-weight: 800;
  font-size: 10px;
  flex-shrink: 0;
  border: 1px solid rgba(20, 32, 20, 0.1);
}

#chatModal .c-msg.mine .av {
  background: #142014;
  color: #c8f000;
}

#chatModal .c-msg .body {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

#chatModal .c-msg.mine .body {
  align-items: flex-end;
}

#chatModal .c-msg .bbl {
  background: #fff;
  border: 1px solid rgba(20, 32, 20, 0.1);
  border-radius: 16px 16px 16px 3px;
  padding: 9px 13px;
  font-size: 13px;
  line-height: 1.55;
  color: #142014;
  word-break: break-word;
  max-width: 100%;
}

#chatModal .c-msg.mine .bbl {
  background: #142014;
  color: #c8f000;
  border-radius: 16px 16px 3px 16px;
  border-color: transparent;
}

#chatModal .c-msg .ts {
  font-size: 10px;
  color: #8a9887;
  padding: 0 3px;
}

/* Footer con input */
#chatModal .c-foot {
  background: #fff;
  border-top: 1px solid rgba(20, 32, 20, 0.08);
  padding: 11px 14px;
  display: flex;
  gap: 9px;
  align-items: flex-end;
  flex-shrink: 0;
  border-radius: 0 0 28px 28px;
}

#chatModal .c-wrap {
  flex: 1;
  background: #f7f9f5;
  border: 1px solid rgba(20, 32, 20, 0.12);
  border-radius: 13px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#chatModal .c-wrap:focus-within {
  border-color: #94b300;
  box-shadow: 0 0 0 3px rgba(148, 179, 0, 0.12);
}

#chatModal textarea {
  flex: 1;
  border: none;
  outline: none;
  padding: 9px 12px;
  font-size: 13px;
  background: transparent;
  color: #142014;
  resize: none;
  min-height: 38px;
  max-height: 100px;
  line-height: 1.5;
  font-family: "DM Sans", sans-serif;
}

#chatModal textarea::placeholder {
  color: #8a9887;
}

#chatModal .c-send {
  width: 42px;
  height: 42px;
  background: #142014;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: #c8f000;
  font-size: 16px;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

#chatModal .c-send:hover {
  background: #1e3220;
  transform: translateY(-1px);
}

#chatModal .c-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Movil */
@media (max-width: 640px) {
  #chatModal {
    padding: 0;
    align-items: flex-end;
  }

  #chatModal .c-panel {
    width: 100%;
    height: 88vh;
    border-radius: 22px 22px 0 0;
    animation: cPanelUp 0.22s ease;
  }

  #chatModal .c-head {
    border-radius: 22px 22px 0 0;
  }

  #chatModal .c-foot {
    border-radius: 0;
    padding-bottom: max(11px, env(safe-area-inset-bottom));
  }
}

@keyframes cPanelUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
/* Minimizar panel */
#chatModal .c-panel.c-minimized .c-msgs,
#chatModal .c-panel.c-minimized .c-foot,
#chatModal .c-panel.c-minimized .c-offline {
  display: none;
}
#chatModal .c-panel.c-minimized {
  height: auto;
  min-height: 0;
}
#chatModal.chat-visible {
  display: flex;
}

/* ── Minimizar: barra flotante en esquina inferior derecha ── */
#chatModal.chat-minimized {
  /* No oscurece el fondo */
  background: transparent;
  backdrop-filter: none;
  pointer-events: none;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0 20px 20px 0;
}
#chatModal.chat-minimized .c-panel {
  pointer-events: all;
  height: auto !important;
  min-height: 0;
  width: 280px;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(16,24,12,0.28);
  animation: none;
}
#chatModal.chat-minimized .c-msgs,
#chatModal.chat-minimized .c-foot,
#chatModal.chat-minimized .c-offline {
  display: none !important;
}
#chatModal.chat-minimized .c-head {
  border-radius: 16px;
  cursor: pointer;
}
/* ── Mensajes del sistema (confirmación de reserva) ── */
#chatModal .c-msg.system {
  align-self: center;
  max-width: 94%;
  margin: 10px 0;
}
#chatModal .bbl-system {
  background: linear-gradient(135deg, #f0f7e0, #e4f0cc);
  border: 1.5px solid #b8d860;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 12.5px;
  line-height: 1.75;
  color: #2a4a1a;
  font-family: "DM Sans", sans-serif;
  box-shadow: 0 2px 8px rgba(100,160,0,0.12);
  white-space: pre-line;
}
/* ============================================================
   CHAT RESPONSIVE — extra mobile fixes (≤480px, ≤360px)
   ============================================================ */

/* Fold/very-narrow: full viewport height, no border-radius top */
@media (max-width: 400px) {
  #chatModal {
    padding: 0;
    align-items: flex-end;
  }
  #chatModal .c-panel {
    width: 100%;
    height: 92vh;
    border-radius: 16px 16px 0 0;
  }
  #chatModal .c-head {
    border-radius: 16px 16px 0 0;
    padding: 12px 14px;
    gap: 8px;
  }
  #chatModal .c-av {
    width: 30px;
    height: 30px;
    font-size: 12px;
  }
  #chatModal .c-name { font-size: 13px; }
  #chatModal .c-sub  { font-size: 9px; }
  #chatModal .c-msgs { padding: 10px 12px; gap: 8px; }
  #chatModal .c-msg  { max-width: 90%; }
  #chatModal .c-msg .bbl { font-size: 12px; padding: 7px 10px; }
  #chatModal .c-foot { padding: 8px 10px; gap: 7px; }
  #chatModal textarea { font-size: 12px; min-height: 34px; padding: 7px 10px; }
  #chatModal .c-send  { width: 36px; height: 36px; font-size: 14px; border-radius: 10px; }
}

/* Minimized bar: stays small on narrow screens */
@media (max-width: 400px) {
  #chatModal.chat-minimized {
    padding: 0 10px 14px 0;
  }
  #chatModal.chat-minimized .c-panel {
    width: calc(100vw - 20px);
    max-width: 300px;
  }
}
/* ── Botón Chat con mensaje pendiente ──────────────────────── */
@keyframes chat-btn-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(239,68,68,0.5); }
  50%       { opacity: 0.82; box-shadow: 0 0 0 5px rgba(239,68,68,0); }
}
.chat-btn-pending {
  background: #ef4444 !important;
  color: #fff !important;
  border-color: #ef4444 !important;
  animation: chat-btn-pulse 1.2s ease-in-out infinite;
}