/**
 * Support Unicorn Widget Styles
 * Standard CSS for the embeddable chat widget
 */

/* Reset */
* {
  box-sizing: border-box;
}

/* Widget Container */
.su-widget-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: white;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Header */
.su-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background-color: #2563eb;
  color: white;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.su-widget-header-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.su-widget-header-actions {
  display: flex;
  gap: 8px;
}

.su-widget-header-button {
  padding: 8px;
  background-color: transparent;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: background-color 0.2s;
  color: white;
}

.su-widget-header-button:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

/* Messages Area */
.su-widget-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  background-color: #f9fafb;
}

.su-message {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: fadeIn 0.3s ease-out;
}

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

.su-message--outgoing {
  align-self: flex-end;
  flex-direction: row-reverse;
  margin-left: auto;
}

.su-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  background-color: #d1d5db;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  flex-shrink: 0;
}

.su-message-bubble {
  padding: 8px 16px;
  border-radius: 16px;
  word-break: break-word;
}

.su-message--incoming .su-message-bubble {
  background-color: #f3f4f6;
  color: #111827;
}

.su-message--outgoing .su-message-bubble {
  background-color: #2563eb;
  color: white;
}

.su-message-time {
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 4px;
}

.su-message-system {
  text-align: center;
  font-size: 0.75rem;
  color: #6b7280;
  padding: 8px 0;
}

/* Input Area */
.su-widget-input-area {
  border-top: 1px solid #e5e7eb;
  padding: 16px;
  background-color: white;
}

.su-widget-input-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.su-widget-input-wrapper {
  flex: 1;
  position: relative;
}

.su-widget-input {
  width: 100%;
  padding: 8px 16px;
  padding-right: 40px;
  border: 1px solid #d1d5db;
  border-radius: 9999px;
  resize: none;
  font-family: inherit;
  max-height: 120px;
  min-height: 40px;
}

.su-widget-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.su-widget-send-button {
  padding: 10px;
  background-color: #2563eb;
  color: white;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: background-color 0.2s;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.su-widget-send-button:hover:not(:disabled) {
  background-color: #1d4ed8;
}

.su-widget-send-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Welcome Screen */
.su-widget-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 0 24px;
}

.su-widget-welcome-icon {
  width: 64px;
  height: 64px;
  background-color: #dbeafe;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.su-widget-welcome-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 8px;
}

.su-widget-welcome-message {
  color: #4b5563;
  margin-bottom: 24px;
}

.su-widget-start-button {
  padding: 8px 24px;
  background-color: #2563eb;
  color: white;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.su-widget-start-button:hover {
  background-color: #1d4ed8;
}

/* Typing Indicator */
.su-typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px;
  background-color: #f3f4f6;
  border-radius: 16px;
  width: 64px;
}

.su-typing-dot {
  width: 8px;
  height: 8px;
  background-color: #9ca3af;
  border-radius: 9999px;
  animation: bounce 1.4s infinite ease-in-out both;
}

.su-typing-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.su-typing-dot:nth-child(2) {
  animation-delay: -0.16s;
}

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

/* Connection Status */
.su-connection-status {
  padding: 8px 12px;
  font-size: 0.75rem;
  text-align: center;
}

.su-connection-status--connected {
  background-color: #d1fae5;
  color: #065f46;
}

.su-connection-status--disconnected {
  background-color: #fee2e2;
  color: #991b1b;
}

.su-connection-status--connecting {
  background-color: #fef3c7;
  color: #92400e;
}

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

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

/* Scrollbar Styles */
.su-widget-messages::-webkit-scrollbar {
  width: 6px;
}

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

.su-widget-messages::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 3px;
}

.su-widget-messages::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

/* SDK Bubble and Holder Styles */
.su-widget-holder {
  position: fixed;
  z-index: 2147483647;
  bottom: 0;
}

.su-widget-holder--right {
  right: 20px;
}

.su-widget-holder--left {
  left: 20px;
}

.su-bubble-holder {
  position: fixed;
  bottom: 20px;
  z-index: 2147483647;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.su-bubble-holder--right {
  right: 20px;
}

.su-bubble-holder--left {
  left: 20px;
}

.su-bubble-holder--hidden {
  opacity: 0;
  transform: scale(0);
  pointer-events: none;
}

.su-bubble-button {
  width: 56px;
  height: 56px;
  border-radius: 9999px;
  background-color: #2563eb;
  color: white;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.su-bubble-button:hover {
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  transform: scale(1.1);
}

.su-bubble-button:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3), 0 0 0 6px rgba(37, 99, 235, 0.1);
}

.su-widget-iframe {
  transition: opacity 0.3s ease, transform 0.3s ease;
  background-color: white;
}

.su-widget-iframe--closed {
  opacity: 0;
  transform: scale(0.95);
}

.su-widget-iframe--open {
  opacity: 1;
  transform: scale(1);
}

.su-hidden {
  display: none !important;
}

/* Utility Classes */
.su-loading {
  opacity: 0.6;
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Helper utility classes */
.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.justify-center {
  justify-content: center;
}

.gap-3 {
  gap: 12px;
}

.w-8 {
  width: 32px;
}

.h-8 {
  height: 32px;
}

.bg-white\/20 {
  background-color: rgba(255, 255, 255, 0.2);
}

.rounded-full {
  border-radius: 9999px;
}

.text-xs {
  font-size: 0.75rem;
}

.opacity-90 {
  opacity: 0.9;
}

/* Mobile Responsive Styles */
@media (max-width: 767px) {
  /* Make widget container fill entire viewport on mobile */
  .su-widget-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  /* Adjust header for mobile */
  .su-widget-header {
    padding: 16px;
  }

  .su-widget-header-title {
    font-size: 1rem;
  }

  /* Messages area - reduce padding on mobile */
  .su-widget-messages {
    padding: 12px;
  }

  /* Message bubbles - allow more width on mobile */
  .su-message {
    max-width: 90%;
  }

  /* Reduce avatar size slightly on mobile */
  .su-message-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
  }

  /* Input area adjustments */
  .su-widget-input-area {
    padding: 12px;
  }

  .su-widget-input {
    font-size: 16px; /* Prevents zoom on iOS */
  }

  /* Welcome screen adjustments */
  .su-widget-welcome {
    padding: 0 16px;
  }

  .su-widget-welcome-icon {
    width: 56px;
    height: 56px;
  }

  .su-widget-welcome-title {
    font-size: 1.125rem;
  }

  .su-widget-welcome-message {
    font-size: 0.9375rem;
  }

  /* Adjust utility classes for mobile */
  .gap-3 {
    gap: 8px;
  }

  .w-8 {
    width: 28px;
  }

  .h-8 {
    height: 28px;
  }
}
