/* SafeStore WhatsApp Chat widget
   Scoped under .sft-wa — no global selectors, no layout shift (fixed pos). */

.sft-wa {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom, 0px));
  z-index: 99000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

.sft-wa[data-position="right"] { right: max(20px, env(safe-area-inset-right, 0px)); }
.sft-wa[data-position="left"]  { left: max(20px, env(safe-area-inset-left, 0px)); align-items: flex-start; }

/* Floating action button */
.sft-wa__fab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  border-radius: 999px;
  background: #25d366;
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(15, 122, 61, 0.35), 0 2px 6px rgba(15, 23, 42, 0.15);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.sft-wa__fab:hover,
.sft-wa__fab:focus-visible {
  background: #1fb958;
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 10px 24px rgba(15, 122, 61, 0.4), 0 3px 8px rgba(15, 23, 42, 0.18);
  text-decoration: none;
  color: #ffffff;
}

.sft-wa__fab:focus-visible {
  outline: 3px solid #0f7a3d;
  outline-offset: 3px;
}

.sft-wa__fab-icon { width: 30px; height: 30px; }
.sft-wa__fab-icon--close { display: none; width: 24px; height: 24px; }

.sft-wa.is-open .sft-wa__fab-icon--wa { display: none; }
.sft-wa.is-open .sft-wa__fab-icon--close { display: block; }

/* Panel */
.sft-wa__panel {
  width: min(360px, calc(100vw - 40px));
  border-radius: 16px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.22), 0 4px 12px rgba(15, 23, 42, 0.1);
  border: 1px solid #e2e8f0;
  transform-origin: bottom right;
  animation: sft-wa-pop 0.22s ease;
}

.sft-wa[data-position="left"] .sft-wa__panel { transform-origin: bottom left; }

@keyframes sft-wa-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.sft-wa__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #0f7a3d 0%, #0c5f30 100%);
  color: #ffffff;
}

.sft-wa__avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.sft-wa__avatar-icon { width: 24px; height: 24px; }

.sft-wa__dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: #94a3b8;
  border: 2px solid #0f7a3d;
}

.sft-wa.is-online .sft-wa__dot { background: #4ade80; }

.sft-wa__heading { display: flex; flex-direction: column; min-width: 0; }

.sft-wa__title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.sft-wa__status {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
}

.sft-wa__close {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.sft-wa__close:hover,
.sft-wa__close:focus-visible { background: rgba(255, 255, 255, 0.24); }
.sft-wa__close:focus-visible { outline: 2px solid #ffffff; outline-offset: 2px; }
.sft-wa__close svg { width: 16px; height: 16px; }

/* Body */
.sft-wa__body {
  padding: 16px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sft-wa__bubble {
  margin: 0;
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 4px 14px 14px 14px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #111827;
  font-size: 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.sft-wa__hours {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: #475569;
}

.sft-wa__hours svg { width: 15px; height: 15px; flex: 0 0 auto; color: #0f7a3d; }

.sft-wa__offline-note {
  margin: 0;
  padding: 9px 12px;
  border-radius: 10px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 12.5px;
}

/* Footer / CTA */
.sft-wa__footer { padding: 14px 16px; background: #ffffff; border-top: 1px solid #eef2f7; }

.sft-wa__start {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  background: #25d366;
  color: #ffffff;
  font-size: 14.5px;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.sft-wa__start:hover,
.sft-wa__start:focus-visible {
  background: #1fb958;
  color: #ffffff;
  text-decoration: none;
  transform: translateY(-1px);
}

.sft-wa__start:focus-visible { outline: 3px solid #0f7a3d; outline-offset: 2px; }
.sft-wa__start-icon { width: 19px; height: 19px; }

/* Mobile */
@media (max-width: 640px) {
  .sft-wa { bottom: max(16px, env(safe-area-inset-bottom, 0px)); gap: 10px; }
  .sft-wa[data-position="right"] { right: 16px; }
  .sft-wa[data-position="left"]  { left: 16px; }
  .sft-wa__fab { width: 54px; height: 54px; }
  .sft-wa__fab-icon { width: 28px; height: 28px; }
  .sft-wa__panel { width: calc(100vw - 32px); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .sft-wa__panel { animation: none; }
  .sft-wa__fab,
  .sft-wa__start { transition: none; }
  .sft-wa__fab:hover,
  .sft-wa__fab:focus-visible,
  .sft-wa__start:hover { transform: none; }
}

/* Keep clear of typical cookie bars / bottom UI on small screens if another
   fixed element registers itself via --sft-wa-offset on :root. */
:root { --sft-wa-offset: 0px; }
.sft-wa { margin-bottom: var(--sft-wa-offset); }

@media print {
  .sft-wa { display: none !important; }
}
