/* 
 * Trackara Shop Portal - Chat Styles
 * CSS for the enhanced customer chat interface
 */

/* Main chat container */
.chat-interface {
  display: flex;
  height: calc(100vh - 180px);
  min-height: 500px;
  background-color: var(--bg-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  position: relative;
  transition: height 0.3s ease;
}

/* Sidebar styles */
.chat-sidebar {
  width: 320px;
  background-color: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  height: 100%;
  z-index: 2;
  transition: width 0.3s ease;
}

.search-container {
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
}

.search-container .form-control-icon {
  position: relative;
}

.search-container .form-control-icon i {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-tertiary);
  font-size: 1rem;
  z-index: 1;
}

.search-container .form-control {
  padding-left: 40px;
  border-radius: 24px;
  background-color: var(--color-surface-hover);
  transition: all 0.2s ease;
}

.search-container .form-control:focus {
  background-color: var(--color-surface);
  box-shadow: 0 0 0 2px rgba(var(--teal-500-rgb), 0.15);
}

[data-theme="dark"] .search-container .form-control:focus {
  box-shadow: 0 0 0 2px rgba(var(--teal-400-rgb), 0.2);
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--color-text-disabled) transparent;
}

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

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

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

/* Conversation item styles */
.conversation-item {
  padding: 16px;
  border-bottom: 1px solid var(--color-divider);
  cursor: pointer;
  transition: background-color 0.2s ease;
  position: relative;
  display: flex;
  align-items: flex-start;
}

.conversation-item:hover {
  background-color: var(--color-surface-hover);
}

.conversation-item.active {
  background-color: rgba(var(--teal-500-rgb), 0.08);
}

[data-theme="dark"] .conversation-item.active {
  background-color: rgba(var(--teal-400-rgb), 0.15);
}

.conversation-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  flex-shrink: 0;
  margin-right: 12px;
}

/* Avatar colors */
.avatar-blue { background-color: #3b82f6; }
.avatar-green { background-color: #10b981; }
.avatar-purple { background-color: #8b5cf6; }
.avatar-pink { background-color: #ec4899; }
.avatar-indigo { background-color: #6366f1; }
.avatar-red { background-color: #ef4444; }
.avatar-teal { background-color: var(--color-primary-main); }

.conversation-content {
  overflow: hidden;
  flex: 1;
  min-width: 0; /* Prevents content from pushing beyond container */
}

.conversation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.conversation-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text-primary);
}

.conversation-time {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  white-space: nowrap;
  margin-left: 8px;
}

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

.conversation-vehicle {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
}

.conversation-vehicle i {
  margin-right: 4px;
  color: var(--color-primary-main);
}

.conversation-unread {
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background-color: var(--color-primary-main);
  color: white;
  font-size: 0.75rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  position: absolute;
  top: 16px;
  right: 16px;
}

/* Chat main area styles */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0; /* Ensures proper flex behavior */
}

/* Chat header styles */
.chat-header {
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--color-surface);
  height: 76px;
  flex-shrink: 0;
}

.chat-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.chat-user-name-container {
  overflow: hidden;
  flex: 1;
}

.chat-user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  flex-shrink: 0;
}

.chat-user-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text-primary);
}

#chat-last-active {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  white-space: nowrap;
}

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

.chat-action-button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chat-action-button:hover {
  background-color: var(--color-surface-hover);
  color: var(--color-primary-main);
}

.customer-vehicle-info,
.customer-appointment-info {
  font-size: 0.75rem;
  background-color: var(--color-surface-hover);
  color: var(--color-text-secondary);
  padding: 4px 10px;
  border-radius: 16px;
  margin-left: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  display: inline-block;
}

.customer-vehicle-info i,
.customer-appointment-info i {
  margin-right: 4px;
  color: var(--color-primary-main);
}

.appointment-status {
  display: inline-block;
  height: 8px;
  width: 8px;
  border-radius: 50%;
  margin-left: 4px;
  position: relative;
  top: -1px;
}

.appointment-status.confirmed,
.appointment-status.scheduled {
  background-color: var(--warning-main);
}

.appointment-status.completed {
  background-color: var(--success-main);
}

.appointment-status.cancelled {
  background-color: var(--error-main);
}

.appointment-status.in-progress {
  background-color: var(--info-main);
}

/* Messages area styles */
.chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  background-color: var(--bg-light);
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: var(--color-text-disabled) transparent;
}

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

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

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

/* Message styling */
.message {
  max-width: 75%;
  display: flex;
  flex-direction: column;
  position: relative;
  margin-bottom: 8px;
  animation: message-fade-in 0.3s ease;
}

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

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

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

.message-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
  line-height: 1.4;
}

.message.outgoing .message-bubble {
  background-color: var(--color-primary-main);
  color: white;
  border-bottom-right-radius: 4px;
}

.message.incoming .message-bubble {
  background-color: var(--color-surface);
  color: var(--color-text-primary);
  border-bottom-left-radius: 4px;
}

.message-time {
  font-size: 0.7rem;
  margin-top: 4px;
  text-align: right;
}

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

.message.incoming .message-time {
  color: var(--color-text-tertiary);
}

.message-date-separator {
  display: flex;
  align-items: center;
  margin: 16px 0;
  color: var(--color-text-tertiary);
  text-align: center;
  font-size: 0.75rem;
}

.message-date-separator::before,
.message-date-separator::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--color-divider);
}

.message-date-separator span {
  margin: 0 10px;
  padding: 0 5px;
  background-color: var(--bg-light);
}

/* Quick response buttons */
.quick-response-container {
  padding: 8px 16px;
  background-color: var(--color-surface);
  border-top: 1px solid var(--color-border);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: thin;
  scrollbar-color: var(--color-text-disabled) transparent;
  flex-shrink: 0;
}

.quick-response-container::-webkit-scrollbar {
  height: 4px;
}

.quick-response-container::-webkit-scrollbar-track {
  background: transparent;
}

.quick-response-container::-webkit-scrollbar-thumb {
  background-color: var(--color-text-disabled);
  border-radius: 2px;
}

.quick-response-scroll {
  display: flex;
  gap: 8px;
  padding-bottom: 6px;
}

.quick-response-btn {
  background-color: var(--color-surface-hover);
  color: var(--color-primary-main);
  border: 1px solid var(--color-primary-main);
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 0.8rem;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.quick-response-btn:hover {
  background-color: var(--color-primary-main);
  color: white;
}

/* Input area styles */
.chat-input-container {
  padding: 16px;
  border-top: 1px solid var(--color-border);
  background-color: var(--color-surface);
  z-index: 1;
  flex-shrink: 0;
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

#chat-input {
  flex: 1;
  border: 1px solid var(--color-border);
  background-color: var(--color-surface);
  resize: none;
  padding: 12px 16px;
  border-radius: 18px;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  line-height: 1.4;
  box-shadow: var(--shadow-sm);
  min-height: 24px;
  font-size: 0.95rem;
}

#chat-input:focus {
  outline: none;
  border-color: var(--color-primary-main);
  box-shadow: 0 0 0 2px rgba(var(--teal-500-rgb), 0.15);
}

[data-theme="dark"] #chat-input:focus {
  box-shadow: 0 0 0 2px rgba(var(--teal-400-rgb), 0.2);
}

#send-message {
  background-color: var(--color-primary-main);
  color: white;
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}

#send-message:hover:not(:disabled) {
  background-color: var(--color-primary-dark);
}

#send-message:disabled {
  background-color: var(--color-text-disabled);
  cursor: not-allowed;
}

/* Attachment options */
.chat-attachment-options {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.attachment-button {
  color: var(--color-text-tertiary);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.2s ease;
  display: flex;
  align-items: center;
  font-size: 0.85rem;
}

.attachment-button:hover {
  color: var(--color-primary-main);
}

.attachment-button i {
  margin-right: 4px;
}

/* Scroll to bottom button */
.scroll-to-bottom-btn {
  position: absolute;
  bottom: 90px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--color-primary-main);
  color: white;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  border: none;
  cursor: pointer;
  z-index: 5;
  transition: background-color 0.2s ease;
  animation: bounce 1s ease infinite;
}

.scroll-to-bottom-btn:hover {
  background-color: var(--color-primary-dark);
  animation: none;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* Empty states */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  color: var(--color-text-tertiary);
  text-align: center;
  height: 100%;
}

.empty-state i {
  font-size: 2rem;
  margin-bottom: 16px;
  color: var(--color-text-disabled);
}

.chat-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  background-color: var(--bg-light);
  color: var(--color-text-tertiary);
}

.empty-state-content {
  text-align: center;
  max-width: 300px;
}

.empty-state-content i {
  font-size: 3rem;
  margin-bottom: 16px;
  color: var(--color-text-disabled);
}

.empty-state-content h3 {
  margin-bottom: 8px;
  color: var(--color-text-primary);
}

/* Responsive styles */
@media (max-width: 992px) {
  .chat-sidebar {
    width: 280px;
  }
  
  .customer-vehicle-info,
  .customer-appointment-info {
    max-width: 150px;
  }
}

@media (max-width: 768px) {
  .chat-interface {
    flex-direction: column;
    height: calc(100vh - 180px);
  }
  
  .chat-sidebar {
    width: 100%;
    height: 280px;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }
  
  .chat-main {
    height: calc(100vh - 460px);
    min-height: 400px;
  }
  
  .message {
    max-width: 85%;
  }
  
  .customer-vehicle-info,
  .customer-appointment-info {
    display: none;
  }
  
  .chat-actions {
    gap: 4px;
  }
  
  .chat-action-button {
    width: 32px;
    height: 32px;
  }
}

@media (max-width: 576px) {
  .chat-interface {
    height: calc(100vh - 150px);
  }
  
  .chat-sidebar {
    height: 240px;
  }
  
  .chat-header {
    padding: 12px;
    height: 60px;
  }
  
  .conversation-avatar {
    width: 40px;
    height: 40px;
  }
  
  .chat-user-avatar {
    width: 36px;
    height: 36px;
  }
  
  .conversation-unread {
    top: 12px;
    right: 12px;
  }
  
  .chat-messages {
    padding: 12px;
  }
  
  .message {
    max-width: 90%;
  }
  
  .message-bubble {
    padding: 10px 12px;
  }
  
  .chat-input-container,
  .quick-response-container {
    padding: 12px;
  }
  
  .quick-response-btn {
    padding: 4px 8px;
    font-size: 0.7rem;
  }
  
  .scroll-to-bottom-btn {
    bottom: 80px;
    right: 16px;
    width: 36px;
    height: 36px;
  }
  
  #chat-input {
    padding: 10px 12px;
    font-size: 0.9rem;
  }
  
  #send-message {
    width: 36px;
    height: 36px;
  }
}