/* Reset e estilos base */
#whatsapp-clone-app {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Helvetica", "Arial", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
  padding: 0;
}

#whatsapp-clone-app * {
  box-sizing: border-box;
}

/* Otimização para mobile - container ocupa toda tela */
.whatsapp-container {
  width: 100%;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height para mobile */
  margin: 0;
  background: #0b141a;
  position: relative;
  overflow: hidden;
  /* Remove max-width e sombras para ocupar tela cheia em mobile */
}

/* Adiciona meta viewport via CSS para garantir renderização mobile */
@viewport {
  width: device-width;
  zoom: 1.0;
}

/* Tela de Boas-Vindas */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0;
  text-align: center;
  background: #111b21;
}

.welcome-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}

.whatsapp-logo {
  width: 192px;
  height: 192px;
  margin-bottom: 40px;
  object-fit: contain;
}

.whatsapp-logo-placeholder {
  width: 192px;
  height: 192px;
  background: #25d366;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 32px;
  font-weight: bold;
  margin-bottom: 40px;
}

.welcome-title {
  color: #e9edef;
  font-size: 28px;
  font-weight: 400;
  margin-bottom: 20px;
  line-height: 1.3;
}

.welcome-text {
  color: #8696a0;
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 0;
  max-width: 360px;
}

.welcome-link {
  color: #53bdeb;
  text-decoration: none;
}

.welcome-link:hover {
  text-decoration: underline;
}

.welcome-footer {
  width: 100%;
  padding: 20px 24px 40px;
  display: flex;
  justify-content: center;
}

.welcome-button {
  width: 100%;
  max-width: 360px;
  background: #00a884;
  color: #111b21;
  border: none;
  padding: 14px 24px;
  border-radius: 24px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.welcome-button:hover {
  background: #00967a;
}

.welcome-button:active {
  background: #008c72;
}

/* Tela de Input de Telefone */
.phone-input-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #0b141a;
}

.header {
  display: flex;
  align-items: center;
  padding: 20px 16px;
  background: #202c33;
  gap: 16px;
  /* Adiciona sombra para separação visual */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.header h1 {
  color: #e9edef;
  font-size: 19px;
  font-weight: 500;
  margin: 0;
  line-height: 1.3;
}

.phone-content {
  flex: 1;
  padding: 24px 20px;
  overflow-y: auto;
}

.phone-content p {
  color: #8696a0;
  font-size: 14px;
  text-align: center;
  margin-bottom: 28px;
  line-height: 1.5;
}

.phone-content a {
  color: #53bdeb;
  text-decoration: none;
}

.country-selector {
  margin-bottom: 20px;
}

.country-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: transparent;
  border: none;
  border-bottom: 1px solid #2a3942;
  color: #e9edef;
  font-size: 17px;
  cursor: pointer;
  transition: background 0.2s;
  text-align: left;
}

.country-btn:active {
  background: #182229;
}

.country-dropdown {
  margin-top: 8px;
  background: #202c33;
  border-radius: 8px;
  overflow: hidden;
  max-height: 60vh;
  overflow-y: auto;
}

.country-search {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #111b21;
  margin: 8px;
  border-radius: 8px;
  /* Adiciona borda para definir melhor o campo */
  border: 1px solid #2a3942;
}

.country-search input {
  flex: 1;
  background: transparent;
  border: none;
  color: #e9edef;
  font-size: 15px;
  outline: none;
}

.country-search input::placeholder {
  color: #667781;
}

.country-option {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  color: #e9edef;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 16px;
}

.country-option:active {
  background: #182229;
}

.country-flag {
  font-size: 28px;
  width: 32px;
}

/* Corrigido layout do phone-input-group para garantir que ambos inputs apareçam corretamente */
.phone-input-group {
  display: flex;
  gap: 12px;
  margin-bottom: 32px;
  align-items: center;
  flex-wrap: nowrap;
  width: 100%;
}

.code-input {
  width: 80px;
  /* Garante largura fixa para não expandir */
  flex-shrink: 0;
  padding: 14px 12px;
  background: transparent;
  border: none;
  border-bottom: 2px solid #00a884;
  text-align: center;
  color: #e9edef;
  font-size: 17px;
  outline: none;
  font-weight: 500;
}

.phone-input {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid #2a3942;
  color: #e9edef;
  font-size: 17px;
  outline: none;
  transition: border-color 0.2s;
  user-select: text !important;
  -webkit-user-select: text !important;
  pointer-events: auto !important;
  cursor: text !important;
  opacity: 1 !important;
  -webkit-text-fill-color: #e9edef !important;
  /* Garante que o input nunca fica readonly */
  -webkit-appearance: none;
  appearance: none;
}

.phone-input:focus {
  border-bottom-color: #00a884;
}

.phone-input::placeholder {
  color: #667781;
}

.btn-container {
  display: flex;
  justify-content: center;
  padding-top: 8px;
}

/* Tela de Verificação */
.verification-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #0b141a;
}

.verification-content {
  flex: 1;
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
}

.verification-content p {
  color: #8696a0;
  font-size: 14px;
  text-align: center;
  margin-bottom: 8px;
  line-height: 1.5;
}

.phone-display {
  color: #e9edef;
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  margin-bottom: 40px;
}

.code-inputs {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 40px;
  padding: 0 10px;
}

/* Ajusta tamanho dos inputs de código para mobile */
.code-digit {
  width: 48px;
  height: 52px;
  background: transparent;
  border: none;
  border-bottom: 2px solid #2a3942;
  color: #e9edef;
  text-align: center;
  font-size: 24px;
  outline: none;
  transition: border-color 0.2s;
  font-weight: 500;
}

.code-digit:focus {
  border-bottom-color: #00a884;
}

.resend-section {
  text-align: center;
  margin-top: auto;
}

.resend-section p {
  font-size: 14px;
  margin-bottom: 12px;
  color: #8696a0;
}

.resend-btn {
  background: none;
  border: none;
  color: #53bdeb;
  font-size: 15px;
  cursor: pointer;
  padding: 8px 16px;
  font-weight: 500;
}

.resend-btn:active {
  opacity: 0.7;
}

/* Chat Interface */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #0b141a;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px 10px 4px;
  background: #202c33;
  /* Adiciona sombra e z-index para header fixo */
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  position: relative;
  z-index: 10;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.back-btn {
  background: none;
  border: none;
  color: #aebac1;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  transition: opacity 0.2s;
  margin-right: 4px;
}

.back-btn:active {
  opacity: 0.6;
}

.avatar {
  width: 40px;
  height: 40px;
  background: #665c54;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.avatar-inner {
  width: 20px;
  height: 20px;
  background: #c8b697;
  border-radius: 50%;
}

.contact-name {
  color: #e9edef;
  font-size: 17px;
  font-weight: 500;
  /* Adiciona truncamento para nomes longos */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  background: none;
  border: none;
  color: #aebac1;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  transition: opacity 0.2s;
  /* Aumenta área de toque para mobile */
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
}

.icon-btn:active {
  opacity: 0.6;
}

/* Chat Area */
.chat-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 8px;
  position: relative;
  /* Melhora scroll em mobile */
  -webkit-overflow-scrolling: touch;
}

.chat-background {
  position: absolute;
  inset: 0;
  opacity: 0.06;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg width='120' height='120' xmlns='http://www.w3.org/2000/svg'%3E%3Cdefs%3E%3Cpattern id='gaming' x='0' y='0' width='120' height='120' patternUnits='userSpaceOnUse'%3E%3Ccircle cx='15' cy='15' r='3' fill='%23fff'/%3E%3Crect x='35' y='10' width='12' height='12' fill='none' stroke='%23fff' stroke-width='1.5'/%3E%3Cpath d='M60 15 L70 10 L70 20 Z' fill='none' stroke='%23fff' stroke-width='1.5'/%3E%3Ccircle cx='90' cy='15' r='5' fill='none' stroke='%23fff' stroke-width='1.5'/%3E%3C/pattern%3E%3C/defs%3E%3Crect width='100%25' height='100%25' fill='url(%23gaming)'/%3E%3C/svg%3E");
}

.message {
  margin-bottom: 4px;
  display: flex;
  /* Adiciona animação de entrada para mensagens */
  animation: messageSlideIn 0.2s ease-out;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.sent {
  justify-content: flex-end;
}

.message.received {
  justify-content: flex-start;
}

.message-bubble {
  max-width: 85%;
  padding: 6px 8px 8px 9px;
  border-radius: 8px;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

.message.sent .message-bubble {
  background: #005c4b;
  border-top-right-radius: 0;
}

.message.received .message-bubble {
  background: #202c33;
  border-top-left-radius: 0;
}

.message-text {
  color: #e9edef;
  font-size: 14.2px;
  margin: 0;
  word-wrap: break-word;
  line-height: 19px;
  white-space: pre-wrap;
}

.message-time {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
}

.time {
  font-size: 11px;
  color: rgba(241, 241, 242, 0.63);
}

.checkmarks {
  display: flex;
  gap: -10px;
  color: #53bdeb;
  font-size: 15px;
  line-height: 1;
}

/* Voice Player */
.voice-player {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  min-width: 200px;
}

.play-btn {
  background: none;
  border: none;
  color: #e9edef;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.play-btn:active {
  opacity: 0.7;
}

.waveform {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 32px;
  min-width: 0;
}

.waveform-bar {
  width: 3px;
  background: rgba(241, 241, 242, 0.4);
  border-radius: 2px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.waveform-bar.active {
  background: rgba(241, 241, 242, 0.85);
}

.voice-duration {
  font-size: 11px;
  color: rgba(241, 241, 242, 0.63);
  flex-shrink: 0;
  min-width: 32px;
  text-align: right;
}

/* Chat Input */
.chat-input {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 8px;
  background: #202c33;
  /* Adiciona separação visual e z-index */
  box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.1);
  position: relative;
  z-index: 10;
}

.input-container {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #2a3942;
  border-radius: 21px;
  padding: 9px 12px;
  min-height: 42px;
}

.message-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #e9edef;
  font-size: 15px;
  outline: none;
  line-height: 20px;
  min-height: 20px;
  max-height: 100px;
}

.message-input::placeholder {
  color: #667781;
}

.send-btn {
  width: 42px;
  height: 42px;
  background: #00a884;
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.send-btn:active {
  background: #008c72;
}

/* Utilidades */
.hidden {
  display: none !important;
}

/* Remove media query e força mobile first */
/* Ícones SVG */
.icon-svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.icon-sm {
  width: 20px;
  height: 20px;
}

/* Adiciona estilos para prevenir zoom em inputs no iOS mas garantir editabilidade */
@supports (-webkit-touch-callout: none) {
  input {
    font-size: 16px !important;
  }

  /* Garantir que inputs de telefone são sempre editáveis */
  .phone-input {
    -webkit-user-select: text !important;
    user-select: text !important;
    -webkit-tap-highlight-color: rgba(0, 168, 132, 0.1);
  }
}

/* Melhora scrollbar em mobile */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(134, 150, 160, 0.3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(134, 150, 160, 0.5);
}

/* Adiciona safe area para notch/ilha dinâmica */
@supports (padding: env(safe-area-inset-top)) {
  .chat-header {
    padding-top: max(10px, env(safe-area-inset-top));
  }

  .chat-input {
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }
}

/* Estilos para menu de deletar mensagens */
.delete-menu {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.delete-menu.show {
  opacity: 1;
}

.delete-menu-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(2px);
}

.delete-menu-content {
  position: relative;
  background: #2a3942;
  border-radius: 12px;
  padding: 0;
  min-width: 280px;
  max-width: 90%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.delete-menu.show .delete-menu-content {
  transform: scale(1);
}

.delete-menu-content h3 {
  color: #e9edef;
  font-size: 18px;
  font-weight: 500;
  margin: 0;
  padding: 24px 24px 16px;
  text-align: center;
}

.delete-menu-btn {
  width: 100%;
  background: transparent;
  border: none;
  color: #e9edef;
  padding: 16px 24px;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s;
  border-top: 1px solid #3b4a54;
  text-align: center;
  font-weight: 500;
}

.delete-menu-btn:active {
  background: #182229;
}

.delete-menu-btn.delete-for-me {
  color: #ea4335;
}

.delete-menu-btn.cancel-delete {
  color: #53bdeb;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
}

/* Estilos para mensagens apagadas */
.deleted-message {
  background: rgba(32, 44, 51, 0.5) !important;
  border: 1px dashed rgba(134, 150, 160, 0.3);
}

.message.sent .deleted-message {
  background: rgba(0, 92, 75, 0.3) !important;
}

.deleted-text {
  display: flex;
  align-items: center;
  color: rgba(233, 237, 239, 0.6) !important;
  font-size: 13px !important;
}

.deleted-text svg {
  flex-shrink: 0;
}

/* Estilos para mensagens com imagem */
.image-bubble {
  padding: 0 !important;
  overflow: hidden;
  max-width: 75%;
  position: relative;
}

.message-image {
  width: 100%;
  max-width: 100%;
  display: block;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.message-image:active {
  opacity: 0.9;
}

.image-bubble .message-text {
  padding: 6px 8px 8px 9px;
  margin: 0;
}

.message-time-overlay {
  position: absolute;
  bottom: 4px;
  right: 8px;
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 6px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
}

.message-time-overlay .time {
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.message-time-overlay .checkmarks {
  color: #53bdeb;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

/* Modal de imagem */
.image-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.image-modal.show {
  opacity: 1;
}

.image-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
}

.image-modal-content {
  position: relative;
  width: 90%;
  height: 90%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.image-modal.show .image-modal-content {
  transform: scale(1);
}

.image-modal-content img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.image-modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: none;
  color: white;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 1;
}

.image-modal-close:active {
  background: rgba(255, 255, 255, 0.2);
}

.image-modal-close .icon-svg {
  width: 28px;
  height: 28px;
}

/* Melhora área de toque do botão anexar */
#attachBtn {
  min-width: 44px;
  min-height: 44px;
}

/* Seletor de Emojis */
.emoji-picker {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: #202c33;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
  max-height: 300px;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 100;
}

.emoji-picker.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.emoji-picker-header {
  padding: 12px 16px 8px;
  border-bottom: 1px solid #2a3942;
}

.emoji-categories {
  display: flex;
  gap: 8px;
  justify-content: space-around;
}

.emoji-category {
  background: transparent;
  border: none;
  font-size: 24px;
  padding: 8px 16px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s;
  opacity: 0.6;
}

.emoji-category:active {
  background: #182229;
}

.emoji-category.active {
  opacity: 1;
  background: #2a3942;
}

.emoji-picker-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  -webkit-overflow-scrolling: touch;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 4px;
}

.emoji-item {
  background: transparent;
  border: none;
  font-size: 28px;
  padding: 8px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
}

.emoji-item:active {
  background: #2a3942;
  transform: scale(1.1);
}
