/**
 * Florida Lanai Curtains - Chat Widget Styles
 *
 * A responsive, accessible chat widget with smooth animations.
 * Works with the chat-widget.js component.
 */

/* ============================================
   CSS VARIABLES
   ============================================ */

.flc-chat-widget {
  /* Colors - FLC Brand */
  --flc-primary: #C41E7A;           /* Magenta/Pink */
  --flc-primary-dark: #A01860;      /* Darker magenta */
  --flc-primary-light: #D93A8E;     /* Lighter magenta */
  --flc-secondary: #F7B733;         /* Golden yellow */
  --flc-secondary-dark: #E5A520;    /* Darker gold */
  --flc-accent: #F26A4B;            /* Coral/salmon */
  --flc-gradient-start: #C41E7A;    /* Magenta */
  --flc-gradient-end: #F7B733;      /* Golden yellow */

  /* Neutrals */
  --flc-white: #ffffff;
  --flc-gray-50: #faf8f9;           /* Slightly warm */
  --flc-gray-100: #f5f3f4;
  --flc-gray-200: #e5e7eb;
  --flc-gray-300: #d1d5db;
  --flc-gray-400: #9ca3af;
  --flc-gray-500: #6b7280;
  --flc-gray-600: #4b5563;
  --flc-gray-700: #374151;
  --flc-gray-800: #1f2937;
  --flc-gray-900: #111827;

  /* Shadows */
  --flc-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --flc-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --flc-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --flc-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Typography */
  --flc-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --flc-font-size-xs: 0.75rem;
  --flc-font-size-sm: 0.875rem;
  --flc-font-size-base: 1rem;

  /* Spacing */
  --flc-spacing-xs: 0.25rem;
  --flc-spacing-sm: 0.5rem;
  --flc-spacing-md: 1rem;
  --flc-spacing-lg: 1.5rem;

  /* Borders */
  --flc-radius-sm: 0.375rem;
  --flc-radius-md: 0.5rem;
  --flc-radius-lg: 0.75rem;
  --flc-radius-xl: 1rem;
  --flc-radius-full: 9999px;

  /* Transitions */
  --flc-transition-fast: 150ms ease;
  --flc-transition-normal: 300ms ease;

  /* Z-index */
  --flc-z-widget: 9999;
}

/* ============================================
   WIDGET CONTAINER
   ============================================ */

.flc-chat-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: var(--flc-z-widget);
  font-family: var(--flc-font-family);
  font-size: var(--flc-font-size-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Adjust position on mobile */
@media (max-width: 480px) {
  .flc-chat-widget {
    bottom: 80px; /* Above mobile CTA bar */
    right: 10px;
  }
}

/* ============================================
   TOGGLE BUTTON
   ============================================ */

.flc-chat-toggle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border: none;
  border-radius: var(--flc-radius-full);
  background: linear-gradient(135deg, var(--flc-gradient-start) 0%, var(--flc-accent) 50%, var(--flc-gradient-end) 100%);
  color: var(--flc-white);
  cursor: pointer;
  box-shadow: var(--flc-shadow-lg);
  transition: transform var(--flc-transition-fast), box-shadow var(--flc-transition-fast);
}

.flc-chat-toggle:hover {
  transform: scale(1.05);
  box-shadow: var(--flc-shadow-xl);
}

.flc-chat-toggle:focus {
  outline: none;
  box-shadow: var(--flc-shadow-xl), 0 0 0 3px rgba(196, 30, 122, 0.3);
}

.flc-chat-toggle:active {
  transform: scale(0.98);
}

.flc-chat-toggle-icon,
.flc-chat-toggle-close {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--flc-transition-fast), transform var(--flc-transition-fast);
}

.flc-chat-toggle-close {
  opacity: 0;
  transform: rotate(-90deg);
}

.flc-chat-widget.is-open .flc-chat-toggle-icon {
  opacity: 0;
  transform: rotate(90deg);
}

.flc-chat-widget.is-open .flc-chat-toggle-close {
  opacity: 1;
  transform: rotate(0);
}

/* Notification badge */
.flc-chat-notification {
  position: absolute;
  top: -4px;
  right: -4px;
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--flc-accent);
  color: var(--flc-white);
  font-size: var(--flc-font-size-xs);
  font-weight: 600;
  border-radius: var(--flc-radius-full);
  animation: flc-bounce 0.5s ease infinite;
}

@keyframes flc-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

/* ============================================
   ATTENTION BUBBLE
   ============================================ */

.flc-chat-attention-bubble {
  position: absolute;
  bottom: 70px;
  right: 0;
  display: flex;
  align-items: center;
  gap: var(--flc-spacing-sm);
  padding: var(--flc-spacing-sm) var(--flc-spacing-md);
  background: var(--flc-white);
  color: var(--flc-gray-800);
  border-radius: var(--flc-radius-lg);
  box-shadow: var(--flc-shadow-lg);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.9);
  transform-origin: bottom right;
  transition: opacity var(--flc-transition-normal),
              visibility var(--flc-transition-normal),
              transform var(--flc-transition-normal);
  z-index: 1;
}

.flc-chat-attention-bubble.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  animation: flc-attention-float 3s ease-in-out infinite;
}

.flc-chat-attention-bubble::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 20px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid var(--flc-white);
}

@keyframes flc-attention-float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-5px) scale(1); }
}

.flc-chat-attention-text {
  font-size: var(--flc-font-size-sm);
  font-weight: 600;
  color: var(--flc-primary);
}

.flc-chat-attention-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: var(--flc-gray-100);
  color: var(--flc-gray-500);
  font-size: 14px;
  line-height: 1;
  border-radius: var(--flc-radius-full);
  cursor: pointer;
  transition: background var(--flc-transition-fast), color var(--flc-transition-fast);
}

.flc-chat-attention-close:hover {
  background: var(--flc-gray-200);
  color: var(--flc-gray-700);
}

/* Hide attention bubble when chat is open */
.flc-chat-widget.is-open .flc-chat-attention-bubble {
  opacity: 0 !important;
  visibility: hidden !important;
}

/* Mobile adjustments for attention bubble */
@media (max-width: 480px) {
  .flc-chat-attention-bubble {
    right: 0;
    bottom: 70px;
    font-size: var(--flc-font-size-xs);
  }
}

/* ============================================
   CHAT WINDOW
   ============================================ */

.flc-chat-window {
  position: absolute;
  bottom: 75px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 140px);
  min-height: 450px;
  display: flex;
  flex-direction: column;
  background: var(--flc-white);
  border-radius: var(--flc-radius-xl);
  box-shadow: var(--flc-shadow-xl);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom right;
  transition: opacity var(--flc-transition-normal),
              visibility var(--flc-transition-normal),
              transform var(--flc-transition-normal);
}

.flc-chat-widget.is-open .flc-chat-window {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Mobile full screen */
@media (max-width: 480px) {
  .flc-chat-window {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    max-height: calc(100vh - 60px);
    min-height: auto;
    height: calc(100vh - 60px);
    border-radius: var(--flc-radius-xl) var(--flc-radius-xl) 0 0;
    transform: translateY(100%);
  }

  .flc-chat-widget.is-open .flc-chat-window {
    transform: translateY(0);
  }
}

/* ============================================
   HEADER
   ============================================ */

.flc-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--flc-spacing-md);
  background: linear-gradient(135deg, var(--flc-gradient-start) 0%, var(--flc-accent) 50%, var(--flc-gradient-end) 100%);
  color: var(--flc-white);
}

.flc-chat-header-info {
  display: flex;
  align-items: center;
  gap: var(--flc-spacing-sm);
}

.flc-chat-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--flc-radius-full);
}

.flc-chat-title {
  margin: 0;
  font-size: var(--flc-font-size-base);
  font-weight: 600;
}

.flc-chat-status {
  display: flex;
  align-items: center;
  gap: var(--flc-spacing-xs);
  margin: 0;
  font-size: var(--flc-font-size-xs);
  opacity: 0.9;
}

.flc-chat-status-dot {
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: var(--flc-radius-full);
  animation: flc-pulse 2s ease-in-out infinite;
}

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

.flc-chat-minimize {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: var(--flc-white);
  border-radius: var(--flc-radius-md);
  cursor: pointer;
  transition: background var(--flc-transition-fast);
}

.flc-chat-minimize:hover {
  background: rgba(255, 255, 255, 0.2);
}

.flc-chat-minimize:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
}

/* ============================================
   MESSAGES AREA
   ============================================ */

.flc-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--flc-spacing-md);
  background: var(--flc-gray-50);
  scroll-behavior: smooth;
}

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

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

.flc-chat-messages::-webkit-scrollbar-thumb {
  background: var(--flc-gray-300);
  border-radius: var(--flc-radius-full);
}

.flc-chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--flc-gray-400);
}

/* ============================================
   MESSAGE BUBBLES
   ============================================ */

.flc-chat-message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  margin-bottom: var(--flc-spacing-md);
  animation: flc-fade-in 0.3s ease;
}

@keyframes flc-fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.flc-chat-message--user {
  align-items: flex-end;
  margin-left: auto;
}

.flc-chat-message--bot {
  align-items: flex-start;
}

.flc-chat-message-content {
  padding: var(--flc-spacing-sm) var(--flc-spacing-md);
  border-radius: var(--flc-radius-lg);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.flc-chat-message--user .flc-chat-message-content {
  background: var(--flc-primary);
  color: var(--flc-white);
  border-bottom-right-radius: var(--flc-spacing-xs);
}

.flc-chat-message--bot .flc-chat-message-content {
  background: var(--flc-white);
  color: var(--flc-gray-800);
  border: 1px solid var(--flc-gray-200);
  border-bottom-left-radius: var(--flc-spacing-xs);
}

/* Message content formatting */
.flc-chat-message-content p {
  margin: 0 0 var(--flc-spacing-sm) 0;
}

.flc-chat-message-content p:last-child {
  margin-bottom: 0;
}

.flc-chat-message-content ul,
.flc-chat-message-content ol {
  margin: var(--flc-spacing-sm) 0;
  padding-left: var(--flc-spacing-lg);
}

.flc-chat-message-content li {
  margin-bottom: var(--flc-spacing-xs);
}

.flc-chat-message-content strong {
  font-weight: 600;
}

/* CTA Button in messages */
.flc-chat-button {
  display: inline-block;
  margin: var(--flc-spacing-sm) 0;
  padding: var(--flc-spacing-sm) var(--flc-spacing-md);
  background: var(--flc-secondary);
  color: var(--flc-gray-900) !important;
  font-size: var(--flc-font-size-sm);
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--flc-radius-md);
  transition: background var(--flc-transition-fast), transform var(--flc-transition-fast);
}

.flc-chat-button:hover {
  background: var(--flc-secondary-dark);
  transform: translateY(-1px);
  text-decoration: none;
}

.flc-chat-button:active {
  transform: translateY(0);
}

.flc-chat-message-time {
  margin-top: var(--flc-spacing-xs);
  font-size: var(--flc-font-size-xs);
  color: var(--flc-gray-400);
}

/* ============================================
   TYPING INDICATOR
   ============================================ */

.flc-chat-typing {
  opacity: 0.7;
}

.flc-chat-typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: var(--flc-spacing-sm) var(--flc-spacing-md);
  background: var(--flc-white);
  border: 1px solid var(--flc-gray-200);
  border-radius: var(--flc-radius-lg);
}

.flc-chat-typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--flc-gray-400);
  border-radius: var(--flc-radius-full);
  animation: flc-typing 1.4s ease-in-out infinite;
}

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

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

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

/* ============================================
   INPUT AREA
   ============================================ */

.flc-chat-input-area {
  padding: var(--flc-spacing-md);
  background: var(--flc-white);
  border-top: 1px solid var(--flc-gray-200);
}

.flc-chat-input-container {
  display: flex;
  align-items: flex-end;
  gap: var(--flc-spacing-sm);
  padding: var(--flc-spacing-sm);
  background: var(--flc-gray-100);
  border-radius: var(--flc-radius-lg);
  transition: box-shadow var(--flc-transition-fast);
}

.flc-chat-input-container:focus-within {
  box-shadow: 0 0 0 2px var(--flc-primary);
}

.flc-chat-input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: var(--flc-spacing-sm);
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: var(--flc-font-size-sm);
  line-height: 1.5;
  resize: none;
  color: var(--flc-gray-800);
}

.flc-chat-input::placeholder {
  color: var(--flc-gray-400);
}

.flc-chat-input:focus {
  outline: none;
}

.flc-chat-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: var(--flc-primary);
  color: var(--flc-white);
  border-radius: var(--flc-radius-md);
  cursor: pointer;
  transition: background var(--flc-transition-fast), transform var(--flc-transition-fast);
}

.flc-chat-send:hover:not(:disabled) {
  background: var(--flc-primary-dark);
}

.flc-chat-send:active:not(:disabled) {
  transform: scale(0.95);
}

.flc-chat-send:disabled {
  background: var(--flc-gray-300);
  cursor: not-allowed;
}

.flc-chat-send:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--flc-primary-light);
}

/* Powered by footer */
.flc-chat-powered {
  margin: var(--flc-spacing-sm) 0 0 0;
  font-size: var(--flc-font-size-xs);
  color: var(--flc-gray-400);
  text-align: center;
}

.flc-chat-powered-separator {
  margin: 0 var(--flc-spacing-xs);
}

.flc-chat-phone-link {
  color: var(--flc-primary);
  text-decoration: none;
  display: inline-block;
  padding: 8px 4px;
  min-height: 44px;
  line-height: 28px;
}

.flc-chat-phone-link:hover {
  text-decoration: underline;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .flc-chat-widget,
  .flc-chat-widget * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .flc-chat-message--bot .flc-chat-message-content {
    border-width: 2px;
  }

  .flc-chat-toggle:focus,
  .flc-chat-send:focus,
  .flc-chat-minimize:focus {
    outline: 3px solid;
    outline-offset: 2px;
  }
}

/* Focus visible */
.flc-chat-toggle:focus-visible,
.flc-chat-send:focus-visible,
.flc-chat-minimize:focus-visible,
.flc-chat-input:focus-visible {
  outline: 2px solid var(--flc-primary);
  outline-offset: 2px;
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  .flc-chat-widget {
    display: none !important;
  }
}
