/* ============================================
   CHAT POPUP - Messenger Style
   ============================================ */

/* Popup Container */
.chat-popup {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 380px;
  max-height: 600px;
  height: 500px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: bottom right;
}

.chat-popup.hidden {
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
}

.chat-popup.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Header */
.chat-popup-header {
  background: #0c2f4f;
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-radius: 12px 12px 0 0;
}

.chat-popup-header.color-bg {
  background: #0c2f4f;
}

.chat-popup-header-info {
  flex: 1;
  min-width: 0;
}

.chat-popup-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.chat-popup-subtitle {
  font-size: 12px;
  opacity: 0.9;
  margin: 2px 0 0;
}

.chat-popup-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  margin-left: 12px;
}

.chat-popup-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  font-size: 14px;
}

.chat-popup-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.chat-popup-btn i {
  pointer-events: none;
}

.chat-popup-back-btn {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  margin-right: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  transition: opacity 0.2s;
}

.chat-popup-back-btn:hover {
  opacity: 0.8;
}

/* Menu Dropdown */
.chat-popup-menu-wrapper {
  position: relative;
}

.chat-popup-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  min-width: 200px;
  z-index: 10000;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-10px) scale(0.95);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.chat-popup-dropdown.hidden {
  opacity: 0;
  transform: translateY(-10px) scale(0.95);
  pointer-events: none;
}

.chat-popup-dropdown.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

.chat-popup-dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: #333;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
  text-align: left;
}

.chat-popup-dropdown-item:hover {
  background: #f5f7fb;
}

.chat-popup-dropdown-item i {
  color: #0c2f4f;
  font-size: 14px;
  width: 16px;
  text-align: center;
}

/* Messages Container */
.chat-popup-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f5f7fb;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
  max-height: 350px;
}

.chat-popup-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-popup-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-popup-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.chat-popup-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* Message Bubbles */
.chat-popup-message {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  animation: messageSlideIn 0.3s ease-out;
}

/* Feedback Modal (SweetAlert2) */
.swal2-popup.hr-modal {
  border-radius: 12px;
  padding: 20px;
  width: 480px;
  max-width: 92vw;
}
.swal2-title {
  font-size: 18px;
  font-weight: 600;
  color: #222;
}
.swal2-html-container {
  font-size: 14px;
  color: #333;
}
.swal2-confirm.color-bg {
  color: #fff;
  border-radius: 8px;
  padding: 10px 18px;
}
.swal2-timer-progress-bar {
  background: rgba(50, 112, 252, 0.25);
}
@media (max-width: 480px) {
  .swal2-popup.hr-modal {
    width: 96vw;
    padding: 16px;
  }
  .swal2-title {
    font-size: 16px;
  }
  .swal2-html-container {
    font-size: 13px;
  }
  .swal2-confirm.color-bg {
    width: 100%;
  }
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-popup-message.me {
  flex-direction: row-reverse;
}

.chat-popup-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0c2f4f;
  color: white;
  font-size: 18px;
}

/* Color diferente para mis mensajes */
.chat-popup-message.me .chat-popup-message-avatar {
  background: #0c2f4f;
}

.chat-popup-message-content {
  max-width: 70%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-popup-message-bubble {
  background: #fff;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.4;
  color: #333;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.chat-popup-message.me .chat-popup-message-bubble {
  background: #0c2f4f;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-popup-message:not(.me) .chat-popup-message-bubble {
  border-bottom-left-radius: 4px;
}

.chat-popup-message-time {
  font-size: 11px;
  color: #999;
  padding: 0 8px;
}

.chat-popup-message.me .chat-popup-message-time {
  text-align: right;
}

/* Empty State */
.chat-popup-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: #999;
}

.chat-popup-empty i {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.chat-popup-empty p {
  margin: 0;
  font-size: 14px;
}

/* Input Area */
.chat-popup-input {
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid #eee;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-shrink: 0;
}

.chat-popup-input textarea {
  flex: 1;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 100px;
  min-height: 40px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.2s;
}

.chat-popup-input textarea:focus {
  border-color: #0c2f4f;
}

.chat-popup-input textarea::placeholder {
  color: #aaa;
}

.chat-popup-send-btn {
  background: #0c2f4f;
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
  flex-shrink: 0;
  font-size: 16px;
}

.chat-popup-send-btn.color-bg {
  background: #0c2f4f;
}

.chat-popup-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(50, 112, 252, 0.4);
}

.chat-popup-send-btn:active {
  transform: scale(0.95);
}

.chat-popup-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Loading State */
.chat-popup-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: #999;
  font-size: 14px;
  gap: 8px;
}

.chat-popup-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #e0e0e0;
  border-top-color: #0c2f4f;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .chat-popup {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 70vh;
    border-radius: 12px 12px 0 0;
  }

  .chat-popup.hidden {
    transform: translateY(100%);
  }

  .chat-popup.show {
    transform: translateY(0);
  }
}

/* Notification Badge */
.chat-popup-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ff4757;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Typing Indicator */
.chat-popup-typing {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: #fff;
  border-radius: 18px;
  width: fit-content;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.chat-popup-typing span {
  width: 8px;
  height: 8px;
  background: #999;
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.chat-popup-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.chat-popup-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* ============================================
   FLOATING ACTION BUTTON (FAB) - Messenger Style
   ============================================ */
.chat-fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  background: #0c2f4f;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(50, 112, 252, 0.4);
  z-index: 99999;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center;
}

.chat-fab.hidden {
  opacity: 0;
  transform: scale(0);
  pointer-events: none;
  visibility: hidden;
}

.chat-fab.show {
  opacity: 1;
  transform: scale(1);
  pointer-events: all;
  visibility: visible;
}

.chat-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(50, 112, 252, 0.5);
}

.chat-fab:active {
  transform: scale(0.95);
}

.chat-fab i {
  font-size: 24px;
  color: #fff;
}

/* ============================================
   SUCCESS MODAL - App UI Consistent
   ============================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.35);
  z-index: 10000;
  display: none;
}
.modal-overlay.active {
  display: block;
}
.modal-success {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  padding: 24px;
  max-width: 90%;
  width: 400px;
  z-index: 10001;
  text-align: center;
  display: none;
}
.modal-success.active {
  display: block;
}
.modal-success-header {
  color: #0c2f4f;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 12px;
}
.modal-success-header i {
  font-size: 32px;
}
.modal-success-message {
  font-size: 14px;
  color: #333;
  margin-bottom: 18px;
}
.modal-success-btn {
  background: #0c2f4f;
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s ease-in-out;
}
.modal-success-btn:hover {
  background: #2b63e0;
}
@media (max-width: 480px) {
  .modal-success {
    width: 96vw;
    padding: 20px;
  }
  .modal-success-header {
    font-size: 20px;
  }
  .modal-success-message {
    font-size: 13px;
  }
  .modal-success-btn {
    width: 100%;
  }
}

/* Badge de mensajes no leídos en FAB */
.chat-fab-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ff4757;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 12px;
  min-width: 22px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(255, 71, 87, 0.4);
  animation: fabBadgePulse 2s infinite;
}

.chat-fab-badge.hidden {
  display: none;
}

@keyframes fabBadgePulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

/* Animación de pulso suave para el FAB */
.chat-fab::after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #0c2f4f;
  z-index: -1;
  opacity: 0;
  animation: fabPulse 2s infinite;
}

@keyframes fabPulse {
  0% {
    transform: scale(1);
    opacity: 0.4;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

/* Responsive para FAB */
@media (max-width: 768px) {
  .chat-fab {
    bottom: 15px;
    right: 15px;
    width: 56px;
    height: 56px;
  }

  .chat-fab i {
    font-size: 22px;
  }
}

/* ============================================
   CONVERSATION LIST VIEW
   ============================================ */
.chat-popup-list {
  flex: 1;
  background: #fff;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.chat-popup-list.hidden {
  display: none;
}

.chat-popup-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.2s;
}

.chat-popup-list-item:hover {
  background: #f5f7fb;
}

.chat-popup-list-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #eee;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.chat-popup-list-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-popup-list-avatar i {
  font-size: 20px;
  color: #999;
}

.chat-popup-list-info {
  flex: 1;
  min-width: 0;
}

.chat-popup-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.chat-popup-list-name {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-popup-list-time {
  font-size: 11px;
  color: #999;
  flex-shrink: 0;
  margin-left: 8px;
}

.chat-popup-list-preview {
  font-size: 13px;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
}

.chat-popup-list-item.unread .chat-popup-list-name {
  color: #0c2f4f;
}

.chat-popup-list-item.unread .chat-popup-list-preview {
  font-weight: 600;
  color: #333;
}

.chat-popup-list-badge {
  background: #0c2f4f;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  height: 18px;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  flex-shrink: 0;
}

.chat-popup-list-item {
  position: relative;
}

.chat-popup-status-dot {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 12px;
  height: 12px;
  background-color: #2ecc71;
  border: 2px solid #fff;
  border-radius: 50%;
  z-index: 2;
}

.chat-popup-list-avatar img {
  border-radius: 50%;
}
