/**
 * Inbox Styles
 * Styles for the Facebook Messenger Inbox page
 */

/* Base styles */
* {
  font-family: 'Inter', system-ui, sans-serif;
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  letter-spacing: -0.02em;
  font-feature-settings: 'ss01' on, 'cv01' on;
}

p, span, a, li {
  letter-spacing: -0.01em;
}

/* Sidebar styles */
.sidebar-link {
  transition: all 0.2s ease;
}

.sidebar-link:hover {
  background-color: #E7F3FF;
  transform: translateX(4px);
}

.sidebar-link.active {
  background-color: #E7F3FF;
  color: #1877F2;
  border-right: 3px solid #1877F2;
}

/* Loading skeleton */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* Conversation item */
.conversation-item {
  padding: 1rem;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  transition: all 0.2s ease;
}

.conversation-item:hover {
  background-color: #f9fafb;
}

.conversation-item.active {
  background-color: #E7F3FF;
  border-left: 4px solid #1877F2;
}

.conversation-item.active:hover {
  background-color: #dbeafe;
}

/* Message bubbles */
.message-bubble {
  max-width: 70%;
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message-user {
  background-color: #f3f4f6;
  color: #1f2937;
  margin-right: auto;
  border-bottom-left-radius: 0.25rem;
}

.message-assistant {
  background-color: #1877F2;
  color: white;
  margin-left: auto;
  border-bottom-right-radius: 0.25rem;
}

/* Message footer with time and badge */
.message-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.message-time {
  font-size: 0.7rem;
  color: #9ca3af;
}

.message-assistant .message-time {
  color: rgba(255, 255, 255, 0.7);
}

/* AI/Human badges */
.msg-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 500;
}

.msg-badge-ai {
  background: #10b981;
  color: white;
}

.msg-badge-staff {
  background: #3b82f6;
  color: white;
}

/* Badge visibility on assistant messages (white on colored) */
.message-assistant .msg-badge-ai {
  background: rgba(255, 255, 255, 0.25);
  color: white;
}

.message-assistant .msg-badge-staff {
  background: rgba(255, 255, 255, 0.25);
  color: white;
}

/* Message image */
.message-image {
  max-width: 200px;
  border-radius: 0.5rem;
  margin-top: 0.5rem;
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.status-ai_handling {
  background-color: #dcfce7;
  color: #166534;
}

.status-human_handling {
  background-color: #fef3c7;
  color: #92400e;
}

.status-resolved {
  background-color: #f3f4f6;
  color: #4b5563;
}

/* Customer info section */
.customer-info-section {
  margin-bottom: 1.5rem;
}

.customer-info-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.customer-info-value {
  font-size: 0.875rem;
  color: #1f2937;
}

/* Action buttons */
.action-btn {
  width: 100%;
  padding: 0.625rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.action-btn-primary {
  background-color: #1877F2;
  color: white;
}

.action-btn-primary:hover {
  background-color: #166FE5;
}

.action-btn-secondary {
  background-color: #f3f4f6;
  color: #374151;
  border: 1px solid #e5e7eb;
}

.action-btn-secondary:hover {
  background-color: #e5e7eb;
}

.action-btn-warning {
  background-color: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

.action-btn-warning:hover {
  background-color: #fde68a;
}

.action-btn-success {
  background-color: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.action-btn-success:hover {
  background-color: #bbf7d0;
}

/* Spinner animation */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  animation: spin 1s linear infinite;
}

/* Toast animation */
@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(1rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* Height fixes for flex layout */
#chatSection, #chatContent {
  min-height: 0;
  height: 100%;
}

#messageList {
  min-height: 0;
  flex: 1 1 0;
  overflow-y: auto;
}

/* Mobile sidebar */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease-out;
  }

  .sidebar.open {
    transform: translateX(0);
  }
}

/* Mobile chat view */
@media (max-width: 767px) {
  /* Conversation list takes full width on mobile */
  #conversationList {
    position: relative;
    width: 100%;
    transition: opacity 0.2s ease-out;
  }

  /* Chat section hidden by default on mobile */
  #chatSection {
    position: absolute;
    inset: 0;
    width: 100%;
    z-index: 20;
    display: none;
  }

  /* When chat is open */
  body.chat-open #conversationList {
    display: none;
  }

  body.chat-open #chatSection {
    display: flex !important;
  }

  body.chat-open #mainHeader {
    display: none;
  }

  /* Customer info always hidden on mobile (use drawer) */
  #customerInfo {
    display: none !important;
  }
}

/* Customer drawer mobile */
#customerDrawer {
  transition: opacity 0.2s ease-out;
}

#customerDrawerContent {
  transition: transform 0.3s ease-out;
}

#customerDrawerOverlay {
  transition: opacity 0.2s ease-out;
}

body.drawer-open {
  overflow: hidden;
}

/* Scrollbar styling */
#conversationList::-webkit-scrollbar,
#messageList::-webkit-scrollbar,
#customerInfo::-webkit-scrollbar {
  width: 6px;
}

#conversationList::-webkit-scrollbar-track,
#messageList::-webkit-scrollbar-track,
#customerInfo::-webkit-scrollbar-track {
  background: transparent;
}

#conversationList::-webkit-scrollbar-thumb,
#messageList::-webkit-scrollbar-thumb,
#customerInfo::-webkit-scrollbar-thumb {
  background-color: #d1d5db;
  border-radius: 3px;
}

#conversationList::-webkit-scrollbar-thumb:hover,
#messageList::-webkit-scrollbar-thumb:hover,
#customerInfo::-webkit-scrollbar-thumb:hover {
  background-color: #9ca3af;
}

/* Message typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.75rem 1rem;
  background-color: #f3f4f6;
  border-radius: 1rem;
  width: fit-content;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background-color: #9ca3af;
  border-radius: 50%;
  animation: bounce 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes bounce {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-4px);
  }
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  text-align: center;
}

.empty-state-icon {
  width: 4rem;
  height: 4rem;
  color: #d1d5db;
  margin-bottom: 1rem;
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 500;
  color: #6b7280;
  margin-bottom: 0.5rem;
}

.empty-state-text {
  font-size: 0.875rem;
  color: #9ca3af;
}
