/* Frynzy AI Chat Widget & Overlay Styles */

:root {
  --frynzy-primary: #7c3aed;
  --frynzy-primary-glow: rgba(124, 58, 237, 0.3);
  --frynzy-secondary: #0ea5e9;
  --frynzy-bg: rgba(255, 255, 255, 0.97);
  --frynzy-card-bg: rgba(248, 250, 252, 0.9);
  --frynzy-card-border: rgba(148, 163, 184, 0.2);
  --frynzy-text: #1e293b;
  --frynzy-text-dim: #64748b;
  --frynzy-font: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
}

/* Floating Widget Button */
.frynzy-widget-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #05060f;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 99999;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  user-select: none;
  touch-action: none;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  /* needed for z-index children stacking */
  isolation: isolate;
}

.frynzy-widget-btn:hover {
  transform: scale(1.08);
}

.frynzy-widget-btn:active {
  transform: scale(0.95);
}

/* Rainbow glowing ring OUTSIDE the button */
.frynzy-widget-border {
  position: absolute;
  top: -3px;
  left: -3px;
  width: calc(100% + 6px);
  height: calc(100% + 6px);
  border-radius: 50%;
  background: linear-gradient(
    45deg,
    #FF0000, #FF7300, #FFFB00, #48FF00,
    #00FFD5, #002BFF, #FF00C8, #FF0000
  );
  background-size: 600%;
  filter: blur(8px);
  z-index: -1;
  animation: frynzyGlowing 20s linear infinite;
}

/* Crisp (non-blurred) ring layer for clean edge */
.frynzy-widget-border::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(
    45deg,
    #FF0000, #FF7300, #FFFB00, #48FF00,
    #00FFD5, #002BFF, #FF00C8, #FF0000
  );
  background-size: 600%;
  filter: blur(1px);
  animation: frynzyGlowing 20s linear infinite;
  z-index: 0;
}

.frynzy-widget-btn.loading .frynzy-widget-border,
.frynzy-widget-btn.loading .frynzy-widget-border::after {
  animation: frynzyGlowing 4s linear infinite;
}

@keyframes frynzyGlowing {
  0%   { background-position: 0 0; }
  50%  { background-position: 400% 0; }
  100% { background-position: 0 0; }
}


/* SVG Inside widget */
.frynzy-widget-icon {
  width: 32px;
  height: 32px;
  fill: none;
  stroke: #fff;
  position: relative;
  z-index: 2;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.frynzy-widget-icon path.spine {
  stroke-dasharray: 60;
  stroke-dashoffset: 60;
  animation: frynzyDraw 1.5s ease forwards;
}

.frynzy-widget-icon path.bars {
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  animation: frynzyDraw 1s ease forwards 0.5s;
}

@keyframes frynzyDraw {
  to { stroke-dashoffset: 0; }
}

/* Chat Overlay Drawer */
.frynzy-chat-overlay {
  position: fixed;
  top: 0;
  right: -420px;
  width: 400px;
  height: 100%;
  background: #ffffff;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: -6px 0 40px rgba(0, 0, 0, 0.1);
  z-index: 99998;
  display: flex;
  flex-direction: column;
  transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: var(--frynzy-font);
  color: var(--frynzy-text);
}

.frynzy-chat-overlay.open {
  right: 0;
}

/* Header */
.frynzy-chat-header {
  padding: 20px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
}

.frynzy-chat-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #1e293b;
}

.frynzy-chat-title .f-mini {
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, var(--frynzy-primary), var(--frynzy-secondary));
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: #fff;
  font-size: 15px;
  -webkit-text-fill-color: initial;
}

.frynzy-chat-close {
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  font-size: 20px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.frynzy-chat-close:hover {
  background: #f1f5f9;
  color: #1e293b;
}

/* Chat Body */
.frynzy-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
  background: #f8fafc;
}

/* Welcome Card */
.frynzy-welcome-box {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.05) 0%, rgba(14, 165, 233, 0.03) 100%);
  border: 1.5px solid rgba(124, 58, 237, 0.18);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  margin-bottom: 5px;
}

.frynzy-welcome-title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 8px;
  color: #1e293b;
}

.frynzy-welcome-desc {
  font-size: 13.5px;
  color: #64748b;
  line-height: 1.5;
  margin-bottom: 16px;
}

/* Quick Options Grid */
.frynzy-quick-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.frynzy-option-card {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.frynzy-option-card:hover {
  background: #f5f3ff;
  border-color: rgba(124, 58, 237, 0.35);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.1);
}

.frynzy-option-emoji {
  font-size: 18px;
}

.frynzy-option-text {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  color: #1e293b;
}

/* Messages area */
.frynzy-messages-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.frynzy-message-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

.frynzy-message-wrapper.user {
  align-self: flex-end;
}

.frynzy-message-wrapper.assistant {
  align-self: flex-start;
  width: 100%;
}

.frynzy-bubble {
  padding: 14px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.frynzy-message-wrapper.user .frynzy-bubble {
  background: linear-gradient(135deg, var(--frynzy-primary) 0%, #6d28d9 100%);
  border-bottom-right-radius: 4px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2);
}

.frynzy-message-wrapper.assistant .frynzy-bubble {
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-bottom-left-radius: 4px;
  color: #000000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

/* Collapsible DeepSeek thoughts */
.frynzy-thoughts-container {
  margin-top: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-left: 2.5px solid var(--frynzy-primary);
  border-radius: 6px;
  overflow: hidden;
  font-size: 13px;
  width: 85%;
}

.frynzy-thoughts-summary {
  padding: 8px 12px;
  font-weight: 600;
  color: var(--frynzy-text-dim);
  cursor: pointer;
  user-select: none;
  outline: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s;
}

.frynzy-thoughts-summary:hover {
  background: rgba(255, 255, 255, 0.02);
  color: #fff;
}

.frynzy-thoughts-content {
  padding: 10px 14px;
  line-height: 1.5;
  color: #94a3b8;
  font-style: italic;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  max-height: 150px;
  overflow-y: auto;
}

/* Suggestion chips */
.frynzy-suggestions-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.frynzy-suggestion-chip {
  background: #f1f5f9;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #475569;
}

.frynzy-suggestion-chip:hover {
  background: #ede9fe;
  border-color: var(--frynzy-primary);
  color: var(--frynzy-primary);
  transform: scale(1.02);
}

/* Loading skeleton typing effect */
.frynzy-typing-indicator {
  display: flex;
  gap: 5px;
  padding: 6px 10px;
  align-items: center;
}

.frynzy-typing-dot {
  width: 6px;
  height: 6px;
  background: var(--frynzy-text-dim);
  border-radius: 50%;
  animation: frynzyBounce 1.4s infinite ease-in-out both;
}

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

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

/* Chat Footer Saisie */
.frynzy-chat-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  background: #ffffff;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.frynzy-input-wrapper {
  flex: 1;
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 18px;
  padding: 8px 14px;
  display: flex;
  align-items: flex-end;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.frynzy-input-wrapper:focus-within {
  border-color: var(--frynzy-primary);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.frynzy-chat-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: #1e293b;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.4;
  max-height: 100px;
  padding: 2px 0;
}

.frynzy-chat-textarea::placeholder {
  color: #94a3b8;
}

.frynzy-chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--frynzy-primary);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.frynzy-chat-send:hover {
  background: #6d28d9;
  transform: scale(1.05);
}

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

.frynzy-chat-send svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Custom Scrollbar for Chat Body */
.frynzy-chat-body::-webkit-scrollbar {
  width: 5px;
}

.frynzy-chat-body::-webkit-scrollbar-track {
  background: #f1f5f9;
}

.frynzy-chat-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

.frynzy-chat-body::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
  .frynzy-chat-overlay {
    width: 100% !important;
    right: -100% !important;
  }
  
  .frynzy-chat-overlay.open {
    right: 0 !important;
  }

  .frynzy-widget-btn {
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
  }

  .frynzy-chat-header {
    padding: 12px 16px;
  }

  .frynzy-chat-title {
    font-size: 15px;
  }

  .frynzy-chat-close {
    font-size: 24px;
    width: 30px;
    height: 30px;
  }

  .frynzy-chat-body {
    padding: 12px;
    gap: 12px;
  }

  .frynzy-welcome-box {
    padding: 14px;
    border-radius: 12px;
  }

  .frynzy-welcome-title {
    font-size: 16px;
  }

  .frynzy-welcome-desc {
    font-size: 12px;
    margin-bottom: 12px;
  }

  .frynzy-quick-options {
    gap: 8px;
  }

  .frynzy-option-card {
    padding: 8px;
    border-radius: 8px;
  }

  .frynzy-option-emoji {
    font-size: 16px;
  }

  .frynzy-option-text {
    font-size: 11px;
  }

  .frynzy-bubble {
    padding: 10px 12px;
    font-size: 12.5px;
    border-radius: 12px;
  }

  .frynzy-message-wrapper {
    max-width: 90%;
  }

  .frynzy-chat-footer {
    padding: 10px;
  }

  .frynzy-chat-textarea {
    font-size: 13.5px;
    padding: 6px 10px;
  }

  .frynzy-chat-send {
    width: 32px;
    height: 32px;
  }
}

/* Dragging active state for long press visual feedback */
.frynzy-widget-btn.dragging-active {
  transform: scale(1.2) !important;
  box-shadow: 0 0 30px var(--frynzy-primary-glow), 0 10px 40px rgba(0, 0, 0, 0.6) !important;
  transition: transform 0.2s ease !important;
}

/* Hide/disable widget when consent or blocking modal is active */
body.consent-modal-active .frynzy-widget-btn,
body.consent-modal-active .frynzy-tooltip-intro,
body.frynzy-chat-blocked .frynzy-widget-btn,
body.frynzy-chat-blocked .frynzy-tooltip-intro {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

/* Pulse animation to draw attention to tooltip on first opening */
@keyframes frynzyHintPulse {
  0% { transform: scale(1); box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5); }
  50% { transform: scale(1.15); box-shadow: 0 0 28px rgba(124, 58, 237, 0.85), 0 8px 32px rgba(0, 0, 0, 0.5); }
  100% { transform: scale(1); box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5); }
}

.frynzy-widget-btn.frynzy-hint-pulse {
  animation: frynzyHintPulse 1.4s ease-in-out 2;
}

/* Floating Tooltip Intro */
.frynzy-tooltip-intro {
  position: fixed;
  bottom: 110px;
  right: 30px;
  width: 260px;
  background: rgba(15, 23, 42, 0.95);
  border: 1.5px solid rgba(124, 58, 237, 0.7);
  border-radius: 14px;
  padding: 14px 32px 14px 16px;
  color: #ffffff;
  font-family: var(--frynzy-font);
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45), 0 0 20px rgba(124, 58, 237, 0.25);
  z-index: 99995;
  opacity: 0;
  transform: translateY(12px) scale(0.95);
  transition: opacity 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
  pointer-events: auto;
}

.frynzy-tooltip-intro.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.frynzy-tooltip-intro .tooltip-close {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 18px;
  cursor: pointer;
  color: #94a3b8;
  transition: color 0.2s;
  line-height: 1;
}

.frynzy-tooltip-intro .tooltip-close:hover {
  color: #ffffff;
}

.frynzy-tooltip-intro strong {
  color: #c084fc;
  display: block;
  font-weight: 700;
  margin-bottom: 4px;
}

@media (max-width: 480px) {
  .frynzy-tooltip-intro {
    bottom: 90px;
    right: 20px;
    width: 220px;
    font-size: 12px;
    padding: 10px 28px 10px 12px;
  }
}
