/**
 * WhatsApp floating assistant and inline button styles.
 *
 * @package Woo_Otimizations
 */
/* Inline button */
.ow-wa-btn-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: #25D366;
  color: #fff;
  text-decoration: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .25s ease, transform .25s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.ow-wa-btn-inline.ow-visible { opacity: 1; transform: translateY(0); }
.ow-wa-btn-inline .ow-wa-icon { 
    width: 18px; 
    height: 18px; 
    display: block; 
    filter: invert(1); /* Invert white to black */
    margin: 0; /* reset */
}

/* Force absolute positioning for archive loops to prevent layout breakage */
.ow-wa-btn-inline.ow-wa-archive { 
    display: none; 
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 20;
}
/* Ensure product parent is relative */
.product, .wc-block-grid__product, .rey-productItem, li.product {
    position: relative !important;
}

.rey-productFooter-item--addtocart { position: relative; }
.rey-productFooter-item--addtocart .ow-wa-btn-inline { 
    margin-left: 0; 
    position: absolute; 
    right: 8px; 
    top: 50%; 
    transform: translateY(-50%); 
    /* Inline context: Reset size if needed or keep standard */
    width: auto; height: auto; background: none; box-shadow: none;
}
.rey-productFooter-item--addtocart .ow-wa-btn-inline .ow-wa-icon {
    width: 22px; height: 22px; filter: invert(1);
}

/* Hover behaviors */
.rey-productFooter-item--addtocart:hover .ow-wa-btn-inline.ow-wa-archive,
.wc-block-components-product-button:hover .ow-wa-btn-inline.ow-wa-archive,
.wc-block-grid__product:hover .ow-wa-btn-inline.ow-wa-archive,
.product:hover .ow-wa-btn-inline.ow-wa-archive,
li.product:hover .ow-wa-btn-inline.ow-wa-archive { 
    display: inline-flex; 
}

/* Component Wrapper */
.ow-wa-component {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1050;
    /* Allow size to be determined by children (FAB) */
    width: auto; 
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none; /* Pass clicks through the empty areas */
}
/* Re-enable clicks for children */
.ow-wa-component > * {
    pointer-events: auto;
}
#ow-wa-component .ow-wa-toggle,
#ow-wa-component .ow-wa-satellite,
#ow-wa-component .ow-wa-actions {
    margin: 0;
}

/* Satellite Button (Mini Search) - Legacy/Fallback */
button.ow-wa-satellite, .ow-wa-satellite {
    position: absolute;
    top: -40px; /* User requested -40px */
    right: 0; 
    width: 35px;
    height: 35px;
    border-radius: 50% !important; /* User requested strict 50% */
    background: #fff !important;
    border: 1px solid #e7e7e7; /* User requested border */
    box-shadow: 0 4px 8px rgba(0,0,0,0.2); 
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1055;
    /* Entrance Transition */
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.5s ease;
    /* Initial State: Hidden and offset */
    opacity: 0;
    transform: translateX(40px) rotate(90deg) scale(0.5);
    will-change: transform, opacity;
}
.ow-wa-component.ow-visible .ow-wa-satellite {
    opacity: 1;
    /* Final State: Visible and in place */
    transform: translateX(0) rotate(0deg) scale(1);
}
/* Idle animation applied via JS after entrance is complete */
.ow-wa-satellite.ow-idle {
    animation: ow-satellite-idle 5s infinite ease-in-out;
    /* No delay needed here as JS handles the timing */
}
.ow-wa-satellite:hover {
    transform: scale(1.1);
    animation: none;
}
.ow-wa-satellite:active {
    transform: scale(0.95);
    box-shadow: 1px 1px 0px rgba(0,0,0,0.5);
    animation: none;
}

/* --- NEW TOGGLE & ACTIONS (Interactive Mode) --- */
.ow-wa-toggle {
    position: absolute;
    top: -40px;
    right: 0;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: #fff !important;
    border: 1px solid #e7e7e7;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1055;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.5s ease;
    opacity: 0;
    transform: translateX(40px) rotate(90deg) scale(0.5);
    color: #333;
}
.ow-wa-component.ow-visible .ow-wa-toggle {
    opacity: 1;
    transform: translateX(0) rotate(0deg) scale(1);
    border-radius: 50% !important;
    box-shadow: 2px 3px black !important;
}
span.ow-icon-plus,
span.ow-icon-close {
    line-height: 0;
}

/* Ensure actions also have these properties enforced if missing */
button.ow-wa-action.ow-wa-action-hand,
button.ow-wa-action.ow-wa-action-search {
    border-radius: 50% !important;
    box-shadow: 2px 3px black !important;
    margin: 0;
    padding: 0;
}
.ow-wa-toggle:hover { transform: scale(1.1); }
.ow-wa-toggle:active { transform: scale(0.95); }

/* Toggle Active State (Menu Open) */
.ow-wa-toggle.ow-active {
    background: #333 !important;
    color: white;
    border-color: #333;
}

/* Actions Wrapper (Hidden by default) */
.ow-wa-actions {
    position: absolute;
    bottom: 100%; /* Above the component */
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding-bottom: 50px; /* Space for Toggle */
    pointer-events: none;
    z-index: 1052;
}

/* Action Buttons */
.ow-wa-action {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: #fff !important;
    border: 1px solid #e7e7e7;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #333;
    opacity: 0;
    transform: translateY(20px) scale(0.8);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ow-wa-action:hover {
    transform: scale(1.1);
    color: #25D366;
}
.ow-wa-action:active { transform: scale(0.95); }

/* Reveal Actions when Toggle is Active */
.ow-wa-toggle.ow-active ~ .ow-wa-actions {
    pointer-events: auto;
}
.ow-wa-toggle.ow-active ~ .ow-wa-actions .ow-wa-action {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Staggered Delay for Actions */
.ow-wa-toggle.ow-active ~ .ow-wa-actions .ow-wa-action:nth-child(1) { transition-delay: 0.1s; }
.ow-wa-toggle.ow-active ~ .ow-wa-actions .ow-wa-action:nth-child(2) { transition-delay: 0.05s; }

/* Sticky Ghost Icon */
.ow-wa-ghost {
    position: fixed;
    top: 0; left: 0;
    width: 40px; height: 40px;
    pointer-events: none;
    z-index: 1052;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
    transition: transform 0.1s linear; /* Smooth follow */
    will-change: transform;
    display: none;
}
.ow-wa-ghost.ow-visible { display: block; }
.ow-wa-ghost img { width: 100%; height: 100%; display: block; }


@keyframes ow-satellite-idle {
    0%, 100% { transform: scale(1) translateY(0); }
    50% { transform: scale(1.08) translateY(-3px); }
}

/* Icons inside Satellite */
.ow-wa-satellite .ow-icon-search,
.ow-wa-satellite .ow-icon-wa-small {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: opacity 0.4s ease, transform 0.4s ease;
    font-size: 20px;
    line-height: 1;
}
.ow-wa-satellite .ow-icon-wa-small {
    width: 22px;
    height: 22px;
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-180deg) scale(0);
}

.ow-wa-fab {
  position: relative; /* Relative to component */
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--ow-wa-bg-color, #25D366);
  color: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.4s, border-color 0.4s, opacity 0.4s ease;
  z-index: 1053;
  will-change: transform, background-color, opacity;
  border: 2px solid transparent; /* Prepare for border change */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  
  /* Initial State for Entrance Animation */
  opacity: 0;
  transform: scale(0.5) translateY(20px);
}
.ow-wa-component.ow-visible .ow-wa-fab {
  opacity: 1;
  transform: scale(1) translateY(0);
  /* Pulse animation starts after transition */
  animation: ow-wa-pulse 3s infinite;
  animation-delay: 0.5s;
}
.ow-wa-fab.ow-visible {
  margin-top: 5px;
}
.ow-wa-fab:active {
    transform: scale(0.95);
}

/* Icons inside FAB */
.ow-wa-fab .ow-main-icon-wa,
.ow-wa-fab .ow-main-icon-search {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: opacity 0.4s ease, transform 0.4s ease;
}
.ow-wa-fab .ow-main-icon-wa {
    width: 32px;
    height: 32px;
    filter: invert(1);
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
}
.ow-wa-fab .ow-main-icon-search {
    font-size: 26px;
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-180deg) scale(0);
}

/* --- SWAP STATE (Search Mode) --- */
.ow-wa-component.ow-swapped .ow-wa-fab {
    background: #fff; /* Main button becomes white */
    border-color: #000;
    color: #000;
}
/* Main Icon -> Hide WA, Show Search */
.ow-wa-component.ow-swapped .ow-wa-fab .ow-main-icon-wa {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(180deg) scale(0);
}
.ow-wa-component.ow-swapped .ow-wa-fab .ow-main-icon-search {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
}

/* Satellite -> Hide Search, Show WA */
.ow-wa-component.ow-swapped .ow-wa-satellite {
    background: #25D366;
    border-color: #25D366;
}
.ow-wa-component.ow-swapped .ow-wa-satellite .ow-icon-search {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(180deg) scale(0);
}
.ow-wa-component.ow-swapped .ow-wa-satellite .ow-icon-wa-small {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
    filter: invert(1); /* Make it white */
}

/* Simple + Search: Satellite showing WhatsApp icon should use configured color */
#ow-wa-component.ow-simple.ow-swapped .ow-wa-satellite {
    background: var(--ow-wa-bg-color, #25D366) !important;
    border-color: var(--ow-wa-bg-color, #25D366) !important;
    box-shadow: none !important;
}

/* --- LOADING STATE (Search Triggered) --- */
/* Fade out tooltip */
.ow-wa-tooltip.ow-fade-out {
    opacity: 0 !important;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

/* Loading Icon inside FAB */
.ow-wa-fab .ow-main-icon-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

/* Loading State on Component */
.ow-wa-component.ow-loading .ow-wa-fab {
    background: #fff;
    border-color: #000;
    color: #000;
}

/* Hide Search Icon when Loading */
.ow-wa-component.ow-loading .ow-wa-fab .ow-main-icon-search {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(180deg) scale(0);
}

/* Show Loading Icon when Loading */
.ow-wa-component.ow-loading .ow-wa-fab .ow-main-icon-loading {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Hourglass Animation */
.ow-wa-fab .ow-main-icon-loading svg {
    display: block;
    width: 24px;
    height: 24px;
    color: #000;
    animation: ow-hourglass-spin 2s linear infinite;
}

@keyframes ow-hourglass-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- TOOLTIP & CONTENT --- */


@keyframes ow-wa-pulse {
  0% {
    box-shadow: 0 0 0 0 var(--ow-wa-pulse-strong, rgba(37, 211, 102, 0.7));
  }
  50% {
    box-shadow: 0 0 0 10px var(--ow-wa-pulse-zero, rgba(37, 211, 102, 0));
  }
  100% {
    box-shadow: 0 0 0 0 var(--ow-wa-pulse-zero, rgba(37, 211, 102, 0));
  }
}

/* Tooltip (Comic Style) */
.ow-wa-tooltip {
  position: absolute;
  right: 75px; /* Pushed further left (was 65px) to avoid "appearing right" */
  bottom: 50px; /* Adjusted vertical position */
  background: #fff;
  color: #000;
  padding: 15px 20px; /* More padding for oval shape */
  border-radius: 20px; /* Comic-style rounded rectangle, not perfect oval but round */
  border: 2px solid #000;
  box-shadow: 4px 4px 0px #000;
  font-family: sans-serif;
  font-weight: 600;
  font-size: 14px;
  white-space: normal;
  line-height: 1.3;
  min-width: auto; /* Removed fixed min-width to avoid excess whitespace */
  max-width: 240px; /* Slightly narrower */
  width: max-content; /* Elastic width to fit content */
  opacity: 0;
  transform: scale(0.8);
  transform-origin: bottom right;
  transition: opacity 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none; 
  z-index: 1000;
  will-change: transform, opacity;
  backface-visibility: hidden;
  /* "Mexendo" effect - Subtle float */
  animation: ow-tooltip-float 3s ease-in-out infinite;
}

@keyframes ow-tooltip-float {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-3px) scale(1); }
}

.ow-wa-component.ow-tip .ow-wa-tooltip { opacity: 1; pointer-events: auto; } /* Removed scale(1) from here to let animation handle it, or combine? */
/* Actually, animation overrides transform. We need to handle enter state. */
.ow-wa-component.ow-tip .ow-wa-tooltip {
    opacity: 1;
    animation: ow-tooltip-enter 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, ow-tooltip-float 3s ease-in-out infinite 0.4s;
}

@keyframes ow-tooltip-enter {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.ow-wa-tooltip .ow-wa-tooltip-close {
  position: absolute;
  top: -15px;
  right: -15px;
  background: #ff4444;
  border: 2px solid #000;
  color: #fff;
  font-size: 14px;
  line-height: 1;
  font-weight: bold;
  cursor: pointer;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  padding: 0;
  box-shadow: 2px 2px 0px #000;
  pointer-events: auto;
  transition: transform 0.1s;
  z-index: 1051;
}
.ow-wa-tooltip .ow-wa-tooltip-close:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0px #000;
}
#ow-wa-component .ow-wa-tooltip .ow-wa-tooltip-close {
  min-height: unset;
  margin: 0;
}

/* Tooltip Tail (Pointing Right) */
.ow-wa-tooltip:after {
  content: "";
  position: absolute;
  right: -10px; /* Stick out right */
  bottom: 10px; /* Adjusted for new height */
  width: 0; height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 10px solid #000;
}
.ow-wa-tooltip:before {
  content: "";
  position: absolute;
  right: -6px;
  bottom: 12px; /* Adjusted for new height */
  width: 0; height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 8px solid #fff;
  z-index: 1;
}

/* Search Mode Styles inside Tooltip */
.ow-wa-search-form {
    display: none;
    flex-direction: row;
    align-items: center;
    gap: 4px; /* Reduced gap */
    width: 100%;
}
.ow-wa-tooltip.ow-search-mode {
    min-width: 230px; /* User requested 230px */
    padding: 10px; /* User requested 10px */
    cursor: default;
}
.ow-wa-tooltip.ow-search-mode .ow-wa-tooltip-text { display: none; }
.ow-wa-tooltip.ow-search-mode .ow-wa-search-form { display: flex; }

.ow-wa-search-form input,
.ow-wa-search-form textarea {
    flex: 1;
    width: 100%;
    box-sizing: border-box; /* Ensure padding doesn't affect width calculation */
    padding: 8px 15px;
    border: 0px;
    border-radius: 20px;
    font-size: 14px;
    line-height: 1.3;
    outline: none;
    background: #f0f0f0; 
    color: #333;
    transition: background-color 0.2s;
    resize: none; /* Disable manual resize */
    
    /* User Requested Styles */
    height: auto;
    min-height: 40px;
    max-height: 72px;
    overflow-y: auto;
    field-sizing: content;
    margin-bottom: 0;
}
.ow-wa-search-form input::placeholder,
.ow-wa-search-form textarea::placeholder {
    color: #666; /* User requested darker placeholder */
    opacity: 1;
}
.ow-wa-search-form input:focus,
.ow-wa-search-form textarea:focus {
    background: #e0e0e0;
}
.ow-wa-search-form button {
    background: transparent;
    color: #666;
    border: none;
    padding: 5px;
    cursor: pointer;
    box-shadow: none;
    font-size: 0; /* Hide text if any, show SVG */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, transform 0.2s;
}
.ow-wa-search-form button:hover {
    color: #25D366;
    transform: scale(1.1);
}
.ow-wa-search-form button svg {
    width: 20px;
    height: 20px;
}
.ow-wa-search-form button:active {
    transform: scale(0.95);
    box-shadow: none;
}

/* SVG Icon Colors */
.ow-icon-search svg,
.ow-main-icon-search svg {
    display: block;
}
/* Satellite Icon Color */
.ow-wa-satellite .ow-icon-search {
    color: #000;
}
/* Main FAB Search Icon (when swapped) */
.ow-wa-fab .ow-main-icon-search {
    color: #000;
}

/* Marquee Effect for Search */
.ow-wa-search-marquee {
    flex: 1;
    width: 100%;
    height: 34px; /* Matches input height roughly */
    overflow: hidden;
    position: relative;
    background: #f0f0f0;
    border-radius: 99px;
    display: flex;
    align-items: center;
    color: #333;
    font-size: 14px;
    white-space: nowrap;
}
.ow-wa-search-marquee span {
    display: inline-block;
    padding-left: 100%;
    animation: ow-marquee 5s linear infinite;
}
@keyframes ow-marquee {
    0%   { transform: translate(0, 0); }
    100% { transform: translate(-100%, 0); }
}

/* Cursor (Product Mode) - Updated to match Comic Style */
.ow-wa-cursor {
  position: fixed;
  top: 0;
  left: 0;
  width: 24px;
  height: 24px;
  background: #25D366;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1s ease;
  will-change: transform, opacity;
  backface-visibility: hidden;
  transform: translateZ(0);
}
.ow-wa-cursor img { width: 18px; height: 18px; display: block; filter: invert(1); }
.ow-wa-cursor-label {
  position: absolute;
  left: -8px;
  bottom: 34px;
  background: #fff;
  color: #000;
  border: 2px solid #000;
  border-radius: 20px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.15;
  min-width: 120px;
  max-width: 180px;
  box-shadow: 4px 4px 0px #000;
  opacity: 1;
  transition: opacity .25s ease;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  will-change: opacity;
  backface-visibility: hidden;
}
.ow-wa-cursor.ow-visible { opacity: 1; }

/* Close button on cursor label (follow tooltip close style, mobile-focused) */
.ow-wa-cursor-close {
  position: fixed;
  background: #ff4444 !important;
  border: 2px solid #000 !important;
  color: #fff !important;
  font-size: 14px;
  line-height: 1;
  font-weight: bold;
  cursor: pointer;
  width: 24px;
  height: 24px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 50% !important;
  padding: 0;
  box-shadow: 2px 2px 0px #000;
  pointer-events: auto;
  transition: transform 0.1s;
  z-index: 100005;
}
.ow-wa-cursor-close:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0px #000;
}
@media (hover: none) and (pointer: coarse) {
  .ow-wa-cursor-close { display: flex; }
}

@media (hover:hover) {
  .ow-wa-btn-inline:active { transform: translateY(0) scale(.97); }
}

/* Onboarding Hidden (Replaced by new flow) */
.ow-wa-onboarding { display: none !important; }

/* Hand icon: default on desktop, custom SVG only on mobile */
#ow-wa-component button.ow-wa-action.ow-wa-action-hand .ow-icon-hand-default,
#ow-wa-component .ow-wa-satellite.ow-wa-action-hand .ow-icon-hand-default {
    display: inline;
    line-height: 0;
}
#ow-wa-component button.ow-wa-action.ow-wa-action-hand .ow-icon-hand-mobile,
#ow-wa-component .ow-wa-satellite.ow-wa-action-hand .ow-icon-hand-mobile {
    display: none;
}
@media (hover: none) and (pointer: coarse) {
    #ow-wa-component button.ow-wa-action.ow-wa-action-hand .ow-icon-hand-default,
    #ow-wa-component .ow-wa-satellite.ow-wa-action-hand .ow-icon-hand-default {
        display: none;
    }
    #ow-wa-component button.ow-wa-action.ow-wa-action-hand .ow-icon-hand-mobile,
    #ow-wa-component .ow-wa-satellite.ow-wa-action-hand .ow-icon-hand-mobile {
        display: inline;
    }
}
