/* =============================================
   Floating Support Widget
   ============================================= */

.fab-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  left: auto;
  z-index: 9999;
  font-family: 'Vazirmatn', sans-serif;
}

/* --- Toggle Button --- */
.fab-toggle {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--emerald) 0%, #1a6b57 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(31, 122, 99, 0.45);
  transition: background 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  flex-shrink: 0;
}

.fab-toggle:hover {
  transform: scale(1.06);
  box-shadow: 0 8px 28px rgba(31, 122, 99, 0.55);
}

.fab-widget.is-open .fab-toggle {
  background: linear-gradient(135deg, var(--navy) 0%, #122d50 100%);
  box-shadow: 0 6px 24px rgba(11, 31, 58, 0.4);
  transform: rotate(0);
}

.fab-widget.is-open .fab-toggle:hover {
  transform: scale(1.06);
}

.fab-toggle-icon {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.25s ease, transform 0.3s ease;
}

.fab-toggle-icon--open {
  opacity: 1;
  transform: scale(1) rotate(0);
}

.fab-toggle-icon--close {
  opacity: 0;
  transform: scale(0.5) rotate(-90deg);
}

.fab-widget.is-open .fab-toggle-icon--open {
  opacity: 0;
  transform: scale(0.5) rotate(90deg);
}

.fab-widget.is-open .fab-toggle-icon--close {
  opacity: 1;
  transform: scale(1) rotate(0);
}

/* --- Action Menu (buttons + team) --- */
.fab-menu {
  position: absolute;
  bottom: calc(100% + 18px);
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  opacity: 0;
  visibility: hidden;
  transform: translateX(20px);
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s ease, visibility 0.28s ease;
}

.fab-widget.is-open:not(.is-form-open) .fab-menu {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  pointer-events: auto;
}

.fab-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.fab-team {
  width: 148px;
}

.fab-team .team-faces--fab {
  background: #fff;
  border-radius: 14px;
  padding: 10px 8px;
  box-shadow: var(--shadow-md);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-sizing: border-box;
}

.fab-team .team-faces--fab .team-faces-avatars {
  justify-content: stretch;
  width: 100%;
  max-width: 100%;
  padding: 0;
  box-sizing: border-box;
  gap: 0;
  --team-overlap: 8px;
}

.fab-team .team-faces--fab .team-faces-avatar {
  flex: 0 0 calc((100% + 3 * var(--team-overlap, 8px)) / 4);
  min-width: 0;
  width: calc((100% + 3 * var(--team-overlap, 8px)) / 4);
  height: auto;
  aspect-ratio: 1;
  margin-right: calc(-1 * var(--team-overlap, 8px));
  border-width: 2px;
  position: relative;
}

.fab-team .team-faces--fab .team-faces-avatar:nth-child(1) { z-index: 4; }
.fab-team .team-faces--fab .team-faces-avatar:nth-child(2) { z-index: 3; }
.fab-team .team-faces--fab .team-faces-avatar:nth-child(3) { z-index: 2; }
.fab-team .team-faces--fab .team-faces-avatar:nth-child(4) { z-index: 1; }

.fab-team .team-faces--fab .team-faces-avatar:last-child {
  margin-right: 0;
}

.fab-action {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  width: 148px;
  height: 44px;
  padding: 0 14px;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  box-sizing: border-box;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  flex-shrink: 0;
}

.fab-widget.is-open:not(.is-form-open) .fab-action:nth-child(1) { transition-delay: 0.04s; }
.fab-widget.is-open:not(.is-form-open) .fab-action:nth-child(2) { transition-delay: 0.08s; }
.fab-widget.is-open:not(.is-form-open) .fab-action:nth-child(3) { transition-delay: 0.12s; }

.fab-action:hover {
  transform: translateX(-6px);
  box-shadow: var(--shadow-lg);
}

.fab-action--wa   { background: #25D366; }
.fab-action--call { background: var(--navy); }
.fab-action--form { background: var(--gold); color: var(--navy); }

.fab-action-label {
  flex: 1;
  font-size: 13px;
  text-align: right;
  line-height: 1;
}

.fab-action svg {
  flex-shrink: 0;
}

/* --- Form Panel --- */
.fab-panel {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  width: 320px;
  max-width: calc(100vw - 48px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(11, 31, 58, 0.18);
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transform: translateX(20px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s ease, visibility 0.28s ease;
}

.fab-widget.is-form-open .fab-panel {
  opacity: 1;
  visibility: visible;
  transform: translateX(0) scale(1);
  pointer-events: auto;
}

.fab-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.fab-panel-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
}

.fab-panel-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-light);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.fab-panel-close:hover {
  background: var(--border);
}

.fab-panel-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.6;
}

.fab-field {
  margin-bottom: 14px;
}

.fab-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.fab-field .req {
  color: #e53e3e;
}

.fab-field input,
.fab-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background: #fff;
  direction: rtl;
  text-align: right;
  transition: border-color 0.2s, box-shadow 0.2s;
  resize: vertical;
}

.fab-field input[type="tel"],
.fab-field input[type="email"],
.fab-field input[inputmode="tel"] {
  direction: ltr;
  text-align: right;
  unicode-bidi: isolate;
}

.fab-field input:focus,
.fab-field textarea:focus {
  outline: none;
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px rgba(31, 122, 99, 0.12);
}

.fab-field input.error,
.fab-field textarea.error {
  border-color: #e53e3e;
}

.fab-error {
  display: block;
  font-size: 12px;
  color: #e53e3e;
  margin-top: 4px;
  min-height: 16px;
}

.fab-submit {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: var(--emerald);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  margin-top: 4px;
}

.fab-submit:hover:not(:disabled) {
  background: var(--emerald-light);
  transform: translateY(-1px);
}

.fab-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.fab-success {
  text-align: center;
  padding: 16px 8px;
}

.fab-success-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(31, 122, 99, 0.1);
  color: var(--emerald);
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 10px;
}

.fab-success p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* --- Responsive --- */
@media (max-width: 480px) {
  .fab-widget {
    bottom: 16px;
    right: 16px;
  }

  .fab-panel {
    right: 0;
    width: calc(100vw - 32px);
    max-width: calc(100vw - 32px);
  }

  .fab-toggle {
    width: 54px;
    height: 54px;
  }

  .fab-action {
    width: 132px;
    height: 42px;
    padding: 0 12px;
  }

  .fab-action-label {
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fab-action,
  .fab-panel,
  .fab-toggle,
  .fab-toggle-icon,
  .fab-menu,
  .fab-actions {
    animation: none !important;
    transition: none !important;
  }
}
