/**
 * Nützlicher WhatsApp-Floating Button — Frontend
 */

.nwfb-root {
  --nwfb-bg: #25D366;
  --nwfb-bg-hover: #1EBE57;
  --nwfb-fg: #ffffff;
  --nwfb-label-bg: #ffffff;
  --nwfb-label-fg: #1f2937;
  --nwfb-size: 60px;
  --nwfb-radius: 50%;
  --nwfb-offset-x: 24px;
  --nwfb-offset-y: 24px;
  --nwfb-offset-x-mobile: 16px;
  --nwfb-offset-y-mobile: 16px;
  --nwfb-z: 9999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  line-height: 1.4;
  box-sizing: border-box;
}

.nwfb-root *,
.nwfb-root *::before,
.nwfb-root *::after {
  box-sizing: border-box;
}

.nwfb-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Floating positioning */
.nwfb-floating {
  position: fixed;
  z-index: var(--nwfb-z);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease;
  transform: translateY(8px);
}

.nwfb-floating.nwfb-is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.nwfb-floating[hidden] {
  display: none !important;
}

.nwfb-floating.nwfb-is-visible[hidden] {
  display: flex !important;
}

.nwfb-pos-bottom-right { right: var(--nwfb-offset-x); bottom: var(--nwfb-offset-y); left: auto; top: auto; }
.nwfb-pos-bottom-left  { left: var(--nwfb-offset-x); bottom: var(--nwfb-offset-y); right: auto; top: auto; align-items: flex-start; }
.nwfb-pos-top-right    { right: var(--nwfb-offset-x); top: var(--nwfb-offset-y); left: auto; bottom: auto; }
.nwfb-pos-top-left     { left: var(--nwfb-offset-x); top: var(--nwfb-offset-y); right: auto; bottom: auto; align-items: flex-start; }
.nwfb-pos-middle-right { right: var(--nwfb-offset-x); top: 50%; left: auto; bottom: auto; transform: translateY(-50%); }
.nwfb-pos-middle-left  { left: var(--nwfb-offset-x); top: 50%; right: auto; bottom: auto; align-items: flex-start; transform: translateY(-50%); }

.nwfb-pos-middle-right.nwfb-is-visible,
.nwfb-pos-middle-left.nwfb-is-visible {
  transform: translateY(-50%);
}

/* Device targeting via CSS (cache-safe) */
@media (max-width: 781px) {
  .nwfb-device-desktop.nwfb-floating { display: none !important; }
  .nwfb-pos-bottom-right,
  .nwfb-pos-top-right,
  .nwfb-pos-middle-right { right: var(--nwfb-offset-x-mobile); }
  .nwfb-pos-bottom-left,
  .nwfb-pos-top-left,
  .nwfb-pos-middle-left { left: var(--nwfb-offset-x-mobile); }
  .nwfb-pos-bottom-right,
  .nwfb-pos-bottom-left { bottom: var(--nwfb-offset-y-mobile); }
  .nwfb-pos-top-right,
  .nwfb-pos-top-left { top: var(--nwfb-offset-y-mobile); }
}

@media (min-width: 782px) {
  .nwfb-device-mobile.nwfb-floating { display: none !important; }
}

/* Inline shortcode */
.nwfb-inline {
  position: relative;
  display: inline-flex;
  align-items: center;
  z-index: auto;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
}

.nwfb-inline[hidden] {
  display: inline-flex !important;
}

/* FAB */
.nwfb-fab {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--nwfb-size);
  height: var(--nwfb-size);
  border-radius: var(--nwfb-radius);
  background: var(--nwfb-bg);
  color: var(--nwfb-fg);
  border: none;
  cursor: pointer;
  text-decoration: none !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  padding: 0;
  flex-shrink: 0;
  outline: none;
}

.nwfb-fab:hover,
.nwfb-fab:focus-visible {
  background: var(--nwfb-bg-hover);
  color: var(--nwfb-fg);
  transform: scale(1.05);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  text-decoration: none !important;
}

.nwfb-fab:focus-visible {
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.45), 0 6px 18px rgba(0, 0, 0, 0.28);
}

.nwfb-icon {
  width: calc(var(--nwfb-size) * 0.48);
  height: calc(var(--nwfb-size) * 0.48);
  display: block;
  color: inherit;
  fill: currentColor;
  pointer-events: none;
}

.nwfb-icon-sm {
  width: 20px;
  height: 20px;
}

/* Label pill */
.nwfb-label {
  position: absolute;
  top: 50%;
  white-space: nowrap;
  background: var(--nwfb-label-bg);
  color: var(--nwfb-label-fg);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  pointer-events: none;
  opacity: 0;
  transform: translateY(-50%) scale(0.96);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.nwfb-label::before {
  content: "";
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  background: var(--nwfb-label-bg);
  transform: translateY(-50%) rotate(45deg);
  box-shadow: -1px 1px 2px rgba(0, 0, 0, 0.06);
}

/* Label on the left of button (right-side positions) */
.nwfb-pos-bottom-right .nwfb-label,
.nwfb-pos-top-right .nwfb-label,
.nwfb-pos-middle-right .nwfb-label {
  right: calc(100% + 12px);
  left: auto;
}
.nwfb-pos-bottom-right .nwfb-label::before,
.nwfb-pos-top-right .nwfb-label::before,
.nwfb-pos-middle-right .nwfb-label::before {
  right: -3px;
  left: auto;
}

/* Label on the right of button (left-side positions) — matches screenshot 2 */
.nwfb-pos-bottom-left .nwfb-label,
.nwfb-pos-top-left .nwfb-label,
.nwfb-pos-middle-left .nwfb-label,
.nwfb-inline .nwfb-label {
  left: calc(100% + 12px);
  right: auto;
}
.nwfb-pos-bottom-left .nwfb-label::before,
.nwfb-pos-top-left .nwfb-label::before,
.nwfb-pos-middle-left .nwfb-label::before,
.nwfb-inline .nwfb-label::before {
  left: -3px;
  right: auto;
}

.nwfb-label-always .nwfb-label,
.nwfb-label-hover .nwfb-fab:hover .nwfb-label,
.nwfb-label-hover .nwfb-fab:focus-visible .nwfb-label {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

.nwfb-label-none .nwfb-label {
  display: none;
}

/* Teaser */
.nwfb-teaser {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 240px;
  background: #fff;
  color: #1f2937;
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
  font-size: 14px;
}

.nwfb-teaser[hidden] {
  display: none !important;
}

.nwfb-teaser-close {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: #9ca3af;
  padding: 0;
  margin: -2px -2px 0 0;
}

.nwfb-teaser-close:hover {
  color: #374151;
}

/* Panel */
.nwfb-panel {
  width: min(320px, calc(100vw - 32px));
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  order: -1;
}

.nwfb-panel[hidden] {
  display: none !important;
}

.nwfb-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 14px;
  background: var(--nwfb-bg);
  color: var(--nwfb-fg);
}

.nwfb-panel-greeting {
  display: block;
  font-size: 16px;
  font-weight: 600;
}

.nwfb-panel-subtitle {
  display: block;
  font-size: 13px;
  opacity: 0.9;
  margin-top: 2px;
}

.nwfb-panel-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: inherit;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.nwfb-panel-close:hover {
  background: rgba(255, 255, 255, 0.35);
}

.nwfb-panel-body {
  padding: 14px;
}

.nwfb-offline-note {
  margin: 0 0 12px;
  padding: 10px 12px;
  background: #f3f4f6;
  border-radius: 8px;
  font-size: 13px;
  color: #4b5563;
}

.nwfb-offline-note[hidden] {
  display: none !important;
}

.nwfb-agents-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nwfb-agent-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  text-decoration: none !important;
  color: #1f2937 !important;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.nwfb-agent-link:hover,
.nwfb-agent-link:focus-visible {
  background: #f0fdf4;
  border-color: var(--nwfb-bg);
}

.nwfb-agent-avatar {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--nwfb-bg);
  color: var(--nwfb-fg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.nwfb-agent-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.nwfb-agent-status {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9ca3af;
  border: 2px solid #fff;
}

.nwfb-agent-item.is-online .nwfb-agent-status {
  background: #10b981;
}

.nwfb-agent-item.is-offline {
  opacity: 0.55;
}

.nwfb-agent-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.nwfb-agent-name {
  font-weight: 600;
  font-size: 14px;
}

.nwfb-agent-role {
  font-size: 12px;
  color: #6b7280;
}

.nwfb-panel-compose {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nwfb-panel-message {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  resize: vertical;
  min-height: 72px;
  color: #1f2937;
}

.nwfb-panel-message:focus {
  outline: none;
  border-color: var(--nwfb-bg);
  box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.25);
}

.nwfb-panel-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--nwfb-bg);
  color: var(--nwfb-fg) !important;
  text-decoration: none !important;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.2s ease;
}

.nwfb-panel-cta:hover,
.nwfb-panel-cta:focus-visible {
  background: var(--nwfb-bg-hover);
  color: var(--nwfb-fg) !important;
}

/* Animations */
.nwfb-anim-pulse .nwfb-fab::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 0 var(--nwfb-bg);
  animation: nwfb-pulse 2s ease-out infinite;
  pointer-events: none;
  z-index: -1;
}

@keyframes nwfb-pulse {
  0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.55); }
  70% { box-shadow: 0 0 0 16px rgba(37, 211, 102, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}

.nwfb-anim-bounce .nwfb-fab {
  animation: nwfb-bounce 2.2s ease-in-out infinite;
}

@keyframes nwfb-bounce {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
  60% { transform: translateY(-3px); }
}

.nwfb-anim-bounce .nwfb-fab:hover {
  animation: none;
  transform: scale(1.05);
}

.nwfb-anim-shine .nwfb-fab {
  overflow: hidden;
}

.nwfb-anim-shine .nwfb-fab::before {
  content: "";
  position: absolute;
  top: -40%;
  left: -60%;
  width: 40%;
  height: 180%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  transform: rotate(25deg);
  animation: nwfb-shine 3s ease-in-out infinite;
  pointer-events: none;
}

@keyframes nwfb-shine {
  0% { left: -60%; }
  40%, 100% { left: 140%; }
}

@media (prefers-reduced-motion: reduce) {
  .nwfb-anim-pulse .nwfb-fab::after,
  .nwfb-anim-bounce .nwfb-fab,
  .nwfb-anim-shine .nwfb-fab::before {
    animation: none !important;
  }
  .nwfb-floating {
    transition: none;
  }
}

/* Admin preview overrides */
.nwfb-is-preview {
  position: absolute !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transform: none !important;
  z-index: 2 !important;
}

.nwfb-is-preview.nwfb-pos-middle-right,
.nwfb-is-preview.nwfb-pos-middle-left {
  transform: translateY(-50%) !important;
}

.nwfb-is-preview[hidden] {
  display: flex !important;
}
