/* ============================================
   CUSTOMER CHAT MODAL - MOBILE FIRST
   Optimized for Latin American Market
   ============================================ */

/* ===== BASE MOBILE STYLES (320px+) ===== */

#customerChatModal.modal {
  align-items: flex-end;
  padding: 0;
}

#customerChatModal.modal.show,
#customerChatModal.modal[style*="display: flex"],
#customerChatModal.modal[style*="display: block"] {
  display: flex !important;
}

.chat-modal-container {
  width: 100%;
  max-width: 100%;
  height: 100vh;
  background: #fff;
  display: flex;
  flex-direction: column;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  animation: slideUpModal 0.3s ease;
}

@keyframes slideUpModal {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Modal Header */
.chat-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(135deg, #E9232F 0%, #c91828 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.chat-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-modal-header h3 i {
  font-size: 20px;
}

.chat-modal-header .close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: none;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.chat-modal-header .close:active {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0.95);
}

/* Modal Body */
.chat-modal-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f5f5f5;
}

/* Customer Info Bar */
.chat-customer-info-bar {
  background: #fff;
  padding: 16px 20px;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.customer-info-display {
  display: flex;
  align-items: center;
  gap: 12px;
}

.customer-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
  flex-shrink: 0;
}

.customer-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-customer-name {
  font-size: 16px;
  font-weight: 700;
  color: #2c3e50;
}

.customer-order-info {
  font-size: 13px;
  color: #7f8c8d;
}

.customer-status {
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.customer-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #95a5a6;
}

.customer-status.online::before {
  background: #2ecc71;
  box-shadow: 0 0 8px rgba(46, 204, 113, 0.5);
}

.customer-status.online {
  color: #27ae60;
}

/* Chat Messages Container */
.chat-messages-container {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 20px;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

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

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

.seller-message {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 20px;
}

.customer-message .message-avatar {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}

.seller-message .message-avatar {
  background: linear-gradient(135deg, #E9232F 0%, #c91828 100%);
  color: #fff;
}

.message-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.message-text {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.5;
  word-wrap: break-word;
}

.customer-message .message-text {
  background: #fff;
  color: #2c3e50;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.seller-message .message-text {
  background: linear-gradient(135deg, #E9232F 0%, #ff4757 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  text-align: right;
}

.message-time {
  font-size: 11px;
  color: #95a5a6;
  padding: 0 6px;
}

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

/* Chat Input Container */
.chat-input-container {
  background: #fff;
  border-top: 1px solid #e0e0e0;
  padding: 12px 16px;
  flex-shrink: 0;
}

.chat-input-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-input-area textarea {
  width: 100%;
  min-height: 44px;
  max-height: 120px;
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 24px;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  transition: all 0.3s ease;
  line-height: 1.5;
}

.chat-input-area textarea:focus {
  outline: none;
  border-color: #E9232F;
  box-shadow: 0 0 0 3px rgba(233, 35, 47, 0.1);
}

.chat-input-area textarea::placeholder {
  color: #bdc3c7;
}

.chat-input-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

.attach-btn,
.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.attach-btn {
  background: #f5f5f5;
  color: #7f8c8d;
}

.attach-btn:active {
  background: #e0e0e0;
  transform: scale(0.95);
}

.send-btn {
  background: linear-gradient(135deg, #E9232F 0%, #c91828 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(233, 35, 47, 0.3);
}

.send-btn:active {
  transform: scale(0.95);
  box-shadow: 0 1px 4px rgba(233, 35, 47, 0.3);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #fff;
  border-radius: 18px;
  max-width: 80px;
  align-self: flex-start;
  margin-left: 48px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #95a5a6;
  animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Scrollbar Styling */
.chat-messages-container::-webkit-scrollbar {
  width: 6px;
}

.chat-messages-container::-webkit-scrollbar-track {
  background: #f5f5f5;
}

.chat-messages-container::-webkit-scrollbar-thumb {
  background: #bdc3c7;
  border-radius: 3px;
}

.chat-messages-container::-webkit-scrollbar-thumb:hover {
  background: #95a5a6;
}

/* ===== TABLET STYLES (768px+) ===== */
@media (min-width: 768px) {
  #customerChatModal.modal {
    align-items: center;
    justify-content: center;
    padding: 20px;
  }

  .chat-modal-container {
    max-width: 600px;
    height: 80vh;
    max-height: 700px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: scaleUpModal 0.3s ease;
  }

  @keyframes scaleUpModal {
    from {
      transform: scale(0.9);
      opacity: 0;
    }
    to {
      transform: scale(1);
      opacity: 1;
    }
  }

  .chat-modal-header {
    border-radius: 16px 16px 0 0;
    padding: 20px 24px;
  }

  .chat-modal-header h3 {
    font-size: 20px;
  }

  .chat-customer-info-bar {
    padding: 20px 24px;
  }

  .chat-messages-container {
    padding: 20px 24px;
  }

  .message {
    max-width: 70%;
  }

  .chat-input-container {
    padding: 16px 24px;
    border-radius: 0 0 16px 16px;
  }
}

/* ===== DESKTOP STYLES (1024px+) ===== */
@media (min-width: 1024px) {
  .chat-modal-container {
    max-width: 700px;
    height: 85vh;
    max-height: 800px;
  }

  .message {
    max-width: 60%;
  }

  .message-text {
    font-size: 16px;
  }

  .chat-input-area textarea {
    font-size: 16px;
  }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Touch-friendly tap highlights */
* {
  -webkit-tap-highlight-color: rgba(233, 35, 47, 0.1);
}

/* Dark mode support (if needed) */
@media (prefers-color-scheme: dark) {
  .chat-modal-container {
    background: #1a1a1a;
  }

  .chat-modal-body {
    background: #2c2c2c;
  }

  .chat-customer-info-bar {
    background: #1a1a1a;
    border-bottom-color: #404040;
  }

  .chat-customer-name {
    color: #fff;
  }

  .customer-order-info {
    color: #bdc3c7;
  }

  .customer-message .message-text {
    background: #3a3a3a;
    color: #fff;
  }

  .chat-input-container {
    background: #1a1a1a;
    border-top-color: #404040;
  }

  .chat-input-area textarea {
    background: #2c2c2c;
    border-color: #404040;
    color: #fff;
  }

  .attach-btn {
    background: #3a3a3a;
    color: #bdc3c7;
  }

  .typing-indicator {
    background: #3a3a3a;
  }
}
