/* ==========================================================================
   CHAT & COMUNICAÇÃO - ULTRA ROUNDED MODERN UI DESIGN WITH FIXED INPUT BAR
   ========================================================================== */

/* Page layout container sizing: hides top-header and fits 100% height with ultra rounded frame */
body.chat-page-active .top-header {
  display: none !important;
}

body.chat-page-active .page-content {
  flex: 1 !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 12px 16px 16px 12px !important;
  margin: 0 !important;
  overflow: hidden !important;
  min-height: 0 !important;
  height: 100vh !important;
  max-height: 100vh !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

body.chat-page-active .main-content {
  overflow: hidden !important;
  height: 100vh !important;
}

.chat-page-wrapper {
  flex: 1 !important;
  display: flex !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  background: #FFFFFF;
  border-radius: 28px !important;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.05) !important;
  border: 1px solid rgba(226, 232, 240, 0.9) !important;
  overflow: hidden;
  margin: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
}

/* --------------------------------------------------------------------------
   LEFT PANEL: CONVERSATIONS LIST
   -------------------------------------------------------------------------- */
.chat-left-panel {
  width: 310px;
  min-width: 270px;
  background: #F8FAFC;
  border-right: 1px solid #E2E8F0;
  display: flex;
  flex-direction: column;
  padding: 18px 16px;
  gap: 16px;
  box-sizing: border-box;
  overflow: hidden;
  flex-shrink: 0;
  height: 100%;
  border-top-left-radius: 28px;
  border-bottom-left-radius: 28px;
}

/* User Profile Block at top of left panel */
.chat-user-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  padding-bottom: 12px;
  border-bottom: 1px solid #E2E8F0;
  flex-shrink: 0;
}

.chat-user-avatar-wrap {
  position: relative;
  width: 56px;
  height: 56px;
  margin-bottom: 8px;
}

.chat-user-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: linear-gradient(135deg, #1E4BFF, #60A5FA);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(30, 75, 255, 0.25);
}

.chat-status-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #10B981;
  border: 2px solid #FFFFFF;
}

.chat-user-name {
  font-size: 14px;
  font-weight: 700;
  color: #0F172A;
  margin: 0 0 4px 0;
}

.chat-status-select {
  background: #E6F4EA;
  color: #137333;
  border: none;
  padding: 4px 12px;
  border-radius: 24px !important;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.chat-status-select:hover {
  background: #CEEAD6;
}

/* Search Bar */
.chat-search-box {
  position: relative;
  width: 100%;
  flex-shrink: 0;
}

.chat-search-input {
  width: 100%;
  height: 40px;
  background: #EDF2F7;
  border: 1px solid transparent;
  border-radius: 20px !important;
  padding: 0 34px 0 36px;
  font-size: 13px;
  color: #1E293B;
  outline: none;
  box-sizing: border-box;
  transition: all 0.2s;
}

.chat-search-input:focus {
  background: #FFFFFF;
  border-color: #1E4BFF;
  box-shadow: 0 0 0 3px rgba(30, 75, 255, 0.1);
}

.chat-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #94A3B8;
  width: 15px;
  height: 15px;
  pointer-events: none;
}

/* Section Header (Últimas conversas) */
.chat-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
  flex-shrink: 0;
}

.chat-list-title {
  font-size: 11px;
  font-weight: 700;
  color: #64748B;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chat-list-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 12px !important;
  border: none;
  background: transparent;
  color: #64748B;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.chat-icon-btn:hover {
  background: #E2E8F0;
  color: #0F172A;
}

.chat-icon-btn.primary {
  background: rgba(30, 75, 255, 0.1);
  color: #1E4BFF;
  border-radius: 12px !important;
}
.chat-icon-btn.primary:hover {
  background: #1E4BFF;
  color: #FFFFFF;
}

/* Conversations List Items */
.chat-list-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.chat-list-items::-webkit-scrollbar {
  width: 4px;
}
.chat-list-items::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 18px !important;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  background: transparent;
}

.chat-item:hover {
  background: #EDF2F7;
}

.chat-item.active {
  background: #FFFFFF;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}

.chat-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: #1E4BFF;
}

.chat-item-avatar-wrap {
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.chat-item-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: #E2E8F0;
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.chat-item-avatar.group-avatar {
  background: linear-gradient(135deg, #0D9488, #2DD4BF);
  color: #FFFFFF;
}

.chat-item-info {
  flex: 1;
  min-width: 0;
}

.chat-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.chat-item-name {
  font-size: 13px;
  font-weight: 700;
  color: #0F172A;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-time {
  font-size: 10px;
  font-weight: 600;
  color: #94A3B8;
  flex-shrink: 0;
}

.chat-item-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-item-msg {
  font-size: 11px;
  color: #64748B;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 145px;
}

.chat-item-msg.typing {
  color: #0D9488;
  font-weight: 600;
  font-style: italic;
}

.chat-unread-badge {
  background: #1E4BFF;
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 12px !important;
  min-width: 18px;
  text-align: center;
}


/* --------------------------------------------------------------------------
   CENTER PANEL: MAIN CHAT THREAD & ALWAYS-VISIBLE INPUT BAR
   -------------------------------------------------------------------------- */
.chat-center-panel {
  flex: 1 !important;
  display: flex !important;
  flex-direction: column !important;
  background: #F8FAFC;
  position: relative;
  overflow: hidden !important;
  min-height: 0 !important;
  height: 100% !important;
}

/* Chat Header */
.chat-main-header {
  height: 64px;
  background: #FFFFFF;
  border-bottom: 1px solid #E2E8F0;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.chat-main-title-group h2 {
  font-size: 15px;
  font-weight: 700;
  color: #0F172A;
  margin: 0 0 2px 0;
}

.chat-main-title-group p {
  font-size: 11px;
  color: #64748B;
  margin: 0;
}

.chat-tabs-pill {
  display: none !important;
}

.chat-tab-btn {
  border: none;
  background: transparent;
  padding: 6px 16px;
  border-radius: 20px !important;
  font-size: 12px;
  font-weight: 600;
  color: #64748B;
  cursor: pointer;
  transition: all 0.2s;
}

.chat-tab-btn.active {
  background: #1E4BFF;
  color: #FFFFFF;
  box-shadow: 0 2px 10px rgba(30, 75, 255, 0.25);
}

/* Botão "Adicionar ao Cronograma" no cabeçalho do Chat (Mobile APK & Desktop) */
.chat-header-cronograma-btn {
  background: linear-gradient(135deg, #1E4BFF 0%, #0077B6 100%);
  color: #ffffff !important;
  border: none;
  border-radius: 12px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 3px 10px rgba(30, 75, 255, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.chat-header-cronograma-btn:hover {
  box-shadow: 0 4px 14px rgba(30, 75, 255, 0.35);
}

.chat-header-cronograma-btn:active {
  transform: scale(0.96);
}

.chat-header-cronograma-btn i {
  width: 14px;
  height: 14px;
}

@media (max-width: 768px) {
  .chat-main-header {
    height: 58px;
    padding: 0 10px;
    gap: 6px;
  }
  .chat-mobile-back-btn {
    padding: 4px 6px;
    font-size: 11px;
    flex-shrink: 0;
    gap: 2px;
  }
  .chat-mobile-back-btn span {
    display: none; /* Deixa apenas a seta para economizar espaço */
  }
  .chat-main-title-group {
    flex: 1;
    min-width: 0;
  }
  .chat-main-title-group h2 {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 110px;
  }
  .chat-main-title-group p {
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .chat-header-actions {
    flex-shrink: 0;
    gap: 5px !important;
  }
  .chat-header-cronograma-btn {
    padding: 6px 9px;
    font-size: 10.5px;
    border-radius: 10px;
    gap: 4px;
  }
}

@media (max-width: 480px) {
  .chat-main-title-group h2 {
    max-width: 90px;
  }
  .chat-header-cronograma-btn {
    padding: 5px 8px;
    font-size: 10px;
    gap: 3px;
  }
}

/* Message History Area (Scrolls inside remaining vertical space) */
.chat-messages-container {
  flex: 1 !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  padding: 26px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background-color: #F8FAFC;
  background-image: 
    radial-gradient(circle at 10% 15%, rgba(239, 246, 255, 0.8) 0%, transparent 45%),
    radial-gradient(circle at 90% 85%, rgba(238, 242, 255, 0.7) 0%, transparent 45%),
    radial-gradient(rgba(148, 163, 184, 0.15) 1.2px, transparent 1.2px);
  background-size: 100% 100%, 100% 100%, 24px 24px;
}

.chat-messages-container::-webkit-scrollbar {
  width: 6px;
}
.chat-messages-container::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 10px;
}

/* Date separator */
.chat-date-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 12px 0 16px 0;
}

.chat-date-divider span {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  color: #475569;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 16px;
  border-radius: 20px !important;
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

/* Message Rows */
.chat-msg-row {
  display: flex;
  gap: 10px;
  max-width: 65%;
}

.chat-msg-row.incoming {
  align-self: flex-start;
}

.chat-msg-row.outgoing {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: linear-gradient(135deg, #1E4BFF, #3B82F6);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
  box-shadow: 0 4px 10px rgba(30, 75, 255, 0.2);
}

.chat-msg-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-msg-meta {
  font-size: 10px;
  color: #64748B;
  display: flex;
  gap: 6px;
  align-items: center;
}

.outgoing .chat-msg-meta {
  justify-content: flex-end;
  color: #64748B;
}

.chat-msg-sender {
  font-weight: 700;
  color: #334155;
}

/* Collaborator Highlighting & Badges */
.collaborator-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2.5px 9px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  letter-spacing: 0.2px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.collaborator-badge:hover {
  transform: translateY(-1px);
}

.collaborator-bubble {
  background: #F8FAFC !important;
  color: #0F172A !important;
  border: 1px solid #E2E8F0 !important;
  border-top-right-radius: 4px !important;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06) !important;
}

.other-collaborator .chat-msg-meta {
  justify-content: flex-end;
}

.collaborator-avatar {
  font-weight: 800;
  box-shadow: 0 3px 10px rgba(0,0,0,0.15);
}

.chat-msg-bubble {
  padding: 12px 18px;
  border-radius: 20px !important;
  font-size: 13.5px;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
}

.incoming .chat-msg-bubble {
  background: #FFFFFF;
  color: #0F172A;
  border-top-left-radius: 4px !important;
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

.outgoing .chat-msg-bubble {
  background: linear-gradient(135deg, #1E4BFF 0%, #3B82F6 100%);
  color: #FFFFFF;
  border-top-right-radius: 4px !important;
  box-shadow: 0 4px 18px rgba(30, 75, 255, 0.28);
}

/* Mention Pill */
.chat-mention-tag {
  background: #E0F2FE;
  color: #0284C7;
  padding: 2px 10px;
  border-radius: 10px !important;
  font-weight: 600;
  display: inline-block;
  margin: 0 2px;
}

/* Message Emoji Reactions */
.chat-msg-reactions {
  display: flex;
  gap: 4px;
  margin-top: 3px;
}

.chat-reaction-badge {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 14px !important;
  padding: 3px 8px;
  font-size: 11px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

/* Typing status bar */
.chat-typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 24px 8px 24px;
  font-size: 11px;
  color: #64748B;
  font-style: italic;
  flex-shrink: 0;
}

/* Chat Input Bar (FIXED & ALWAYS VISIBLE AT BOTTOM) */
.chat-input-wrapper {
  flex-shrink: 0 !important;
  padding: 14px 24px 18px 24px;
  background: transparent;
  display: flex;
  justify-content: center;
}

.chat-input-bar {
  background: #FFFFFF;
  border-radius: 28px !important;
  padding: 6px 10px 6px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 900px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.04);
  border: 1px solid #E2E8F0;
}

.chat-main-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  color: #0F172A;
  padding: 8px 0;
}

.chat-main-input::placeholder {
  color: #94A3B8;
}

.chat-input-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 18px !important;
  background: #0D9488;
  color: #FFFFFF;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.35);
}

.chat-send-btn:hover {
  background: #0F766E;
  transform: scale(1.06);
}


/* --------------------------------------------------------------------------
   RIGHT PANEL: SHARED FILES & DETAILS
   -------------------------------------------------------------------------- */
.chat-right-panel {
  width: 310px;
  min-width: 270px;
  background: #FFFFFF;
  border-left: 1px solid #E2E8F0;
  display: flex;
  flex-direction: column;
  padding: 18px 16px;
  gap: 16px;
  box-sizing: border-box;
  overflow-y: auto;
  transition: all 0.3s ease;
  flex-shrink: 0;
  height: 100%;
  border-top-right-radius: 28px;
  border-bottom-right-radius: 28px;
}

.chat-right-panel.collapsed {
  display: none;
}

.chat-right-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chat-right-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-right-title {
  font-size: 13px;
  font-weight: 700;
  color: #0F172A;
  margin: 0;
}

/* Profile / Group Card in Right Panel */
.chat-group-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 10px 0;
  flex-shrink: 0;
}

.chat-group-cover {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  margin-bottom: 10px;
  background: linear-gradient(135deg, #0284C7, #38BDF8);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
}

.chat-group-name {
  font-size: 15px;
  font-weight: 800;
  color: #0F172A;
  margin: 0 0 2px 0;
}

.chat-group-sub {
  font-size: 11px;
  color: #64748B;
  margin: 0;
}

/* Quick Stats Grid */
.chat-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  flex-shrink: 0;
}

.chat-stat-box {
  padding: 14px 12px;
  border-radius: 20px !important;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.chat-stat-box.teal {
  background: #E6FFFA;
  border: 1px solid #B2F5EA;
  color: #0D9488;
}

.chat-stat-box.gray {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  color: #64748B;
}

.chat-stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 9px;
  font-weight: 700;
}

.chat-stat-val {
  font-size: 22px;
  font-weight: 800;
  color: #0F172A;
}

/* File Breakdown Section */
.chat-files-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.chat-files-title {
  font-size: 11px;
  font-weight: 700;
  color: #64748B;
  text-transform: uppercase;
}

.chat-file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 20px !important;
  background: #F8FAFC;
  border: 1px solid rgba(0,0,0,0.02);
  cursor: pointer;
  transition: all 0.2s;
}

.chat-file-item:hover {
  background: #F1F5F9;
  transform: translateX(2px);
}

.chat-file-icon-bg {
  width: 36px;
  height: 36px;
  border-radius: 14px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-file-icon-bg.doc { background: #E0F2FE; color: #0284C7; }
.chat-file-icon-bg.photo { background: #FEF3C7; color: #D97706; }
.chat-file-icon-bg.video { background: #CCFBF1; color: #0D9488; }
.chat-file-icon-bg.other { background: #FEE2E2; color: #DC2626; }

.chat-file-info {
  flex: 1;
}

.chat-file-name {
  font-size: 12px;
  font-weight: 700;
  color: #0F172A;
  margin: 0;
}

.chat-file-meta {
  font-size: 10px;
  color: #94A3B8;
  margin: 2px 0 0 0;
}

/* ==========================================================================
   CASCADE ENTRANCE / EXIT & FLUID THREAD SWITCHING ANIMATIONS
   ========================================================================== */

/* Keyframe Definitions */
@keyframes chatSlideInLeft {
  from {
    opacity: 0;
    transform: translateX(-35px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes chatSlideInRight {
  from {
    opacity: 0;
    transform: translateX(35px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes chatFadeScale {
  from {
    opacity: 0;
    transform: scale(0.97) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

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

@keyframes chatCascadeExit {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.96) translateY(12px);
  }
}

@keyframes threadSwitchIn {
  0% {
    opacity: 0;
    transform: translateY(16px) scale(0.985);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes bubblePop {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes msgSpringPop {
  0% {
    opacity: 0;
    transform: translate3d(28px, 18px, 0) scale(0.8) rotate(3deg);
    filter: blur(6px);
  }
  60% {
    opacity: 1;
    transform: translate3d(-4px, -2px, 0) scale(1.02) rotate(-0.5deg);
    filter: blur(0);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1) rotate(0);
    filter: blur(0);
  }
}

@keyframes msgSpringPopIncoming {
  0% {
    opacity: 0;
    transform: translate3d(-28px, 18px, 0) scale(0.8) rotate(-3deg);
    filter: blur(6px);
  }
  60% {
    opacity: 1;
    transform: translate3d(4px, -2px, 0) scale(1.02) rotate(0.5deg);
    filter: blur(0);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1) rotate(0);
    filter: blur(0);
  }
}

/* Page Cascade Entrance */
.chat-left-panel {
  animation: chatSlideInLeft 0.45s cubic-bezier(0.16, 1, 0.3, 1) 0.05s both;
}

.chat-center-panel {
  animation: chatFadeScale 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.15s both;
}

.chat-right-panel {
  animation: chatSlideInRight 0.45s cubic-bezier(0.16, 1, 0.3, 1) 0.25s both;
}

/* Staggered list items cascade entrance */
.chat-item {
  animation: chatCascadeUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(var(--i, 0) * 0.04s + 0.1s);
}

/* Fluid Profile / Thread Switching Animation */
.chat-thread-transition {
  animation: threadSwitchIn 0.38s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
}

.chat-msg-row {
  animation: bubblePop 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.chat-msg-row.outgoing.newly-sent {
  animation: msgSpringPop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) both !important;
}

.chat-msg-row.incoming.newly-sent {
  animation: msgSpringPopIncoming 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) both !important;
}

/* Page Exit Animation */
.chat-page-wrapper.chat-page-exiting {
  animation: chatCascadeExit 0.28s cubic-bezier(0.4, 0, 1, 1) forwards !important;
}

/* ==========================================================================
   WHATSAPP REAL MOBILE FLOW (Contatos Primeiro -> Chat Completo -> Botão Voltar)
   ========================================================================== */
@media (max-width: 768px) {
  .chat-page-wrapper {
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    overflow: hidden !important;
  }

  /* Default Mobile State: Contacts List ONLY */
  .chat-left-panel {
    width: 100% !important;
    min-width: 100% !important;
    height: 100% !important;
    border-radius: 0 !important;
    border-right: none !important;
    display: flex !important;
    flex: 1 !important;
    background: #FFFFFF !important;
    padding: 12px 14px calc(80px + env(safe-area-inset-bottom, 0px)) 14px !important;
  }

  .chat-center-panel {
    display: none !important;
    position: absolute !important;
    inset: 0 !important;
    z-index: 100 !important;
    width: 100% !important;
    height: 100% !important;
    background: #efeae2 !important;
  }

  .chat-right-panel {
    display: none !important;
  }

  /* Active Chat Mobile State: Hide Contacts List, Show Chat Room */
  .chat-page-wrapper.mobile-chat-active .chat-left-panel {
    display: none !important;
  }

  .chat-page-wrapper.mobile-chat-active .chat-center-panel {
    display: flex !important;
    flex-direction: column !important;
  }

  /* WhatsApp Header Mobile Styling & Back Button (< Voltar) */
  .chat-mobile-back-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 2px !important;
    background: none !important;
    border: none !important;
    color: #007AFF !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    padding: 6px 8px 6px 0 !important;
    margin-right: 4px !important;
    flex-shrink: 0 !important;
  }

  .chat-mobile-back-btn:active {
    opacity: 0.6 !important;
  }

  .chat-main-header {
    padding: 10px 14px !important;
    background: rgba(255, 255, 255, 0.95) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    backdrop-filter: blur(20px) !important;
    border-bottom: 0.5px solid rgba(60, 60, 67, 0.18) !important;
    flex-wrap: nowrap !important;
  }

  .chat-main-title-group h2 {
    font-size: 16px !important;
    font-weight: 700 !important;
  }

  .chat-messages-container {
    background-color: #efeae2 !important;
    background-image: radial-gradient(#d5ceb8 0.75px, transparent 0.75px) !important;
    background-size: 16px 16px !important;
    padding: 14px 12px 20px !important;
    flex: 1 !important;
    overflow-y: auto !important;
  }

  /* Chat Input Bar smoothly sits at bottom when navbar hides */
  .chat-input-wrapper {
    padding: 10px 14px calc(14px + env(safe-area-inset-bottom, 0px)) 14px !important;
    background: rgba(255, 255, 255, 0.96) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    backdrop-filter: blur(20px) !important;
    border-top: 0.5px solid rgba(60, 60, 67, 0.15) !important;
    position: relative !important;
    z-index: 20 !important;
    transition: padding 0.35s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }

  /* Full screen page content container for mobile chat */
  body.chat-page-active .page-content {
    padding: 0 !important;
    height: 100vh !important;
    max-height: 100vh !important;
  }

  /* Compact banner design on mobile */
  .chat-ai-banner {
    margin: 8px 10px 0 10px !important;
    padding: 8px 12px !important;
    border-radius: 10px !important;
    gap: 8px !important;
  }
  .chat-ai-banner h4 {
    font-size: 12px !important;
  }
  .chat-ai-banner p {
    display: none !important; /* Hide description to optimize viewport height */
  }
  .chat-ai-banner button {
    padding: 5px 10px !important;
    font-size: 10px !important;
  }
  .chat-msg-row {
    max-width: 82% !important;
  }
}

@media (min-width: 769px) {
  .chat-mobile-back-btn {
    display: none !important;
  }
}
