/**
 * Messages / Chat Styles
 */

/* Messages Container - takes full height */
.messages-container {
  height: calc(100vh - 140px);
  display: flex;
}

/* Messages View - Split Layout */
.messages-view {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 0;
  height: 100%;
  min-height: 450px;
  background: rgba(var(--color-surface-rgb, 15, 23, 42), 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xl);
  overflow: hidden;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow:
    4px 4px 20px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

@media (max-width: 768px) {
  .messages-view {
    grid-template-columns: 1fr;
    height: 100%;
  }

  /* Messages container fixed on mobile - aproape de topbar */
  .messages-container {
    position: fixed;
    top: 70px;
    left: 12px;
    right: 12px;
    bottom: 110px;
    height: auto;
    overflow: hidden;
    display: flex;
  }

  /* Conversations panel fills container, only list scrolls */
  .conversations-panel {
    display: flex !important;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow: hidden;
  }

  /* Search header stays fixed at top */
  .conversations-header {
    flex-shrink: 0;
  }

  /* Only the conversations list scrolls */
  .conversations-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  /* Hide chat panel completely on mobile - show only conversations list */
  .chat-panel {
    display: none !important;
  }

  /* When chat is open - Messenger style full screen */
  .view.chat-mode-active .view-header {
    display: none;
  }

  .view.chat-mode-active .messages-container {
    height: 100vh;
    height: 100dvh;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    background: var(--color-background, #0f172a);
  }

  .view.chat-mode-active .messages-view {
    height: 100%;
    border-radius: 0;
    border: none;
  }

  /* When chat mode active - show chat, hide conversations */
  .view.chat-mode-active .chat-panel {
    display: flex !important;
    height: 100%;
    width: 100%;
  }

  .view.chat-mode-active .conversations-panel {
    display: none !important;
  }

  .view.chat-mode-active .chat-active {
    height: 100%;
    display: flex !important;
    flex-direction: column;
  }
}

/* Conversations Panel */
.conversations-panel {
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
  max-height: 100%;
  overflow: hidden;
}

/* Chat Panel */
.chat-panel {
  display: flex;
  flex-direction: column;
  max-height: 100%;
  height: 100%;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.01);
}

/* Chat Active Container */
.chat-active {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.chat-active[hidden] {
  display: none !important;
}

/* Chat Messages Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

@media (max-width: 768px) {
  .messages-view.chat-open .conversations-panel {
    display: none;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   SEARCH BAR - GLASS 3D WITH ALIGNED ICON
   ═══════════════════════════════════════════════════════════════════ */
.conversations-search {
  padding: var(--space-4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.conversations-search .search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.conversations-search .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--color-text-muted);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.conversations-search input {
  width: 100%;
  padding: var(--space-3) var(--space-4) var(--space-3) 44px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  color: var(--color-text);
  transition: all 0.25s ease;
  box-shadow:
    inset 2px 2px 4px rgba(0, 0, 0, 0.2),
    inset -1px -1px 2px rgba(255, 255, 255, 0.03);
}

.conversations-search input::placeholder {
  color: var(--color-text-muted);
}

.conversations-search input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: rgba(255, 255, 255, 0.06);
  box-shadow:
    inset 2px 2px 4px rgba(0, 0, 0, 0.2),
    0 0 0 3px rgba(251, 146, 60, 0.15);
}

/* Conversations List with proper scroll */
.conversations-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.conversations-list::-webkit-scrollbar {
  width: 6px;
}

.conversations-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 3px;
}

.conversations-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.conversations-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ═══════════════════════════════════════════════════════════════════
   CONVERSATION ITEM - ENHANCED 3D GLASS
   ═══════════════════════════════════════════════════════════════════ */
.conversation-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  margin: var(--space-2);
  cursor: pointer;
  transition: all 0.25s ease;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  box-shadow:
    2px 2px 6px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.conversation-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  background: linear-gradient(180deg, #8b5cf6, #7c3aed);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.conversation-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
  transform: translateX(4px);
  box-shadow:
    4px 4px 12px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.conversation-item:hover::before {
  opacity: 0.5;
}

.conversation-item.active {
  background: rgba(251, 146, 60, 0.12);
  border-color: rgba(251, 146, 60, 0.3);
  box-shadow:
    0 4px 16px rgba(251, 146, 60, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.conversation-item.active::before {
  background: linear-gradient(180deg, #f97316, #ea580c);
  opacity: 1;
}

.conversation-item.unread {
  background: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.2);
}

.conversation-item.unread::before {
  opacity: 1;
}

/* Avatar 3D */
.conversation-avatar {
  position: relative;
  flex-shrink: 0;
}

.conversation-avatar img {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    3px 3px 8px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.online-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background-color: var(--color-success);
  border: 2px solid var(--color-surface);
  border-radius: var(--radius-full);
}

/* Content */
.conversation-content {
  flex: 1;
  min-width: 0;
}

.conversation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-1);
}

.conversation-name {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-text);
}

.conversation-time {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.conversation-preview {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: var(--space-1);
}

.conversation-property {
  display: inline-block;
  font-size: var(--text-xs);
  color: var(--color-primary);
  background-color: var(--color-primary-light);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
}

/* Unread Badge */
.unread-badge {
  flex-shrink: 0;
  min-width: 20px;
  height: 20px;
  padding: 0 var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 600;
  color: white;
  background-color: var(--color-primary);
  border-radius: var(--radius-full);
}

/* Chat Panel */
.chat-panel {
  display: flex;
  flex-direction: column;
  background-color: var(--color-background);
}

@media (max-width: 768px) {
  .chat-panel {
    display: none;
  }

  .messages-view.chat-open .chat-panel {
    display: flex;
  }
}

/* Chat Header */
.chat-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.btn-back {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--color-text);
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.btn-back:hover {
  background-color: var(--color-background);
}

@media (max-width: 768px) {
  .btn-back {
    display: flex;
  }
}

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.chat-info {
  flex: 1;
}

.chat-name {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-text);
}

.chat-property {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Chat Messages */
/* ═══════════════════════════════════════════════════════════════════
   CHAT MESSAGES - GLASS 3D WITH SCROLL
   ═══════════════════════════════════════════════════════════════════ */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: transparent;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(251, 146, 60, 0.3);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(251, 146, 60, 0.5);
}

/* Message */
.message {
  display: flex;
  max-width: 75%;
  animation: messageIn 0.3s ease;
}

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

.message.other {
  align-self: flex-start;
}

.message.own {
  align-self: flex-end;
}

/* Message Bubble - Glass 3D */
.message-bubble {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-xl);
  position: relative;
  box-shadow:
    2px 2px 8px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.message.other .message-bubble {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom-left-radius: var(--radius-sm);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.message.own .message-bubble {
  background: linear-gradient(135deg, rgba(251, 146, 60, 0.9), rgba(234, 88, 12, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-bottom-right-radius: var(--radius-sm);
  color: white;
  box-shadow:
    0 4px 15px rgba(251, 146, 60, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.message-text {
  font-size: var(--text-sm);
  line-height: 1.6;
  margin-bottom: var(--space-1);
  word-break: break-word;
}

.message-time {
  font-size: var(--text-xs);
  opacity: 0.7;
}

.message.own .message-time {
  text-align: right;
}

/* Chat Empty */
.chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* Chat Loading */
.chat-loading {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Chat Error */
.chat-error {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  color: var(--color-text-muted);
}

.chat-error svg,
.chat-error i {
  width: 48px;
  height: 48px;
  color: var(--color-warning);
}

/* Chat Form */
.chat-form {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  padding: var(--space-4);
  background-color: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

.chat-form textarea {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: var(--space-3) var(--space-4);
  background-color: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-family: inherit;
  font-size: var(--text-sm);
  resize: none;
  line-height: 1.5;
}

.chat-form textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.chat-form .btn-icon,
.chat-form button[type="submit"] {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.chat-form button:hover {
  background-color: var(--color-primary-hover);
}

.chat-form button svg,
.chat-form button i {
  width: 20px;
  height: 20px;
}

/* ═══════════════════════════════════════════════════════════════════
   NO CHAT SELECTED - GLASS 3D PLACEHOLDER
   ═══════════════════════════════════════════════════════════════════ */
.chat-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-8);
  color: var(--color-text-muted);
  background: rgba(255, 255, 255, 0.01);
}

.chat-placeholder .empty-state-icon {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(124, 58, 237, 0.3));
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-6);
  box-shadow:
    6px 6px 20px rgba(0, 0, 0, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.1);
}

.chat-placeholder .empty-state-icon svg,
.chat-placeholder svg,
.chat-placeholder i {
  width: 40px;
  height: 40px;
  color: #8b5cf6;
}

.chat-placeholder h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.chat-placeholder p {
  font-size: var(--text-sm);
  max-width: 280px;
}

/* Empty conversations state - inside conversations panel */
.conversations-empty,
.empty-state.empty-messages {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-8) var(--space-4);
  margin: var(--space-4);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-xl);
  box-shadow:
    4px 4px 16px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.conversations-empty .empty-state-icon,
.empty-state.empty-messages .empty-state-icon {
  width: 70px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(124, 58, 237, 0.3));
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-4);
  box-shadow:
    4px 4px 12px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.conversations-empty .empty-state-icon svg,
.empty-state.empty-messages .empty-state-icon svg {
  width: 32px;
  height: 32px;
  color: #8b5cf6;
}

.conversations-empty h3,
.empty-state.empty-messages h3 {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.conversations-empty p,
.empty-state.empty-messages p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: 220px;
}

/* ═══════════════════════════════════════════════════════════════════
   LOADING & SPINNER STATES
   ═══════════════════════════════════════════════════════════════════ */
.chat-loading {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
}

.chat-loading .spinner,
.messages-loading .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.chat-error {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-6);
  text-align: center;
  color: var(--color-text-muted);
}

.chat-error svg,
.chat-error i {
  width: 48px;
  height: 48px;
  color: var(--color-warning);
}

/* Skeleton items */
.conversation-item.skeleton-item {
  pointer-events: none;
}

.conversation-item .skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

.conversation-item .conversation-avatar.skeleton {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.conversation-item .skeleton-text {
  height: 14px;
  margin-bottom: var(--space-2);
}

.conversation-item .skeleton-text.lg {
  height: 12px;
  width: 80%;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Glass styles for messages */
.messages-container {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  height: calc(100vh - 200px);
  min-height: 500px;
  max-height: 700px;
  background: rgba(var(--color-surface-rgb, 15, 23, 42), 0.6);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

@media (max-width: 768px) {
  .messages-container {
    grid-template-columns: 1fr;
    height: calc(100vh - 180px);
    max-height: none;
  }

  .messages-container.chat-open .conversations-panel,
  .conversations-panel.hidden-mobile {
    display: none !important;
  }

  .messages-container.chat-open .chat-panel {
    display: flex;
  }

  /* Show chat panel when conversation selected */
  .chat-panel {
    display: flex;
  }

  .chat-active {
    display: flex;
    flex-direction: column;
    height: 100%;
  }
}

/* Glass conversations panel */
.conversations-panel {
  background: rgba(255, 255, 255, 0.02);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.conversations-header {
  padding: var(--space-4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* Glass conversation styles now defined at top of file */

/* Glass tag for property */
.conversation-property.glass-tag {
  display: inline-block;
  margin-top: var(--space-1);
  padding: 2px var(--space-2);
  font-size: var(--text-xs);
  background: rgba(251, 146, 60, 0.15);
  color: var(--color-primary);
  border: 1px solid rgba(251, 146, 60, 0.3);
  border-radius: var(--radius-sm);
}

/* Unread badge 3D */
.unread-badge.badge-3d {
  min-width: 22px;
  height: 22px;
  padding: 0 var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  border-radius: var(--radius-full);
  box-shadow:
    0 4px 10px rgba(139, 92, 246, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Chat header glass - enhanced */
.chat-header .chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.1);
  box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.2);
}

.chat-header-info .chat-name {
  display: block;
  font-weight: 600;
  color: var(--color-text);
}

.chat-header-info .chat-property {
  display: block;
  font-size: var(--text-sm);
  color: var(--color-primary);
}

/* Back button mobile - old style */
.btn-back-mobile {
  display: none;
  width: 36px;
  height: 36px;
  padding: 0;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-back-mobile:hover {
  background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 768px) {
  .btn-back-mobile {
    display: flex;
  }
}

/* Back to menu button - with text */
.btn-back-menu {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: linear-gradient(135deg, rgba(251, 146, 60, 0.2), rgba(234, 88, 12, 0.15));
  border: 1px solid rgba(251, 146, 60, 0.3);
  border-radius: 20px;
  color: #fb923c;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  flex-shrink: 0;
}

.btn-back-menu svg {
  flex-shrink: 0;
}

.btn-back-menu:hover {
  background: linear-gradient(135deg, rgba(251, 146, 60, 0.3), rgba(234, 88, 12, 0.25));
  transform: translateX(-2px);
}

@media (max-width: 768px) {
  .btn-back-menu {
    display: flex;
  }
}

/* Hide bottom navbar when in chat mode */
body.chat-fullscreen .mobile-nav {
  display: none !important;
}

.chat-messages {
  background: transparent;
}

/* ═══════════════════════════════════════════════════════════════════
   EMOJI BAR - TOP EMOTICONS
   ═══════════════════════════════════════════════════════════════════ */
.chat-emoji-bar {
  display: none;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: rgba(255, 255, 255, 0.03);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  animation: slideDown 0.2s ease;
}

.chat-emoji-bar.visible {
  display: flex;
}

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

.emoji-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow:
    2px 2px 6px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.emoji-btn:hover {
  transform: scale(1.15);
  background: rgba(255, 255, 255, 0.1);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.emoji-btn:active {
  transform: scale(0.95);
}

/* ═══════════════════════════════════════════════════════════════════
   CHAT FORM - GLASS 3D WITH ACTIONS
   ═══════════════════════════════════════════════════════════════════ */
.chat-form.glass-chat-form {
  background: rgba(255, 255, 255, 0.04);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: var(--space-3) var(--space-4);
  display: flex;
  gap: var(--space-3);
  align-items: flex-end;
}

.chat-actions-left {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.btn-chat-action {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow:
    2px 2px 6px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.btn-chat-action:hover {
  color: var(--color-primary);
  background: rgba(251, 146, 60, 0.1);
  border-color: rgba(251, 146, 60, 0.3);
  transform: translateY(-2px);
}

.btn-chat-action svg {
  width: 20px;
  height: 20px;
}

/* Textarea styling */
.chat-form.glass-chat-form textarea {
  flex: 1;
  min-height: 42px;
  max-height: 120px;
  padding: var(--space-3) var(--space-4);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-xl);
  color: var(--color-text);
  font-size: var(--text-sm);
  font-family: inherit;
  resize: none;
  transition: all 0.2s ease;
  box-shadow:
    inset 2px 2px 4px rgba(0, 0, 0, 0.15),
    inset -1px -1px 2px rgba(255, 255, 255, 0.02);
}

.chat-form.glass-chat-form textarea::placeholder {
  color: var(--color-text-muted);
}

.chat-form.glass-chat-form textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  background: rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 2px 2px 4px rgba(0, 0, 0, 0.15),
    0 0 0 3px rgba(251, 146, 60, 0.15);
}

/* Send button */
.btn-send-message {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f97316, #ea580c);
  border: none;
  border-radius: var(--radius-xl);
  color: white;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow:
    4px 4px 12px rgba(249, 115, 22, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-send-message:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow:
    0 8px 20px rgba(249, 115, 22, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-send-message:active {
  transform: translateY(-1px) scale(0.98);
}

.btn-send-message svg {
  width: 22px;
  height: 22px;
}

/* ═══════════════════════════════════════════════════════════════════
   CHAT INPUT - WITH EMOJI AND UPLOAD BUTTONS
   ═══════════════════════════════════════════════════════════════════ */
.chat-input,
.chat-form:not(.glass-chat-form) {
  background: rgba(var(--color-surface-rgb, 15, 23, 42), 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.chat-input input,
.chat-form:not(.glass-chat-form) input {
  flex: 1;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  color: #fff;
  font-size: 0.9rem;
  min-width: 0;
}

.chat-input input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.chat-input input:focus {
  outline: none;
  border-color: #fb923c;
  background: rgba(255, 255, 255, 0.08);
}

/* Chat input buttons - emoji, upload, send */
.chat-input-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.chat-input-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.chat-input-btn.btn-emoji:hover {
  color: #fbbf24;
}

.chat-input-btn.btn-upload:hover {
  color: #60a5fa;
}

.chat-input-btn.btn-send {
  background: linear-gradient(135deg, #fb923c, #ea580c);
  color: white;
  box-shadow: 0 4px 12px rgba(251, 146, 60, 0.3);
}

.chat-input-btn.btn-send:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(251, 146, 60, 0.4);
}

.chat-input-btn svg {
  width: 22px;
  height: 22px;
}

/* Emoji Picker Popup */
.emoji-picker-popup {
  position: absolute;
  bottom: 100%;
  left: 8px;
  margin-bottom: 8px;
  background: rgba(var(--color-elevated-rgb, 30, 41, 59), 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 12px;
  box-shadow:
    0 -8px 32px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.05);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.2s ease;
  z-index: 9999;
}

.emoji-picker-popup.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.emoji-picker-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}

.emoji-picker-grid button {
  width: 40px;
  height: 40px;
  font-size: 22px;
  background: transparent;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.emoji-picker-grid button:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.15);
}

.emoji-picker-grid button:active {
  transform: scale(0.95);
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .chat-input {
    padding: 10px 12px;
    gap: 6px;
  }

  .chat-input-btn {
    width: 36px;
    height: 36px;
  }

  .chat-input-btn svg {
    width: 20px;
    height: 20px;
  }

  .chat-input input {
    padding: 10px 14px;
    font-size: 0.85rem;
  }

  /* Emoji picker mobile */
  .emoji-picker-popup {
    left: 0;
    right: 0;
    margin-left: 12px;
    margin-right: 12px;
    border-radius: 14px;
  }

  .emoji-picker-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
  }

  .emoji-picker-grid button {
    width: 100%;
    height: 44px;
    font-size: 24px;
  }
}

