/* ============================================
   RAAHI — Chat UI Styles (Enhanced & Modern)
   ============================================ */

:root {
  --chat-sidebar-width: 360px;
  --chat-header-height: 72px;
}

.chat-layout {
  display: flex;
  height: calc(100vh - var(--header-height));
  background: linear-gradient(135deg, #F9FAFB 0%, #F3F4F6 100%);
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border);
  overflow: hidden;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

/* ═══════════════════════════════════════════
   CHAT SIDEBAR
   ═══════════════════════════════════════════ */

.chat-sidebar {
  width: var(--chat-sidebar-width);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  background: var(--color-white);
  flex-shrink: 0;
}

@media (max-width: 767px) {
  .chat-sidebar {
    width: 100%;
    position: absolute;
    inset: 0;
    z-index: 2;
    background: var(--color-white);
  }
}

/* Sidebar Header */
.chat-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border-light);
  gap: 12px;
}

.chat-sidebar-title-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.chat-sidebar-header h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

.chat-unread-count {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
  color: white;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}

/* Search Bar */
.chat-sidebar-search {
  padding: 16px 16px;
  border-bottom: 1px solid var(--color-border-light);
}

.chat-sidebar-search .input-with-icon {
  position: relative;
}

.chat-sidebar-search .input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border: 1px solid var(--color-border);
  border-radius: 24px;
  font-size: 14px;
  background: var(--color-bg-secondary);
  transition: all 0.2s ease;
}

.chat-sidebar-search .input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--color-white);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.chat-sidebar-search .input-icon-left {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
}

/* Chat List */
.chat-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

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

.chat-list::-webkit-scrollbar-track {
  background: transparent;
}

.chat-list::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.chat-list::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-light);
}

/* Chat List Item */
.chat-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  margin: 0 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 12px;
  position: relative;
}

.chat-list-item:hover {
  background: var(--color-bg-secondary);
}

.chat-list-item.active {
  background: linear-gradient(135deg, #F0F9FF 0%, #E0F2FE 100%);
  border-left: 3px solid var(--color-primary);
  padding-left: 9px;
}

/* Chat List Avatar */
.chat-list-avatar {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.avatar-group {
  display: flex;
  align-items: center;
}

.avatar-group .avatar {
  border: 2px solid white;
}

.avatar-group .avatar:not(:first-child) {
  margin-left: -8px;
}

.status-indicator {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  background: #10B981;
  border: 2px solid white;
  border-radius: 50%;
}

/* Chat List Info */
.chat-list-info {
  flex: 1;
  min-width: 0;
}

.chat-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.chat-list-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-list-time {
  font-size: 12px;
  color: var(--color-text-light);
  flex-shrink: 0;
  white-space: nowrap;
}

.chat-list-preview {
  font-size: 13px;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-list-unread {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
  color: white;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}


/* ═══════════════════════════════════════════
   CHAT MAIN
   ═══════════════════════════════════════════ */

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: linear-gradient(to bottom, var(--color-white) 0%, #F9FAFB 100%);
}

@media (max-width: 767px) {
  .chat-main.hidden-mobile {
    display: none;
  }
}

/* Chat Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  height: var(--chat-header-height);
  border-bottom: 1px solid var(--color-border-light);
  background: var(--color-white);
}

.chat-back-btn {
  display: none;
  background: none;
  border: none;
  color: var(--color-text);
  cursor: pointer;
  font-size: 20px;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

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

@media (max-width: 767px) {
  .chat-back-btn { 
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

.chat-header-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.chat-header-avatar {
  position: relative;
  flex-shrink: 0;
}

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

.chat-header-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
  line-height: 1.2;
}

.chat-header-status {
  font-size: 12px;
  color: #10B981;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.chat-header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10B981;
}

.chat-header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.chat-header-actions .btn {
  padding: 8px;
  color: var(--color-text-muted);
  transition: all 0.2s ease;
}

.chat-header-actions .btn:hover {
  background: var(--color-bg-secondary);
  color: var(--color-text);
}

/* ═══════════════════════════════════════════
   CHAT MESSAGES
   ═══════════════════════════════════════════ */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: linear-gradient(135deg, #F9FAFB 0%, #F3F4F6 100%);
}

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

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-light);
}

/* Date Divider */
.chat-date-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--color-text-light);
  margin: 8px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.chat-date-divider::before,
.chat-date-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border-light);
}

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

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

.message.message-out {
  align-self: flex-end;
  flex-direction: row-reverse;
  max-width: 75%;
}

@media (max-width: 767px) {
  .message {
    max-width: 85%;
  }
  
  .message.message-out {
    max-width: 85%;
  }
}

/* Message Content */
.message-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Message Bubble */
.message-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}

.message-in .message-bubble {
  background: var(--color-white);
  color: var(--color-text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--color-border-light);
}

.message-in .message-bubble:hover {
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.message-out .message-bubble {
  background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

.message-out .message-bubble:hover {
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Message Time */
.message-time {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
}

.message-in .message-time {
  color: var(--color-text-light);
  justify-content: flex-start;
}

.message-out .message-time {
  color: rgba(255, 255, 255, 0.7);
  justify-content: flex-end;
}

/* Voice Note */
.voice-note {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}

.voice-play {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.2);
  color: var(--color-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.voice-play:hover {
  background: rgba(59, 130, 246, 0.3);
  transform: scale(1.05);
}

.message-out .voice-play {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.voice-waveform {
  flex: 1;
  height: 24px;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 24"><rect x="5" y="8" width="3" height="8" fill="%233B82F6" opacity="0.6"/><rect x="12" y="4" width="3" height="16" fill="%233B82F6"/><rect x="19" y="10" width="3" height="6" fill="%233B82F6" opacity="0.6"/><rect x="26" y="6" width="3" height="12" fill="%233B82F6"/><rect x="33" y="8" width="3" height="8" fill="%233B82F6" opacity="0.6"/><rect x="40" y="2" width="3" height="20" fill="%233B82F6"/><rect x="47" y="10" width="3" height="6" fill="%233B82F6" opacity="0.6"/></svg>') no-repeat center / contain;
  min-width: 60px;
}

.message-out .voice-waveform {
  background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 24"><rect x="5" y="8" width="3" height="8" fill="white" opacity="0.6"/><rect x="12" y="4" width="3" height="16" fill="white"/><rect x="19" y="10" width="3" height="6" fill="white" opacity="0.6"/><rect x="26" y="6" width="3" height="12" fill="white"/><rect x="33" y="8" width="3" height="8" fill="white" opacity="0.6"/><rect x="40" y="2" width="3" height="20" fill="white"/><rect x="47" y="10" width="3" height="6" fill="white" opacity="0.6"/></svg>');
}

.voice-time {
  font-size: 12px;
  flex-shrink: 0;
}

.message-in .voice-time {
  color: var(--color-text-light);
}

.message-out .voice-time {
  color: rgba(255, 255, 255, 0.8);
}


/* ═══════════════════════════════════════════
   CHAT INPUT
   ═══════════════════════════════════════════ */

.chat-input-area {
  padding: 16px 24px;
  border-top: 1px solid var(--color-border-light);
  background: var(--color-white);
  flex-shrink: 0;
}

.chat-attachment-preview {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border-light);
  margin-bottom: 12px;
}

.chat-attachment-preview.hidden {
  display: none;
}

/* Input Wrapper */
.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: var(--color-bg-secondary);
  border-radius: 24px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  transition: all 0.2s ease;
}

.chat-input-wrapper:focus-within {
  border-color: var(--color-primary);
  background: var(--color-white);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Input Field */
.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--color-text);
  font-size: 14px;
  padding: 8px 4px;
  outline: none;
  font-family: inherit;
  resize: none;
  max-height: 100px;
}

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

/* Input Buttons */
.chat-input-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 6px;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-input-btn:hover {
  background: var(--color-bg-secondary);
  color: var(--color-text);
}

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

/* Send Button */
.chat-send-btn {
  background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 18px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.chat-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

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

/* ═══════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════ */

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

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

.animate-fade-in {
  animation: slideIn 0.3s ease;
}

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */

@media (max-width: 767px) {
  .chat-layout {
    border-radius: 0;
  }

  .chat-sidebar {
    border-right: none;
  }

  .chat-input-area {
    padding: 12px 16px;
  }

  .message {
    max-width: 90%;
  }

  .message.message-out {
    max-width: 90%;
  }
}

@media (max-width: 480px) {
  .chat-sidebar-header {
    padding: 16px 16px;
  }

  .chat-header {
    padding: 12px 16px;
    height: auto;
  }

  .chat-messages {
    padding: 16px;
    gap: 12px;
  }

  .message {
    max-width: 95%;
  }

  .message.message-out {
    max-width: 95%;
  }

  .chat-sidebar-search {
    padding: 12px 12px;
  }
}

/* Utilities */
.btn-sm {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.hide-desktop {
  display: none;
}

@media (max-width: 767px) {
  .hide-desktop {
    display: flex !important;
  }
}

/* Read receipts */
.read-receipt {
  font-size: 12px;
}

.read-receipt.read {
  color: var(--color-secondary);
}

/* Typing indicator in chat */
.chat-typing {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
}

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

/* Image attachment */
.chat-image {
  max-width: 260px;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
}

.chat-image img {
  width: 100%;
  border-radius: var(--radius-md);
}
