/* Adrift Chat Widget Styles */
:root {
  --adrift-primary: #ff6b35;
  --adrift-primary-dark: #e55a2b;
  --adrift-secondary: #424242;
  --adrift-background: #ffffff;
  --adrift-surface: #f5f5f5;
  --adrift-text: #333333;
  --adrift-text-light: #666666;
  --adrift-border: #e0e0e0;
  --adrift-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  --adrift-shadow-light: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Widget Container */
.adrift-chat-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2147483647; /* Maximum z-index */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--adrift-text);
  box-sizing: border-box;
}

.adrift-chat-widget *,
.adrift-chat-widget *::before,
.adrift-chat-widget *::after {
  box-sizing: border-box;
}

/* Chat Button */
.adrift-chat-button {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--adrift-primary), var(--adrift-primary-dark));
  border: none;
  cursor: pointer;
  box-shadow: var(--adrift-shadow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.adrift-chat-button:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
}

.adrift-chat-button:active {
  transform: scale(0.95);
}

.adrift-chat-button.open {
  background: var(--adrift-secondary);
}

/* Chat Button Icon */
.adrift-chat-icon {
  width: 42px;
  height: 42px;
  fill: white;
  transition: opacity 0.3s ease;
}

.adrift-chat-icon.hidden {
  opacity: 0;
}

/* Notification Badge */
.adrift-notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: #ff4444;
  border-radius: 50%;
  color: white;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(0);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.adrift-notification-badge.show {
  transform: scale(1);
}

/* Chat Window */
.adrift-chat-window {
  position: absolute;
  bottom: 110px;
  right: 0;
  width: 456px;
  height: 600px;
  max-height: calc(100vh - 120px);
  background: var(--adrift-background);
  border-radius: 12px;
  box-shadow: var(--adrift-shadow);
  border: 1px solid var(--adrift-border);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  overflow: hidden;
  box-sizing: border-box;
}

.adrift-chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .adrift-chat-widget {
    bottom: 10px;
    right: 10px;
  }
  
  .adrift-chat-window {
    width: calc(100vw - 20px);
    height: calc(100vh - 100px);
    bottom: 110px;
    right: -10px;
  }
}

/* Tablet adjustments for new width */
@media (max-width: 520px) and (min-width: 481px) {
  .adrift-chat-window {
    width: calc(100vw - 40px);
    right: -20px;
  }
}

/* Chat Header */
.adrift-chat-header {
  background: linear-gradient(135deg, var(--adrift-primary), var(--adrift-primary-dark));
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 12px 12px 0 0;
}

.adrift-chat-header-info h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.adrift-chat-header-info p {
  margin: 2px 0 0 0;
  font-size: 12px;
  opacity: 0.9;
}

.adrift-chat-close {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.adrift-chat-close:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.adrift-chat-close svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Chat Messages Area */
.adrift-chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  background: var(--adrift-surface);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.adrift-chat-messages::-webkit-scrollbar {
  width: 6px;
}

.adrift-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.adrift-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

/* Welcome Message */
.adrift-welcome-message {
  text-align: center;
  padding: 40px 20px;
  color: var(--adrift-text-light);
}

.adrift-welcome-message h4 {
  margin: 0 0 12px 0;
  color: var(--adrift-primary);
  font-size: 18px;
  font-weight: 600;
}

.adrift-welcome-message p {
  margin: 0 0 8px 0;
  font-size: 14px;
  line-height: 1.5;
}

.adrift-welcome-message .subtitle {
  font-size: 13px;
  opacity: 0.8;
}

/* Message Bubble */
.adrift-message {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: messageSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.adrift-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.adrift-message.assistant {
  align-self: flex-start;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Avatar */
.adrift-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 600;
}

.adrift-avatar.user {
  background: var(--adrift-primary);
  color: white;
}

.adrift-avatar.assistant {
  background: var(--adrift-secondary);
  color: white;
}

/* Message Content */
.adrift-message-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
}

.adrift-message-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  word-wrap: break-word;
  white-space: pre-wrap;
  position: relative;
  max-width: 100%;
  overflow-wrap: break-word;
  box-sizing: border-box;
}

.adrift-message.user .adrift-message-bubble {
  background: var(--adrift-primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.adrift-message.assistant .adrift-message-bubble {
  background: white;
  color: var(--adrift-text);
  border: 1px solid var(--adrift-border);
  border-bottom-left-radius: 4px;
}

.adrift-message-time {
  font-size: 11px;
  color: var(--adrift-text-light);
  opacity: 0.7;
  margin-top: 2px;
}

.adrift-message.user .adrift-message-time {
  text-align: right;
}

/* Typing Indicator */
.adrift-typing-indicator {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px 0;
}

.adrift-typing-dots {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: white;
  border: 1px solid var(--adrift-border);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
}

.adrift-typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--adrift-text-light);
  animation: typingBounce 1.4s infinite ease-in-out;
}

.adrift-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.adrift-typing-dot:nth-child(2) { animation-delay: -0.16s; }
.adrift-typing-dot:nth-child(3) { animation-delay: 0s; }

@keyframes typingBounce {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Chat Input */
.adrift-chat-input {
  padding: 16px 20px;
  background: var(--adrift-background);
  border-top: 1px solid var(--adrift-border);
  border-radius: 0 0 12px 12px;
}

.adrift-input-container {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 0;
}

.adrift-input-wrapper {
  flex: 1;
  position: relative;
}

.adrift-input {
  width: 100%;
  min-height: 40px;
  max-height: 120px;
  padding: 10px 12px;
  border: 2px solid var(--adrift-border);
  border-radius: 20px;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  transition: border-color 0.2s ease;
  background: var(--adrift-background);
  overflow-y: hidden;
  overflow-x: hidden;
  margin: 0;
}

.adrift-input::placeholder {
  color: var(--adrift-text-light);
}

.adrift-send-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--adrift-primary);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  margin-top: 0;
  position: relative;
}

.adrift-send-button:hover:not(:disabled) {
  background: var(--adrift-primary-dark);
  transform: scale(1.05);
}

.adrift-send-button:disabled {
  background: var(--adrift-border);
  cursor: not-allowed;
}

.adrift-send-button svg {
  width: 18px !important;
  height: 18px !important;
  fill: white !important;
  display: block !important;
  margin: 0 auto !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Ensure no other content interferes with the SVG */
.adrift-send-button::before,
.adrift-send-button::after {
  display: none !important;
  content: none !important;
}

/* Force the button to show only the SVG */
.adrift-send-button {
  background: var(--adrift-primary) !important;
  color: white !important;
  font-size: 0 !important; /* Hide any text content */
}

.adrift-send-button svg path {
  fill: white !important;
  stroke: none !important;
}

/* Loading Spinner */
.adrift-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Error Message */
.adrift-error-message {
  padding: 12px 16px;
  background: #ffebee;
  border: 1px solid #ffcdd2;
  border-radius: 8px;
  color: #c62828;
  font-size: 13px;
  margin: 16px 20px 0;
}

/* Action Buttons */
.adrift-action-buttons {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(0, 0, 0, 0.02);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

@media (min-width: 480px) {
    .adrift-action-buttons {
        flex-direction: column;
        flex-wrap: nowrap;
    }
}

.adrift-action-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border: 2px solid var(--adrift-primary);
    border-radius: 12px;
    background: var(--adrift-primary);
    color: white;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    text-decoration: none;
    min-width: 0;
    flex: 1;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.2);
    max-width: 100%;
    word-wrap: break-word;
    overflow: hidden;
}

@media (min-width: 480px) {
    .adrift-action-button {
        flex: 1;
        min-width: 0;
        max-width: 100%;
    }
}

.adrift-action-button:hover {
    background: var(--adrift-primary-dark);
    border-color: var(--adrift-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(25, 118, 210, 0.3);
}

.adrift-action-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.2);
}

/* Secondary button style */
.adrift-action-secondary {
    background: transparent;
    color: var(--adrift-primary);
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.1);
}

.adrift-action-secondary:hover {
    background: var(--adrift-primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(25, 118, 210, 0.2);
}

/* Outline button style */
.adrift-action-outline {
    background: transparent;
    color: var(--adrift-primary);
    border: 2px solid var(--adrift-border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.adrift-action-outline:hover {
    background: var(--adrift-primary);
    border-color: var(--adrift-primary);
    color: white;
}

/* Action button icons */
.adrift-action-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.adrift-action-label {
    flex: 1;
    text-align: center;
    white-space: normal;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    line-height: 1.3;
}

/* Specific button type styles */
.adrift-action-book {
    background: #2e7d32;
    border-color: #2e7d32;
    box-shadow: 0 2px 8px rgba(46, 125, 50, 0.2);
}

.adrift-action-book:hover {
    background: #1b5e20;
    border-color: #1b5e20;
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.3);
}

.adrift-action-call {
    background: #ff6b35;
    border-color: #ff6b35;
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.2);
}

.adrift-action-call:hover {
    background: #e55a2b;
    border-color: #e55a2b;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

.adrift-action-email {
    background: #1976d2;
    border-color: #1976d2;
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.2);
}

.adrift-action-email:hover {
    background: #115293;
    border-color: #115293;
    box-shadow: 0 4px 12px rgba(25, 118, 210, 0.3);
}

/* Disabled state */
.adrift-action-button:disabled {
    background: var(--adrift-border);
    border-color: var(--adrift-border);
    color: var(--adrift-text-light);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.adrift-action-button:disabled:hover {
    background: var(--adrift-border);
    border-color: var(--adrift-border);
    transform: none;
    box-shadow: none;
}

/* Powered By */
.adrift-powered-by {
    padding: 8px 20px;
    text-align: center;
    font-size: 11px;
    color: var(--adrift-text-light);
    background: var(--adrift-background);
    border-top: 1px solid var(--adrift-border);
}

.adrift-powered-by a {
    color: var(--adrift-primary);
    text-decoration: none;
}

.adrift-powered-by a:hover {
    text-decoration: underline;
}

/* Accessibility */
.adrift-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus styles */
.adrift-chat-button:focus,
.adrift-chat-close:focus,
.adrift-send-button:focus {
  outline: 2px solid var(--adrift-primary);
  outline-offset: 2px;
}

.adrift-input:focus {
  outline: none;
  border-color: var(--adrift-primary);
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --adrift-border: #000000;
    --adrift-text-light: #000000;
  }
  
  .adrift-message.assistant .adrift-message-bubble {
    border-width: 2px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .adrift-chat-button,
  .adrift-chat-window,
  .adrift-message,
  .adrift-send-button {
    transition: none;
  }
  
  .adrift-typing-dot {
    animation: none;
  }
  
  .adrift-spinner {
    animation: none;
  }
}
