/**
 * Widget Tarhely.eu - Host CSS
 * Minimal positioning styles for iframe widget
 *
 * @version 1.0.7
 * @date 2026-02-17
 * Changelog:
 * - v1.0.7 (2026-02-17): Experimental bubble UI (shape/effects + tooltip animation)
 * - v1.0.6 (2026-02-16): Bubble palette align to vNext + tooltip fit fix
 * - v1.0.5 (2025-11-25): CLEAN APPROACH - Mobile fullscreen via JS class (twe-mobile-fullscreen)
 *   - REMOVED: All @media queries for #twe-widget-iframe
 *   - ADDED: .twe-mobile-fullscreen class (position:fixed, inset:0, 100%/100dvh)
 *   - BENEFIT: JS-controlled mobile mode, no CSS media query false positives
 * - v1.0.4 (2025-11-24): Mobile docked shell: ~75% viewport height at bottom for #twe-widget-iframe
 * - v1.0.3 (2025-11-24): Mobile fullscreen shell: 100vw/100dvh for #twe-widget-iframe without over-aggressive !important
 * - v1.0.2 (2025-11-24): Mobile responsive fix: Force 100dvh/100vw with !important to override inline JS styles
 * - v1.0.1 (2025-11-09): Remove !important on responsive rules to allow dynamic resize; add width/height transitions
 */

/* Iframe widget container */
#twe-widget-iframe {
  /* Position is set inline via PHP for flexibility */
  border: none;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  border-radius: 16px;
  /* Smooth transitions for dynamic bridge-driven resizes */
  transition:
    width 0.3s ease,
    height 0.3s ease,
    transform 0.3s ease,
    opacity 0.3s ease;
  /* Smooth fade-in animation */
  opacity: 0;
  animation: twe-fade-in 0.5s ease forwards;
  animation-delay: 0.2s;
}

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

/* Hidden hub iframe (cross-domain state) */
#twe-hub-iframe {
  display: none !important;
  position: absolute;
  width: 0;
  height: 0;
  border: none;
  visibility: hidden;
}

/* Mobile full-screen mode (Chatbase-style)
   Applied via JS class toggle in bridge.js (UA + viewport detection)
   Forces iframe to cover entire viewport on mobile devices
*/
#twe-widget-iframe.twe-mobile-fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: 100dvh !important;
  border-radius: 0 !important;
  z-index: 2147483647 !important;
  box-shadow: none !important;
  margin: 0 !important;
}

/* Removed previous @media queries - mobile mode is now JS-controlled */

/* =====================================================================
   WordPress Bubble (namespaced, independent from site theme)
   Matches agent.tarhely.eu chat button + tooltip visuals
   ===================================================================== */

.twe-bubble-wrapper {
  /* position set inline (top/bottom + left/right) */
  width: auto;
  height: auto;
  pointer-events: auto;
  overflow: visible;

  /* Baseline before this experiment: commit 8b70fd48 */
  --twe-bubble-grad-1: #1e2d54;
  --twe-bubble-grad-2: #2a3f78;
  --twe-bubble-grad-3: #1a2744;
  --twe-bubble-glow: rgba(42, 63, 120, 0.22);
}

.twe-bubble-button {
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: linear-gradient(
    145deg,
    var(--twe-bubble-grad-1),
    var(--twe-bubble-grad-2),
    var(--twe-bubble-grad-3)
  );
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 !important; /* theme overrides often add button padding */
  box-shadow: 0 6px 24px rgba(30, 45, 84, 0.3), 0 2px 8px rgba(26, 39, 68, 0.2);
  color: #fff;
  outline: none;
  /* Neutralize theme text metrics so no stray glyph shows */
  line-height: 0;
  font-size: 0;
  z-index: 0;
  overflow: visible;
  transform: scale(1);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Hard center override (if theme overrides flex/padding). */
#twe-bubble.twe-bubble-button {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
}

.twe-bubble-button::before {
  content: '';
  position: absolute;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: -1;
  pointer-events: none;
  animation: twe-glow-pulse 3.5s ease-in-out infinite;
}

.twe-bubble-button:hover {
  transform: scale(1.08);
  box-shadow: 0 10px 36px rgba(30, 45, 84, 0.45), 0 4px 12px rgba(26, 39, 68, 0.3);
}

.twe-bubble-button:hover::before {
  animation: none;
  box-shadow: none;
  opacity: 0;
}

.twe-bubble-button:active {
  transform: scale(0.95);
}

.twe-bubble-button::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 1px;
  right: 1px;
  height: 45%;
  border-radius: 15px 15px 40% 40%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0) 100%);
  pointer-events: none;
}

.twe-bubble-button.twe-ring {
  animation: twe-ring-shake 0.8s ease;
}

/* Lock icon size against theme overrides */
.twe-bubble-button .twe-bubble-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  z-index: 1;
  display: block;
  pointer-events: none;
}

.twe-bubble-button .twe-bubble-icon svg {
  width: 24px !important;
  height: 24px !important;
  display: block;
  flex: 0 0 auto;
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.twe-bubble-button.twe-icon-chat .twe-icon-chat {
  opacity: 1;
  transform: scale(1);
}

.twe-bubble-button.twe-icon-phone .twe-icon-phone {
  opacity: 1;
  transform: scale(1);
}

.twe-bubble-button.twe-fading .twe-bubble-icon svg {
  opacity: 0;
  transform: scale(0.8);
}

/* Tooltip */
#twe-bubble-wrapper .twe-bubble-tooltip {
  position: absolute;
  bottom: 62px;
  right: 0;
  z-index: 40;
  background: #ffffff;
  color: #1a2744;
  padding: 10px 18px 10px 16px;
  border-radius: 20px 20px 6px 20px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  box-shadow: 0 6px 28px rgba(30, 40, 80, 0.13), 0 2px 6px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  gap: 3px;

  opacity: 0;
  transform: translateY(10px) scale(0.88);
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  cursor: pointer;
}

#twe-bubble-wrapper.twe-tooltip-visible .twe-bubble-tooltip {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* No arrow in this tooltip variant */
.twe-bubble-tooltip::after {
  display: none;
}

/* Hide tooltip while widget is open */
.twe-bubble-wrapper.twe-open .twe-bubble-tooltip {
  opacity: 0;
  pointer-events: none;
  display: none;
}

@keyframes twe-ring-shake {
  0%,
  100% {
    transform: rotate(0deg) scale(1);
  }
  12% {
    transform: rotate(14deg) scale(1.06);
  }
  25% {
    transform: rotate(-12deg) scale(1.06);
  }
  37% {
    transform: rotate(10deg) scale(1.03);
  }
  50% {
    transform: rotate(-6deg) scale(1.02);
  }
  62% {
    transform: rotate(4deg) scale(1.01);
  }
  75% {
    transform: rotate(-2deg) scale(1);
  }
}

@keyframes twe-glow-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 var(--twe-bubble-glow);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(42, 63, 120, 0);
  }
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .twe-bubble-button {
    width: 52px;
    height: 52px;
  }
}
