/* Chat interno — escritorio y móvil */

.chat-btn-topbar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  margin-right: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  color: #754516;
  font-size: 1.15rem;
  cursor: pointer;
  flex-shrink: 0;
  overflow: visible;
  z-index: 1;
}

.chat-btn-topbar:hover {
  background: #f5efe8;
}

.chat-badge-total {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: #e74c3c;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.15rem;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  z-index: 3;
  pointer-events: none;
}

.chat-badge-total:not(.oculto) {
  display: inline-block !important;
}

.chat-panel-overlay {
  position: fixed;
  inset: 0;
  z-index: 12000;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
}

.chat-panel-overlay.oculto {
  display: none;
}

.chat-panel {
  width: min(420px, 100vw);
  max-width: 100%;
  background: #fff;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  animation: chat-slide-in 0.2s ease;
}

@keyframes chat-slide-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.chat-panel-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e8dfd4;
  background: #faf7f3;
}

.chat-panel-header h2 {
  flex: 1;
  margin: 0;
  font-size: 1.05rem;
  color: #754516;
}

.chat-panel-btn-icon {
  border: none;
  background: transparent;
  font-size: 1.25rem;
  cursor: pointer;
  color: #754516;
  padding: 0.25rem 0.5rem;
  line-height: 1;
}

.chat-panel-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-nueva-bar {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #eee;
  background: #fff;
}

.chat-nueva-bar select {
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.9rem;
}

.chat-nueva-bar button {
  padding: 0.45rem 0.75rem;
  border: none;
  border-radius: 6px;
  background: #754516;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.chat-lista-conversaciones {
  flex: 1;
  overflow-y: auto;
}

.chat-conv-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.85rem 1rem;
  border: none;
  border-bottom: 1px solid #f0ebe4;
  background: #fff;
  cursor: pointer;
}

.chat-conv-item:hover,
.chat-conv-item.activo {
  background: #f9f5f0;
}

.chat-conv-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.chat-conv-nombre {
  font-weight: 600;
  color: #333;
  font-size: 0.95rem;
}

.chat-conv-fecha {
  font-size: 0.72rem;
  color: #888;
  flex-shrink: 0;
}

.chat-conv-preview {
  margin: 0.25rem 0 0;
  font-size: 0.82rem;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-conv-badge {
  display: inline-block;
  min-width: 1.2rem;
  padding: 0 0.35rem;
  margin-left: 0.35rem;
  border-radius: 999px;
  background: #754516;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  vertical-align: middle;
}

.chat-vista-hilo {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chat-vista-hilo.oculto,
.chat-vista-lista.oculto {
  display: none;
}

.chat-mensajes {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: #f7f4f0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-burbuja {
  max-width: 85%;
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.4;
  word-break: break-word;
}

.chat-burbuja.mio {
  align-self: flex-end;
  background: #754516;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-burbuja.otro {
  align-self: flex-start;
  background: #fff;
  color: #222;
  border: 1px solid #e5ddd5;
  border-bottom-left-radius: 4px;
}

.chat-burbuja-meta {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.65rem;
  opacity: 0.75;
}

.chat-form-enviar {
  display: flex;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-top: 1px solid #e8dfd4;
  background: #fff;
  align-items: center;
}

.chat-form-enviar textarea {
  flex: 1;
  resize: none;
  padding: 0.55rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 1.25rem;
  font-family: inherit;
  font-size: 0.9rem;
  min-height: 2.5rem;
  max-height: 6rem;
  line-height: 1.35;
}

.chat-btn-enviar {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #25d366;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: background 0.15s ease, transform 0.1s ease;
}

.chat-btn-enviar:hover {
  background: #20bd5a;
}

.chat-btn-enviar:active {
  transform: scale(0.96);
}

.chat-btn-enviar svg {
  display: block;
  margin-left: 2px;
}

.chat-vacio {
  padding: 2rem 1rem;
  text-align: center;
  color: #888;
  font-size: 0.9rem;
}

/* Móvil */
.movil-vista-chat {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 120px);
  padding-bottom: 4.5rem;
}

.movil-vista-chat .chat-panel-body {
  flex: 1;
}

.movil-vista-chat .chat-vista-lista,
.movil-vista-chat .chat-vista-hilo {
  flex: 1;
  min-height: 0;
}

.movil-tab-badge-chat {
  position: absolute;
  top: 2px;
  right: 8px;
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.2rem;
  border-radius: 999px;
  background: #e74c3c;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1rem;
  z-index: 2;
  pointer-events: none;
}

.movil-tab-badge-chat:not(.oculto) {
  display: inline-block !important;
}

.movil-tab {
  position: relative;
}
