/* --- Estilos del Bot de WhatsApp de Pesca Fagi --- */

.whatsapp-layout {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 28px;
  align-items: start;
  margin-top: 10px;
}

@media (max-width: 1200px) {
  .whatsapp-layout {
    grid-template-columns: 1fr;
  }
}

/* --- Panel de Administración --- */
.whatsapp-admin-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 700px;
}

.bot-status-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-bot-status {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 20px;
  font-weight: 700;
  letter-spacing: 0.03em;
  box-shadow: 0 0 10px rgba(0, 230, 118, 0.15);
}

.badge-bot-status.status-auto {
  background-color: rgba(0, 230, 118, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(0, 230, 118, 0.3);
}

.badge-bot-status.status-manual {
  background-color: rgba(255, 74, 90, 0.15);
  color: var(--accent-red);
  border: 1px solid rgba(255, 74, 90, 0.3);
  animation: pulse-red-badge 1.5s infinite;
}

@keyframes pulse-red-badge {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); box-shadow: 0 0 15px rgba(255, 74, 90, 0.3); }
  100% { transform: scale(1); }
}

.admin-chats-split {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
  background-color: rgba(10, 17, 40, 0.4);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  padding: 16px;
  height: 480px;
}

@media (max-width: 768px) {
  .admin-chats-split {
    grid-template-columns: 1fr;
    height: auto;
  }
}

.chats-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-glass);
  padding-right: 16px;
  height: 100%;
  overflow: hidden;
}

.chats-sidebar h4 {
  font-size: 0.95rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.chats-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
}

/* Chat Item */
.chat-list-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border-radius: 10px;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.chat-list-item:hover {
  background-color: rgba(0, 242, 254, 0.05);
  border-color: rgba(0, 242, 254, 0.1);
}

.chat-list-item.active {
  background-color: rgba(0, 242, 254, 0.1);
  border-color: var(--accent-cyan);
}

.cli-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cli-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.cli-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.cli-preview {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cli-badges {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.cli-badge {
  font-size: 0.68rem;
  padding: 1px 5px;
  border-radius: 4px;
}

.cli-badge.badge-auto {
  background-color: rgba(0, 230, 118, 0.1);
  color: var(--accent-green);
}

.cli-badge.badge-manual {
  background-color: rgba(255, 74, 90, 0.1);
  color: var(--accent-red);
}

/* Chat Console */
.chat-console {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.console-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-glass);
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.active-chat-info h5 {
  font-size: 1.05rem;
  color: var(--text-main);
}

.console-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding-right: 6px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.empty-console-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  gap: 12px;
}

.empty-console-state i {
  font-size: 2.5rem;
  color: rgba(255, 255, 255, 0.05);
}

.console-msg-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.4;
  position: relative;
}

.console-msg-bubble.client {
  align-self: flex-start;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  border-bottom-left-radius: 2px;
}

.console-msg-bubble.bot {
  align-self: flex-end;
  background-color: rgba(0, 242, 254, 0.05);
  border: 1px solid rgba(0, 242, 254, 0.15);
  border-bottom-right-radius: 2px;
}

.console-msg-bubble.admin-response {
  align-self: flex-end;
  background-color: rgba(79, 172, 254, 0.15);
  border: 1px solid rgba(79, 172, 254, 0.3);
  border-bottom-right-radius: 2px;
}

.msg-meta-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.msg-sender-tag {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.65rem;
  letter-spacing: 0.03em;
}

.console-msg-bubble.client .msg-sender-tag { color: var(--accent-blue); }
.console-msg-bubble.bot .msg-sender-tag { color: var(--accent-cyan); }
.console-msg-bubble.admin-response .msg-sender-tag { color: #f4f6fc; }

.console-chat-input {
  display: flex;
  gap: 10px;
  background-color: rgba(0, 0, 0, 0.2);
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--border-glass);
}

.console-chat-input input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 8px;
  font-size: 0.9rem;
}

.console-chat-input input:focus {
  outline: none;
}

.console-chat-input input:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* Plantillas de Respuesta */
.admin-bot-settings {
  border-top: 1px solid var(--border-glass);
  padding-top: 18px;
  margin-top: 10px;
}

.admin-bot-settings h4 {
  font-size: 1.05rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 768px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  padding: 10px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.88rem;
  resize: none;
  transition: var(--transition-smooth);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-cyan);
}

/* --- Teléfono Móvil Simulador --- */
.whatsapp-phone-simulator {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.phone-frame {
  width: 325px;
  height: 610px;
  border: 11px solid #1f2937;
  border-radius: 36px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), var(--shadow-premium);
  position: relative;
  background-color: #0b141a;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-bottom-width: 14px;
}

/* Notch del altavoz/cámara */
.phone-frame::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 18px;
  background-color: #1f2937;
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 14px;
  z-index: 20;
}

.phone-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  position: relative;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* WhatsApp Header */
.whatsapp-header {
  background-color: #202c33;
  padding: 24px 10px 10px 10px; /* Margen superior para el Notch */
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.wa-header-back {
  font-size: 0.9rem;
  color: #aebac1;
  cursor: pointer;
}

.wa-header-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.wa-header-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.wa-contact-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: #e9edef;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.verified-badge {
  color: #00a884;
  font-size: 0.75rem;
}

.wa-contact-status {
  font-size: 0.7rem;
  color: #8696a0;
  white-space: nowrap;
}

.wa-contact-status.typing {
  color: #53bdeb;
  font-weight: 600;
}

.wa-header-actions {
  display: flex;
  gap: 14px;
  color: #aebac1;
  font-size: 0.88rem;
  padding-right: 4px;
}

/* WhatsApp Chat Body */
.whatsapp-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background-color: #0b141a;
  background-image: 
    radial-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 0),
    radial-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 0);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
}

/* Chat Bubbles */
.wa-bubble {
  max-width: 82%;
  padding: 6px 10px 4px 10px;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.4;
  position: relative;
  box-shadow: 0 1px 0.5px rgba(0,0,0,0.15);
  color: #e9edef;
  word-break: break-word;
}

.wa-bubble.incoming {
  align-self: flex-start;
  background-color: #202c33;
  border-top-left-radius: 0;
}

.wa-bubble.outgoing {
  align-self: flex-end;
  background-color: #005c4b;
  border-top-right-radius: 0;
}

.wa-bubble-content {
  margin-bottom: 2px;
}

.wa-bubble-content strong {
  color: var(--accent-cyan);
}

.wa-bubble-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 3px;
  font-size: 0.65rem;
  color: #8696a0;
  margin-top: 2px;
  text-align: right;
}

.wa-bubble.outgoing .wa-bubble-meta {
  color: #8696a0;
}

.wa-bubble-meta i {
  font-size: 0.72rem;
}

.wa-bubble-meta i.read {
  color: #53bdeb;
}

/* Burbujas Especiales de Botones / Listas */
.wa-bubble-list {
  background-color: #202c33;
  border-radius: 8px;
  border-top-left-radius: 0;
  padding: 8px;
  margin-bottom: 4px;
}

.wa-list-header {
  font-weight: 700;
  font-size: 0.82rem;
  color: #e9edef;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding-bottom: 6px;
  margin-bottom: 6px;
}

.wa-list-item {
  padding: 6px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.78rem;
}

.wa-list-item:last-child {
  border-bottom: none;
}

.wa-list-item-title {
  font-weight: 600;
  color: var(--accent-cyan);
}

.wa-list-item-desc {
  color: #8696a0;
  font-size: 0.72rem;
}

/* Burbuja de Botones de Opciones */
.wa-options-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 6px;
}

.wa-option-btn {
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #53bdeb;
  font-weight: 600;
  font-size: 0.78rem;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  transition: var(--transition-smooth);
}

.wa-option-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Typing Indicator */
.wa-typing-indicator {
  align-self: flex-start;
  background-color: #202c33;
  padding: 8px 14px;
  border-radius: 12px;
  border-top-left-radius: 0;
  margin-left: 10px;
  margin-bottom: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.wa-typing-indicator .dot {
  width: 6px;
  height: 6px;
  background-color: #8696a0;
  border-radius: 50%;
  animation: bounce 1.3s infinite ease-in-out;
}

.wa-typing-indicator .dot:nth-child(2) { animation-delay: 0.15s; }
.wa-typing-indicator .dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* Quick Actions (Cliente) */
.wa-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  background-color: rgba(11, 20, 26, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  z-index: 5;
}

.quick-action-pill {
  background-color: #202c33;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #e9edef;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 14px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.quick-action-pill:hover {
  background-color: #005c4b;
  border-color: #00e676;
}

.quick-action-pill.text-danger-pill {
  border-color: rgba(255, 74, 90, 0.2);
  color: var(--accent-red);
}

.quick-action-pill.text-danger-pill:hover {
  background-color: rgba(255, 74, 90, 0.15);
  color: #fff;
  border-color: var(--accent-red);
}

/* WhatsApp Input Area */
.whatsapp-input-area {
  background-color: #1f2937;
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.wa-input-container {
  flex: 1;
  background-color: #2a3942;
  border-radius: 24px;
  display: flex;
  align-items: center;
  padding: 4px 12px;
  gap: 8px;
  color: #8696a0;
  font-size: 0.95rem;
}

.wa-input-container input {
  flex: 1;
  background: transparent;
  border: none;
  color: #e9edef;
  padding: 6px 0;
  font-size: 0.8rem;
}

.wa-input-container input:focus {
  outline: none;
}

.wa-input-container i {
  cursor: pointer;
}

.wa-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: #00a884;
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
  transition: var(--transition-smooth);
}

.wa-send-btn:hover {
  background-color: #00c69d;
  transform: scale(1.05);
}

.wa-send-btn:active {
  transform: scale(0.95);
}

/* Helper Hints */
.simulator-hint {
  margin-top: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
  max-width: 320px;
  text-align: center;
}

.simulator-hint i {
  color: var(--accent-cyan);
}

/* Custom QR code bubble in WhatsApp */
.wa-qr-code-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px;
  background: white;
  border-radius: 6px;
  margin-top: 6px;
}

.wa-qr-img {
  width: 100px;
  height: 100px;
  object-fit: contain;
}

.wa-qr-text {
  font-size: 0.7rem;
  font-weight: 700;
  color: #000;
  margin-top: 4px;
}
