/*
 * Oto Tuan – Floating Contact Widget
 * Phase 4B | scoped to .ott-contact-* classes only
 * Mobile-first. Brand primary: #e31d1a (red).
 */

/* ── Variables ──────────────────────────────────────────────────── */
.ott-contact-widget {
  --ott-contact-red:        #e31d1a;
  --ott-contact-red-dark:   #c01815;
  --ott-contact-white:      #ffffff;
  --ott-contact-surface:    #ffffff;
  --ott-contact-text:       #1a1a1a;
  --ott-contact-subtext:    #666666;
  --ott-contact-shadow:     0 4px 20px rgba(0, 0, 0, 0.18);
  --ott-contact-radius:     14px;
  --ott-contact-item-h:     52px;
  --ott-contact-launcher-size: 56px;
  --ott-contact-z:          9900;
}

/* ── Widget container ────────────────────────────────────────────── */
.ott-contact-widget {
  position: fixed;
  bottom: 150px;
  right: 10px;
  z-index: var(--ott-contact-z);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  /* prevents accidental layout shift from child transitions */
  contain: layout style;
}

/* ── Expandable menu ─────────────────────────────────────────────── */
.ott-contact-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--ott-contact-surface);
  border-radius: var(--ott-contact-radius);
  padding: 10px;
  box-shadow: var(--ott-contact-shadow);
  min-width: 200px;

  /* Hidden by default */
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  pointer-events: none;
  visibility: hidden;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    visibility 0s linear 0.2s;
  transform-origin: bottom right;
}

/* Open state – driven by JS adding .is-open to .ott-contact-widget */
.ott-contact-widget.is-open .ott-contact-menu {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  visibility: visible;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    visibility 0s linear 0s;
}

/* ── Menu items ──────────────────────────────────────────────────── */
.ott-contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--ott-contact-item-h);
  padding: 8px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--ott-contact-text);
  background: transparent;
  transition: background 0.15s ease;
  cursor: pointer;
}

.ott-contact-item:hover,
.ott-contact-item:focus-visible {
  background: #f5f5f5;
  outline: none;
}

.ott-contact-item:focus-visible {
  box-shadow: 0 0 0 3px rgba(227, 29, 26, 0.35);
}

/* Icon wrapper */
.ott-contact-item__icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ott-contact-red);
  color: var(--ott-contact-white);
}

.ott-contact-item__icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

/* Channel-specific icon tints */
.ott-contact-item--zalo .ott-contact-item__icon {
  background: #0068ff;
}

.ott-contact-item--messenger .ott-contact-item__icon {
  background: #0084ff;
}

/* Label area */
.ott-contact-item__label {
  display: flex;
  flex-direction: column;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ott-contact-text);
}

.ott-contact-item__sub {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--ott-contact-subtext);
  margin-top: 2px;
}

/* ── Launcher button ─────────────────────────────────────────────── */
.ott-contact-launcher {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--ott-contact-launcher-size);
  padding: 0 18px;
  border: none;
  border-radius: 28px;
  background: var(--ott-contact-red);
  color: var(--ott-contact-white);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(227, 29, 26, 0.45);
  transition:
    background 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.15s ease;
  /* ensure consistent font rendering */
  font-family: inherit;
  line-height: 1;
}

.ott-contact-launcher:hover {
  background: var(--ott-contact-red-dark);
  box-shadow: 0 6px 20px rgba(227, 29, 26, 0.55);
}

.ott-contact-launcher:active {
  transform: scale(0.97);
}

.ott-contact-launcher:focus-visible {
  outline: 3px solid rgba(227, 29, 26, 0.45);
  outline-offset: 2px;
}

/* Icon sizing inside launcher */
.ott-contact-launcher__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ott-contact-launcher__icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

/* Toggle icons */
.ott-contact-launcher__icon--open {
  display: none;
}

.ott-contact-widget.is-open .ott-contact-launcher__icon--closed {
  display: none;
}

.ott-contact-widget.is-open .ott-contact-launcher__icon--open {
  display: flex;
}

/* ── Mobile adjustments ──────────────────────────────────────────── */
@media (max-width: 767px) {
  .ott-contact-widget {
    /* Nudge up on mobile to avoid overlapping sticky car-search bar.
       Adjust this value if the car-search bar height changes.      */
    bottom: 72px;
    right: 14px;
  }

  .ott-contact-launcher {
    /* Slightly more compact on small screens */
    min-height: 48px;
    padding: 0 14px;
  }

  .ott-contact-menu {
    min-width: 180px;
  }
}

/* ── Reduced motion ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .ott-contact-menu,
  .ott-contact-launcher {
    transition: none;
  }
}
