/**
 * Bird Chat Custom UI Styles
 */

.bird-chat-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 380px;
  height: 600px;
  max-height: 80vh;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.bird-chat-container.active {
  display: flex;
  animation: slideUp 0.3s ease-out;
}

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

/* Header */
.bird-chat-header {
  background: linear-gradient(135deg, #448AFF 0%, #2979FF 100%);
  color: white;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.bird-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bird-chat-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.bird-chat-status {
  margin: 4px 0 0;
  font-size: 13px;
  opacity: 0.9;
}

.bird-chat-close,
.bird-chat-history-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background-color 0.2s;
}

.bird-chat-close:hover,
.bird-chat-history-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

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

/* Messages Area */
.bird-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f5f7fa;
  display: none;
}

.bird-chat-messages.active {
  display: flex;
  flex-direction: column;
}

.bird-chat-welcome {
  text-align: center;
  padding: 40px 20px;
  color: #64748b;
}

.bird-chat-welcome p {
  margin: 0;
  font-size: 16px;
}

/* Messages */
.bird-chat-message {
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  animation: fadeIn 0.3s ease-out;
}

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

.bird-chat-message-user {
  justify-content: flex-end;
}

.bird-chat-message-agent {
  justify-content: flex-start;
}

/* Message content - user messages */
.bird-chat-message-user .bird-chat-message-content {
  background: #448AFF;
  color: white;
  padding: 10px 14px;
  border-radius: 18px 18px 4px 18px;
  max-width: 280px;
  margin-left: 60px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
}

/* Message content - agent messages */
.bird-chat-message-agent .bird-chat-message-content {
  background: white;
  color: #1e293b;
  padding: 10px 14px;
  border-radius: 18px 18px 18px 4px;
  max-width: 280px;
  margin-right: 60px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  border: 1px solid #e2e8f0;
}

/* Remove avatar styling - we'll use a simpler approach */
.bird-chat-avatar {
  display: none;
}

/* Message wrapper is not needed */
.bird-chat-message-wrapper {
  display: contents;
}

/* Time stamp */
.bird-chat-message-time {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 2px;
  padding: 0 14px;
  display: block;
}

.bird-chat-message-user .bird-chat-message-time {
  text-align: right;
  margin-right: 60px;
}

.bird-chat-message-agent .bird-chat-message-time {
  text-align: left;
  margin-left: 0;
}

/* Agent Info Display */
.bird-chat-agent-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding-left: 4px;
}

/* Adjust agent messages with info */
.bird-chat-message-agent:has(.bird-chat-agent-info) {
  flex-direction: column;
  align-items: flex-start;
}

.bird-chat-agent-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.bird-chat-agent-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bird-chat-agent-initial {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  border-radius: 50%;
  text-transform: uppercase;
}

.bird-chat-agent-name {
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* Auto-response styling */
.bird-chat-message[data-message-id^="auto_"] .bird-chat-message-content {
  background: #f0f4f8;
  border: 1px solid #e2e8f0;
  font-style: italic;
}

.bird-chat-message[data-message-id^="auto_"] .bird-chat-agent-initial {
  background: #94a3b8;
}

/* Error Messages */
.bird-chat-error {
  background: #fee;
  border: 1px solid #fcc;
  color: #c33;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}

.bird-chat-error p {
  margin: 0;
}

/* Input Area */
.bird-chat-input-container {
  background: white;
  border-top: 1px solid #e2e8f0;
  padding: 16px;
  flex-shrink: 0;
  display: none;
}

.bird-chat-input-container.active {
  display: block;
}

.bird-chat-form {
  margin: 0;
}

.bird-chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 24px;
  padding: 4px 4px 4px 16px;
  transition: border-color 0.2s;
}

.bird-chat-input-wrapper:focus-within {
  border-color: #448AFF;
}

.bird-chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 14px;
  line-height: 1.5;
  padding: 8px 0;
  resize: none;
  min-height: 36px;
  max-height: 120px;
  font-family: inherit;
}

.bird-chat-input::placeholder {
  color: #94a3b8;
}

.bird-chat-send {
  background: #448AFF;
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.2s;
  flex-shrink: 0;
}

.bird-chat-send:hover {
  background: #2979FF;
}

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

.bird-chat-send:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

.bird-chat-powered {
  text-align: center;
  padding: 8px;
  font-size: 11px;
  color: #94a3b8;
  background: white;
  border-top: 1px solid #e2e8f0;
  flex-shrink: 0;
  display: none;
}

.bird-chat-powered a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s;
}

.bird-chat-powered a:hover {
  color: #448AFF;
  text-decoration: underline;
}

.bird-chat-powered.active {
  display: block;
}

/* Settings Panel */
.bird-chat-settings {
  padding: 20px;
  background: #fff;
}

.bird-chat-settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.bird-chat-settings-header h4 {
  margin: 0;
  font-size: 16px;
  color: #333;
}

.bird-chat-settings-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #999;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bird-chat-settings-close:hover {
  color: #666;
}

.bird-chat-setting-item {
  margin-bottom: 20px;
}

.bird-chat-toggle {
  display: flex;
  align-items: center;
  cursor: pointer;
  position: relative;
}

.bird-chat-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
}

.bird-chat-toggle-slider {
  width: 44px;
  height: 24px;
  background: #ddd;
  border-radius: 12px;
  position: relative;
  transition: background 0.3s;
  margin-right: 12px;
}

.bird-chat-toggle-slider::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.3s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.bird-chat-toggle input:checked + .bird-chat-toggle-slider {
  background: #2196F3;
}

.bird-chat-toggle input:checked + .bird-chat-toggle-slider::after {
  transform: translateX(20px);
}

.bird-chat-toggle-label {
  font-size: 14px;
  color: #333;
}

.bird-chat-setting-description {
  font-size: 12px;
  color: #666;
  margin-top: 5px;
  margin-left: 56px;
}

.bird-chat-volume-slider {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #ddd;
  outline: none;
  opacity: 0.7;
  transition: opacity 0.2s;
  margin-top: 10px;
}

.bird-chat-volume-slider:hover {
  opacity: 1;
}

.bird-chat-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: #2196F3;
  cursor: pointer;
  border-radius: 50%;
}

.bird-chat-volume-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #2196F3;
  cursor: pointer;
  border-radius: 50%;
  border: none;
}

.bird-chat-test-notification {
  background: #2196F3;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.3s;
  width: 100%;
}

.bird-chat-test-notification:hover {
  background: #1976D2;
}

/* Settings button in header */
.bird-chat-settings-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background-color 0.2s;
}

.bird-chat-settings-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

/* Offline indicator */
.bird-chat-offline-indicator {
  position: sticky;
  top: 0;
  z-index: 10;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .bird-chat-container {
    width: 100%;
    height: 100%;
    max-height: 100%;
    bottom: 0;
    right: 0;
    border-radius: 0;
  }
  
  .bird-chat-header {
    border-radius: 0;
  }
  
  .bird-chat-message-user .bird-chat-message-content,
  .bird-chat-message-agent .bird-chat-message-content {
    max-width: 85%;
    margin-left: 20px;
    margin-right: 20px;
  }
  
  .bird-chat-message-user .bird-chat-message-time {
    margin-right: 20px;
  }
}

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

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

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

.bird-chat-messages::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Loading State */
.bird-chat-loading {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: white;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  width: fit-content;
}

.bird-chat-loading span {
  width: 8px;
  height: 8px;
  background: #94a3b8;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.bird-chat-loading span:nth-child(1) {
  animation-delay: -0.32s;
}

.bird-chat-loading span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/* Contact Form */
.bird-chat-contact-form {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f5f7fa;
  display: none;
}

.bird-chat-contact-form.active {
  display: flex;
  flex-direction: column;
}

.bird-chat-form-content {
  max-width: 320px;
  margin: 0 auto;
}

.bird-chat-form-header {
  text-align: center;
  margin-bottom: 24px;
}

.bird-chat-form-badge {
  display: inline-block;
  background: #e0f2fe;
  color: #0369a1;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.bird-chat-form-header h4 {
  margin: 0;
  font-size: 18px;
  color: #1e293b;
  font-weight: 600;
}

.bird-chat-form-group {
  margin-bottom: 20px;
}

.bird-chat-form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #475569;
}

.bird-chat-form-group input,
.bird-chat-form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  background: white;
  transition: border-color 0.2s;
  outline: none;
}

.bird-chat-form-group input:focus,
.bird-chat-form-group select:focus {
  border-color: #448AFF;
}

.bird-chat-phone-group {
  display: flex;
  gap: 8px;
}

.bird-chat-phone-group select {
  width: 90px;
  flex-shrink: 0;
  background: #f0f4f8;
  cursor: not-allowed;
}

.bird-chat-submit {
  width: 100%;
  padding: 12px 20px;
  background: #448AFF;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

.bird-chat-submit:hover {
  background: #2979FF;
}

.bird-chat-form-note {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: #64748b;
}

/* Message states */
.bird-chat-message-sending .bird-chat-message-content {
  opacity: 0.7;
  position: relative;
}

.bird-chat-message-sending .bird-chat-message-content::after {
  content: '...';
  position: absolute;
  bottom: 2px;
  right: 10px;
  font-size: 16px;
  color: rgba(255, 255, 255, 0.8);
  animation: sending-dots 1.4s infinite;
}

@keyframes sending-dots {
  0%, 20% {
    content: '.';
  }
  40% {
    content: '..';
  }
  60%, 100% {
    content: '...';
  }
}

.bird-chat-message-failed .bird-chat-message-content {
  background: #ff5252 !important;
  position: relative;
}

.bird-chat-message-failed .bird-chat-message-content::before {
  content: '⚠';
  position: absolute;
  top: 50%;
  right: -25px;
  transform: translateY(-50%);
  color: #ff5252;
  font-size: 16px;
}

/* Delivery status indicators */
.bird-chat-delivery-status {
  margin-left: 6px;
  font-size: 12px;
  display: inline-block;
  vertical-align: middle;
}

.bird-chat-delivery-status[data-status="sending"] {
  color: #94a3b8;
}

.bird-chat-delivery-status[data-status="sent"],
.bird-chat-delivery-status[data-status="delivered"] {
  color: #64748b;
}

.bird-chat-delivery-status[data-status="failed"] {
  color: #ff5252;
}

/* Typing indicator animation */
.bird-chat-typing-indicator {
  margin-bottom: 16px;
}

/* Conversation History */
.bird-chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f5f7fa;
  display: none;
}

.bird-chat-history.active {
  display: flex;
  flex-direction: column;
}

.bird-chat-history-header {
  margin-bottom: 20px;
}

.bird-chat-history-header h4 {
  margin: 0 0 16px 0;
  font-size: 18px;
  color: #1e293b;
  font-weight: 600;
}

.bird-chat-history-actions {
  display: flex;
  gap: 12px;
}

.bird-chat-back-btn,
.bird-chat-new-conversation {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.bird-chat-back-btn {
  background: #e2e8f0;
  color: #475569;
}

.bird-chat-back-btn:hover {
  background: #cbd5e1;
}

.bird-chat-new-conversation {
  background: #448AFF;
  color: white;
}

.bird-chat-new-conversation:hover {
  background: #2979FF;
}

.bird-chat-history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bird-chat-history-item {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.bird-chat-history-item:hover {
  border-color: #448AFF;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.bird-chat-history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 8px;
}

.bird-chat-history-item-name {
  font-weight: 500;
  color: #1e293b;
  font-size: 15px;
}

.bird-chat-history-item-date {
  font-size: 12px;
  color: #64748b;
}

.bird-chat-history-item-status {
  font-size: 13px;
  color: #64748b;
}

/* Loading State */
.bird-chat-loading {
  display: flex;
  justify-content: center;
  padding: 20px;
}

.bird-chat-loading-dots {
  display: flex;
  gap: 8px;
}

.bird-chat-loading-dots span {
  width: 12px;
  height: 12px;
  background: #448AFF;
  border-radius: 50%;
  animation: loadingDot 1.4s infinite ease-in-out both;
}

.bird-chat-loading-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.bird-chat-loading-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes loadingDot {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.bird-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bird-chat-input:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
}