/* Variáveis de cores e estilos */
:root {
  --primary-color: #00a884;
  --app-background: #00a884;
  --secondary-color: #075e54;
  --received-msg-bg: #ffffff;
  --sent-msg-bg: #d9fdd3;
  --chat-bg: #e5ddd5;
  --text-color: #3b4a54;
  --light-text: #888888;
  --border-radius: 8px;
  --shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  --app-wash: #dbd8d4;
  --app-background-deeper: #d1d7db;
  --panel-header-background: #f0f2f5;
  --primary-strong: #111b21;
  --conversation-panel-background: #efeae2;
  --button-alternative: #009de2;
  --black-rgb: 11, 20, 26;
  --white-rgb: 255, 255, 255;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--black-rgb), 0.2) transparent;
}
*::-webkit-scrollbar {
  width: 6px !important;
  height: 6px !important;
}
*::-webkit-scrollbar-thumb {
  background-color: rgba(var(--black-rgb), 0.2);
}
*::-webkit-scrollbar-track {
  background: rgba(var(--white-rgb), 0.1);
}

body {
  background-color: var(--app-wash, var(--app-background));
  background-image: linear-gradient(
    to bottom,
    var(--app-wash, var(--app-background)),
    var(--app-wash, var(--app-background-deeper))
  );
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern";
}
.chat-background {
  width: 100%;

  display: flex;
  justify-content: center;
  height: calc(100vh - 40px);
  margin-top: 20px;
}
.chat-background::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  z-index: -1;
  width: 100%;
  height: 127px;
  background-color: var(--app-background);
}

/* Container principal do chat */
.chat-container {
  width: calc(100% - 38px);
  max-width: 1600px;
  margin: 0 auto;
  box-shadow: 0 6px 18px rgba(var(--shadow-rgb), 0.05);
  display: flex;
  flex-direction: column;
}

/* Cabeçalho do chat */
.chat-header {
  background-color: var(--panel-header-background);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  color: var(--primary-strong);
}

.profile-info {
  display: flex;
  align-items: center;
}

.profile-image {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-right: 12px;
}
.profile-image img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.profile-name h3 {
  font-size: 16px;
  font-weight: 600;
}

.profile-name p {
  font-size: 12px;
  opacity: 0.8;
}

/* Área de mensagens */
.messages {
  flex: 1;
  background-color: var(--conversation-panel-background);
  transition: background-color 0.3s ease;
  transform-origin: left top;
  position: relative;
}
.chat-messages {
  overflow: auto;
  height: calc(100vh - 168px);
}
.background-chat {
  position: absolute;
  inset: 0;
  right: 10px;
  opacity: 0.4;
  background-image: url("/static/background.png");
  pointer-events: none;
}
.messages-container {
  flex: 1;
  padding: 16px 62px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Estilos das mensagens */
.message {
  max-width: 70%;
  margin-bottom: 12px;
  padding-left: 9px;
  padding-right: 9px;
  padding-top: 6px;
  padding-bottom: 14px;
  border-radius: var(--border-radius);

  position: relative;
  font-size: 14px;
  display: flex;
  gap: 5px;
}
.message.received span {
  line-height: 1.5;
  padding-right: 10px;
}
.message.received {
  border-top-left-radius: 0px;
}
.message.sent {
  border-top-right-radius: 0px;
  padding-right: 50px;
  line-height: 1.5;
}

.message-time {
  font-size: 11px;
  color: var(--light-text);
  position: absolute;
  bottom: 3px;
  right: 8px;
}

.message.received::after {
  content: "";
  position: absolute;
  top: 0px;
  left: -6px;
  width: 0;
  height: 0;
  rotate: -90deg;
  border-style: solid;
  border-width: 6px 12px 6px 0;
  border-color: transparent var(--received-msg-bg) transparent transparent;
}

.received {
  background-color: var(--received-msg-bg);
  align-self: flex-start;
}
.message.sent::after {
  content: "";
  position: absolute;
  top: 0px;
  right: -6px;
  width: 0;
  height: 0;
  rotate: -90deg;
  border-style: solid;
  border-width: 6px 12px 6px 0;
  border-color: transparent var(--sent-msg-bg) transparent transparent;
}
.message.received.button {
  margin-top: -8px;
}

.message.received.button {
  background: transparent;
  padding: 0px;
}
.message.received.button::after {
  display: none;
}
.option-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.option-button {
  background-color: white;
  color: var(--button-alternative);
  font-size: 14px;
  border: none;
  border-radius: 8px;
  padding: 10px 24px;
  cursor: pointer;
}

.sent {
  background-color: var(--sent-msg-bg);
  align-self: flex-end;
  box-shadow: var(--shadow);
}

/* Indicador de leitura (double check) */
.read-receipt {
  margin-left: 4px;
  color: #34b7f1;
}

/* Área de entrada de texto */
.input-area {
  display: flex;
  padding: 12px 24px;
  background-color: var(--panel-header-background);
}

.input-area input {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  outline: none;
  font-size: 14px;
}

.input-area button {
  width: 40px;
  height: 40px;
  border: none;
  background-color: var(--primary-color);
  color: white;
  border-radius: 50%;
  margin-left: 8px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Modal de confirmação */
/* .modal {
  display: none;
  position: fixed;
  z-index: 100;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: white;
  width: 90%;
  max-width: 500px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.modal-header {
  padding: 16px;
  color: var(--primary-strong);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.close-modal {
  font-size: 24px;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
  max-height: 400px;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background-color: #f5f5f5;
}

.modal-footer button {
  padding: 10px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#confirm-data-btn {
  background-color: var(--primary-color);
  color: white;
}

#edit-data-btn {
  background-color: #f0f0f0;
  color: var(--text-color);
} */

/* Responsividade */
@media (max-width: 768px) {
  .chat-background {
    height: 100vh;
    padding: 10px;
    margin-top: 0px;
  }
  .chat-container {
    width: 100%;
    max-height: 90vh;
  }
  .chat-messages {
    height: calc(90vh - 128px);
  }
  .messages-container {
    padding: 16px;
  }
  .message {
    max-width: 90%;
  }
}

/* Estilos para o indicador de digitação */
.typing {
  padding: 8px 15px !important;
  min-height: 20px;
  display: flex;
  align-items: center;
}

.typing-dots {
  display: inline-block;
  margin-right: 5px;
}

.typing-dots span {
  opacity: 0;
  animation: typingDot 1.4s infinite;
  display: inline-block;
  font-size: 16px;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingDot {
  0% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* Estilos para input desabilitado */
#user-input:disabled {
  background-color: #f2f2f2;
  border: 1px solid #ddd;
  color: #888;
}

#send-btn:disabled {
  background-color: #cccccc;
  cursor: not-allowed;
}

/* Estilos para indicação visual de campo numérico */
#user-input.numeric-only:focus {
  background-color: #f8fbff;
  border-color: #128c7e;
}

/* Feedback visual quando digita caractere não permitido */
#user-input.error-shake {
  animation: shake 0.3s;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

/* Estilização do placeholder */
#user-input::placeholder {
  color: var(--light-text);
}

/* Campo de input desativado */
#user-input:disabled {
  background-color: #f2f2f2;
  cursor: not-allowed;
  color: #888;
}

#send-btn:disabled {
  background-color: #cccccc;
  cursor: not-allowed;
}

/* Modal Overlay */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
}

.modal-wrapper {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  width: 90%;
  max-width: 380px;
}
.modal-wrapper.edit-mode {
  max-width: 1000px;
}

/* Modal Container */
.modal {
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Modal Header */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 1.5rem;
  color: var(--primary-strong);
  margin: 0;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #888;
  cursor: pointer;
  transition: color 0.2s;
}

.close-btn:hover {
  color: #333;
}

/* Modal Content */
.modal-content section {
  margin-bottom: 12px;
}

.modal-content h3 {
  font-size: 1rem;
  color: var(--primary-strong);
  margin-bottom: 6px;
}

.modal-content p {
  margin: 2px 0;
  font-size: 0.95rem;
  color: var(--text-color);
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.modal-content label {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
  font-weight: 500;
  color: var(--text-color);
  font-size: 0.95rem;
}

.modal-content input,
.modal-content select {
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.95rem;
  margin-top: 4px;
  transition: border 0.2s;
  width: 100%;
  box-sizing: border-box;
}

.modal-content input:focus,
.modal-content select:focus {
  border-color: var(--primary-color);
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 168, 132, 0.2);
}

/* Modal Actions */
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.modal-actions.edit {
  display: none;
}

.edit-btn,
.confirm-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.2s;
}

.edit-btn {
  background: var(--panel-header-background);
  color: var(--primary-strong);
}

.edit-btn:hover {
  color: var(--text-color);
}

.confirm-btn {
  background: var(--primary-color);
  color: white;
}

.confirm-btn:hover {
  background: var(--app-background);
}