/* --- Estilos originais preservados, mas sem afetar o site principal --- */

/* 🔒 Isola o CSS: aplica somente quando o chat está ativo */
.sofia-chat-active body {
  margin: 0;
  font-family: Arial, sans-serif;
  background-color: #f4f4f4;
  overflow-x: hidden;
}

/* 🔒 Restaura layout do site quando o chat não está ativo */
body:not(.sofia-chat-active) {
  margin: initial;
  font-family: inherit;
  background-color: inherit;
  overflow-x: visible;
}

/* Mantém os elementos visuais do chat (sem interferir no resto do site) */
.chat-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 400px;
  height: 650px;
  background: #ece5dd;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
  z-index: 999;
}

.chat-overlay .header {
  background: #075e54;
  color: white;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-overlay .header-left {
  display: flex;
  align-items: center;
}

.chat-overlay .header img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  margin-right: 15px;
}

.chat-overlay .header .info {
  display: flex;
  flex-direction: column;
}

.chat-overlay .header .info span:first-child {
  font-weight: bold;
  font-size: 20px;
}

.chat-overlay .header .info span:last-child {
  font-size: 14px;
  color: #cfcfcf;
}

.chat-overlay .header-right {
  display: flex;
  gap: 20px;
  font-size: 24px;
  cursor: pointer;
}

.chat-overlay .messages {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  background: #ece5dd;
  display: flex;
  flex-direction: column;
}

.chat-overlay .msg {
  max-width: 70%;
  padding: 15px;
  border-radius: 8px;
  margin: 10px 0;
  position: relative;
  font-size: 18px;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-overlay .bot {
  background: #fff;
  align-self: flex-start;
  border-radius: 0 8px 8px 8px;
}

.chat-overlay .user {
  background: #dcf8c6;
  align-self: flex-end;
  border-radius: 8px 0 8px 8px;
}

.chat-overlay .time {
  font-size: 12px;
  color: #999;
  position: absolute;
  bottom: 3px;
  right: 10px;
}

.chat-overlay .typing {
  font-size: 16px;
  color: #666;
  font-style: italic;
  margin: 8px 0;
}

.chat-overlay .input-area {
  display: flex;
  align-items: center;
  padding: 8px;
  background: #f0f0f0;
}

.chat-overlay .input-area input {
  flex: 1;
  padding: 14px 18px;
  border-radius: 25px;
  border: none;
  outline: none;
  font-size: 18px;
}

.chat-overlay .input-area button {
  background: none;
  border: none;
  font-size: 26px;
  margin-left: 12px;
  cursor: pointer;
  color: #075e54;
  padding: 8px;
}

.chat-overlay .video-container {
  position: relative;
  width: 240px;
  aspect-ratio: 9/16;
  overflow: hidden;
  border-radius: 15px;
  margin-top: 5px;
}

.chat-overlay .video-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(8px) brightness(0.5);
}

.chat-overlay .overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.3);
}

.chat-overlay .play-btn {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: 0.3s;
  font-size: 28px;
  color: #fff;
}

.chat-overlay .play-btn:hover {
  background: rgba(255, 255, 255, 0.4);
}

.chat-overlay .overlay p {
  margin-top: 15px;
  color: #fff;
  font-size: 16px;
  text-align: center;
}

/* Modal */
.video-modal {
  animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    backdrop-filter: blur(0px);
  }
  to {
    opacity: 1;
    backdrop-filter: blur(5px);
  }
}

/* Popup */
#popup {
  display: none;
  justify-content: center;
  align-items: center;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  z-index: 9998;
}

#popup-content {
  background: #fff;
  color: #333;
  padding: 20px;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  max-width: 90%;
  width: 360px;
}

#confirm-button {
  margin-top: 10px;
  padding: 10px 20px;
  background: #4caf50;
  color: #fff;
  border: none;
  border-radius: 5px;
  cursor: not-allowed;
}

#confirm-button:enabled {
  cursor: pointer;
}

/* Película invisível */
#overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 75%;
  height: 75%;
  background: transparent;
  z-index: 9999;
  display: none;
}

/* Responsivo */
@media (max-width: 1768px) {
  .chat-overlay {
    width: 95%;
    height: 95%;
  }
  .chat-overlay .header img {
    width: 70px;
    height: 70px;
  }
  .chat-overlay .header .info span:first-child {
    font-size: 22px;
  }
  .chat-overlay .header .info span:last-child {
    font-size: 16px;
  }
  .chat-overlay .header-right {
    font-size: 32px;
    gap: 16px;
  }
  .chat-overlay .msg {
    font-size: 20px !important;
    padding: 16px !important;
    line-height: 1.6 !important;
    max-width: 90%;
  }
  .chat-overlay .time {
    font-size: 12px;
  }
  .chat-overlay .typing {
    font-size: 18px;
  }
  .chat-overlay .input-area input {
    font-size: 20px !important;
    padding: 14px 18px !important;
  }
  .chat-overlay .input-area button {
    font-size: 32px;
    margin-left: 12px;
  }
  .chat-overlay .video-container {
    width: 95%;
    max-width: 480px;
  }
  .chat-overlay .video-container video {
    height: 100%;
  }
  .chat-overlay .overlay p {
    font-size: 20px;
  }
  .chat-overlay .play-btn {
    width: 90px;
    height: 90px;
    font-size: 36px;
  }
}

/* --- Loading girando no botão Confirmar --- */
.loading-spinner {
  border: 3px solid rgba(255,255,255,0.3);
  border-top: 3px solid white;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
  margin-left: 8px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
