/* ============================================================
   SUBMIT REFERRAL VIEW
   ============================================================ */
.content-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

/* Subtle top-left glass reflection on content cards */
.content-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.04) 0%,
    rgba(255, 255, 255, 0) 100%
  );
  pointer-events: none;
  z-index: 1;
}

.section-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 2;
}

/* Temperature / Hotness Slider */
.temp-slider-container {
  margin: 16px 0 24px;
}

.temp-bars {
  display: none !important;
}

.temp-selector {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.temp-btn {
  flex: 1;
  background: rgba(15, 23, 42, 0.04);
  border: 2px solid transparent;
  padding: 0;
  height: 18px;
  border-radius: 99px;
  text-indent: -9999px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s ease;
  margin-top: 10px;
}
.temp-btn[data-val="1"] { background-color: #3b82f6 !important; }
.temp-btn[data-val="2"] { background-color: #06b6d4 !important; }
.temp-btn[data-val="3"] { background-color: #fbbf24 !important; }
.temp-btn[data-val="4"] { background-color: #f97316 !important; }
.temp-btn[data-val="5"] { background-color: #ef4444 !important; }

.temp-btn.active {
  border-color: #ffffff !important;
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.6);
  transform: scaleY(1.2);
}

/* ============================================================

   SHOP & ACTIVITY FILTER BAR
   ============================================================ */
.shop-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.shop-filters::-webkit-scrollbar {
  display: none;
}

.shop-filter-btn {
  padding: 7px 14px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.25s var(--ease);
  flex-shrink: 0;
}

.shop-filter-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.shop-filter-btn.active {
  background: rgba(214, 25, 32, 0.12);
  border-color: rgba(214, 25, 32, 0.4);
  color: var(--primary-light);
  box-shadow: 0 0 10px rgba(214, 25, 32, 0.15);
}


/* ============================================================

/* ============================================================
   TOAST NOTIFICATIONS â€” PREMIUM
   ============================================================ */
.toast-container {
  position: fixed;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 90%;
  max-width: 380px;
  pointer-events: none;
}

.toast {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--text-inverse);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5), 0 0 1px rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(-10px);
  animation: toastIn 0.35s var(--ease-out-back) forwards;
  pointer-events: auto;
  position: relative;
  overflow: hidden;
}

/* Progress bar at bottom */
.toast::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 100%;
  animation: toastProgress 4s linear forwards;
}

@keyframes toastProgress {
  from { width: 100%; }
  to { width: 0%; }
}

@keyframes toastIn {
  to { opacity: 1; transform: translateY(0); }
}

.toast.toast-success {
  border-left: 4px solid var(--success);
}
.toast.toast-success::after {
  background: var(--success);
}

.toast.toast-error {
  border-left: 4px solid var(--danger);
}
.toast.toast-error::after {
  background: var(--danger);
}

.toast.toast-info {
  border-left: 4px solid var(--info);
}
.toast.toast-info::after {
  background: var(--info);
}

/* ============================================================

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: safe center;
  justify-content: center;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  box-sizing: border-box;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  max-height: 92vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  box-sizing: border-box;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7), 0 0 40px rgba(214, 25, 32, 0.05);
  transform: scale(0.92) translateY(10px);
  transition: transform 0.35s var(--ease-out-back);
}
.modal-overlay.active .modal-content {
  transform: scale(1) translateY(0);
}

/* CRM Partner Modal — Fix flex layout per desktop */
#modal-partner-crm .btn-primary {
  width: auto;
  flex-shrink: 0;
}
#modal-partner-crm .form-control {
  min-width: 0;
}
#modal-partner-crm select.form-control {
  min-width: 160px;
}
#modal-partner-crm #crm-actions-grid .btn-primary {
  width: 100%;
}


/* ============================================================

/* ============================================================
   ACCORDION STYLES (PROFILO)
   ============================================================ */
.accordion-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  overflow: hidden;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.accordion-item.active {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(214, 25, 32, 0.15), 0 4px 16px rgba(0, 0, 0, 0.2);
}

.accordion-header {
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-weight: 700;
  font-size: 1.05rem;
  background: rgba(255, 255, 255, 0.03);
  user-select: none;
  position: relative;
  transition: background 0.2s ease;
}

.accordion-item.active .accordion-header {
  background: rgba(214, 25, 32, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.accordion-header:hover {
  background: rgba(255, 255, 255, 0.06);
}

.acc-icon {
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--primary-light);
  flex-shrink: 0;
}

.accordion-item.active .acc-icon {
  transform: rotate(180deg);
}

.accordion-content {
  overflow: hidden;
  max-height: 0;
  padding: 0 16px;
  opacity: 0;
  transition: max-height 0.45s ease, padding 0.35s ease, opacity 0.3s ease;
}

.accordion-item.active .accordion-content {
  padding: 16px;
  opacity: 1;
}

/* ============================================================

/* ============================================================
   FAB ADD REFERRAL
   ============================================================ */
.fab-add-referral {
  position: fixed;
  bottom: 85px;
  right: 20px;
  z-index: 900;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  border: none;
  box-shadow: 0 8px 24px rgba(214, 25, 32, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.fab-add-referral:hover {
  transform: scale(1.05) translateY(-2px);
  box-shadow: 0 12px 30px rgba(214, 25, 32, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.fab-add-referral:active {
  transform: scale(0.95);
}

@keyframes popInList {
  0% { opacity: 0; transform: translateY(20px) scale(0.9); }
  50% { transform: translateY(-5px) scale(1.02); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.animated-list-item {
  animation: popInList 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  opacity: 0;
}



/* ============================================================
   AGENT CARDS — Consulente Assegnato (Client Profile)
   ============================================================ */
.agent-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  padding: 4px;
}

@media (max-width: 480px) {
  .agent-cards-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    padding: 0;
  }
  .agent-card {
    flex: 1 1 calc(50% - 4px);
    max-width: calc(50% - 4px);
    min-width: 0;
    padding: 14px 6px 12px !important;
    box-sizing: border-box;
    overflow: hidden;
  }
  .agent-card-name {
    font-size: 0.82rem !important;
    word-break: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .agent-card-avatar {
    width: 56px !important;
    height: 56px !important;
  }
}

.agent-card {
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md, 14px);
  padding: 20px 12px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.agent-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 60px;
  background: linear-gradient(135deg, rgba(214, 25, 32, 0.12), rgba(214, 25, 32, 0.03));
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.agent-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.agent-card:active {
  transform: translateY(0) scale(0.97);
}

.agent-card.selected {
  border-color: var(--primary, #d61920);
  background: rgba(214, 25, 32, 0.1);
  box-shadow: 0 0 0 1px rgba(214, 25, 32, 0.25), 0 4px 16px rgba(214, 25, 32, 0.15);
}

.agent-card.selected::before {
  background: linear-gradient(135deg, rgba(214, 25, 32, 0.2), rgba(214, 25, 32, 0.06));
}

.agent-card-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: #cc0000;
  margin: 0 auto 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  border: 3px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.agent-card.selected .agent-card-avatar {
  border-color: var(--primary, #d61920);
  box-shadow: 0 4px 16px rgba(214, 25, 32, 0.3);
}

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

.agent-card-avatar .agent-initials {
  color: #fff;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -1px;
}

.agent-card-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
  margin-bottom: 6px;
  position: relative;
  z-index: 1;
}

.agent-card-role {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  position: relative;
  z-index: 1;
  letter-spacing: 0.3px;
}

.agent-card-role.role-admin {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.2), rgba(234, 179, 8, 0.08));
  color: #fbbf24;
  border: 1px solid rgba(234, 179, 8, 0.25);
}

.agent-card-role.role-agent {
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.15), rgba(96, 165, 250, 0.05));
  color: #93c5fd;
  border: 1px solid rgba(96, 165, 250, 0.2);
}

.agent-card-info-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--text-light, #94a3b8);
  margin-top: 10px;
  opacity: 0.6;
  transition: opacity 0.2s;
  position: relative;
  z-index: 1;
}

.agent-card:hover .agent-card-info-hint {
  opacity: 1;
  color: var(--primary-light, #ff616b);
}

/* Selected checkmark */
.agent-card-check {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary, #d61920);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.2s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 2;
}

.agent-card.selected .agent-card-check {
  opacity: 1;
  transform: scale(1);
}

.agent-card-check svg {
  width: 12px;
  height: 12px;
  stroke: #fff;
  stroke-width: 3;
  fill: none;
}

/* ============================================================
   CONTACT PREFERENCES TOGGLE (Staff Profile)
   ============================================================ */
.contact-pref-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.contact-pref-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm, 8px);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.contact-pref-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}

.contact-pref-toggle input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.contact-pref-toggle input[type="checkbox"]:checked {
  background: var(--primary, #d61920);
  border-color: var(--primary, #d61920);
}

.contact-pref-toggle input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 900;
}

.contact-pref-toggle:has(input:checked) {
  border-color: rgba(214, 25, 32, 0.3);
  background: rgba(214, 25, 32, 0.08);
}

.contact-pref-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
}

/* ============================================================
   AGENT DETAIL MODAL — Mini Scheda Tecnica
   ============================================================ */
.modal-agent-detail .modal-content {
  max-width: 380px;
  max-height: 90dvh;
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: #0d1525;
}

.agent-modal-header {
  position: relative;
  padding: 32px 24px 20px;
  text-align: center;
  background: linear-gradient(180deg, rgba(214, 25, 32, 0.15) 0%, rgba(214, 25, 32, 0.02) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.agent-modal-header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(214, 25, 32, 0.1), transparent 70%);
  pointer-events: none;
}

.agent-modal-avatar {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: #cc0000;
  margin: 0 auto 14px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 40px rgba(214, 25, 32, 0.1);
  position: relative;
  z-index: 1;
}

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

.agent-modal-avatar .agent-initials {
  color: #fff;
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -1px;
}

.agent-modal-name {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 6px;
  position: relative;
  z-index: 1;
}

.agent-modal-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 4px 14px;
  border-radius: 20px;
  position: relative;
  z-index: 1;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.agent-modal-role-badge.role-admin {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.25), rgba(234, 179, 8, 0.1));
  color: #fbbf24;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.agent-modal-role-badge.role-agent {
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.2), rgba(96, 165, 250, 0.08));
  color: #93c5fd;
  border: 1px solid rgba(96, 165, 250, 0.25);
}

.agent-modal-body {
  padding: 20px 24px 24px;
}

.agent-modal-info-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.agent-modal-info-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.agent-modal-info-row:last-child {
  border-bottom: none;
}

.agent-modal-info-icon {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--primary-light, #ff616b);
}

.agent-modal-info-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-light, #94a3b8);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.agent-modal-info-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
}

.agent-modal-info-value a {
  color: var(--primary-light, #ff616b);
  text-decoration: none;
  transition: opacity 0.2s;
}

.agent-modal-info-value a:hover {
  opacity: 0.8;
}

.agent-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.agent-modal-actions .btn-agent-action {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm, 10px);
  font-size: 0.92rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.agent-modal-actions .btn-agent-call {
  background: var(--primary, #d61920);
  color: #fff;
}

.agent-modal-actions .btn-agent-call:hover {
  background: #b71418;
  box-shadow: 0 4px 14px rgba(214, 25, 32, 0.3);
}

.agent-modal-actions .btn-agent-wa {
  background: #25D366;
  color: #fff;
}

.agent-modal-actions .btn-agent-wa:hover {
  background: #1fb855;
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.3);
}

.agent-modal-actions .btn-agent-tg {
  background: #0088cc;
  color: #fff;
}

.agent-modal-actions .btn-agent-tg:hover {
  background: #0077b3;
  box-shadow: 0 4px 14px rgba(0, 136, 204, 0.3);
}

.agent-modal-actions .btn-agent-email {
  background: rgba(148, 163, 184, 0.2);
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.agent-modal-actions .btn-agent-email:hover {
  background: rgba(148, 163, 184, 0.3);
  box-shadow: 0 4px 14px rgba(148, 163, 184, 0.2);
}

.agent-modal-footer {
  padding: 0 24px 20px;
  text-align: center;
}

.agent-modal-footer .btn-select-agent {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: var(--radius-sm, 10px);
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  background: linear-gradient(135deg, var(--primary, #d61920), #b71418);
  color: #fff;
  box-shadow: 0 4px 16px rgba(214, 25, 32, 0.25);
}

.agent-modal-footer .btn-select-agent:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(214, 25, 32, 0.35);
}

.agent-modal-footer .btn-select-agent.already-selected {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
  box-shadow: none;
  cursor: default;
}

.agent-modal-close {
  position: sticky;
  top: 10px;
  float: right;
  margin: 10px 10px -40px 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  z-index: 10;
}

.agent-modal-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

.agent-modal-close svg {
  width: 18px;
  height: 18px;
  stroke: #fff;
  stroke-width: 2.5;
  fill: none;
}

/* Stagger animation for agent cards */
@keyframes agentCardIn {
  0% { opacity: 0; transform: translateY(16px) scale(0.95); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.agent-card {
  animation: agentCardIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  opacity: 0;
}

/* ============================================================
   REFERRAL TYPE SEGMENTED TOGGLE (Vendita / Affitto / Affitto · Vendita)
   ============================================================ */
.ref-type-toggle-group {
  display: grid;
  grid-template-columns: 1fr 1fr 1.35fr;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm, 12px);
  padding: 0;
  gap: 10px;
  min-height: 54px;
  align-items: stretch;
  margin-top: 6px;
}
.ref-type-pill {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm, 12px);
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  color: var(--text-light, #94a3b8);
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
  user-select: none;
}
.ref-type-pill:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
  transform: translateY(-1px);
}
.ref-type-pill.active {
  background: linear-gradient(135deg, var(--primary, #d61920), hsl(358, 85%, 38%));
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 4px 16px rgba(214, 25, 32, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: none;
}
.ref-type-pill .type-icon {
  font-size: 1.2rem;
  line-height: 1;
}
@media (max-width: 440px) {
  .ref-type-toggle-group {
    min-height: 50px;
    gap: 6px;
  }
  .ref-type-pill {
    font-size: 0.84rem;
    gap: 5px;
    padding: 8px 6px;
  }
  .ref-type-pill .type-icon {
    font-size: 1.05rem;
  }
}

/* ============================================================
   GAMIFICATION ACCORDIONS (ADMIN PUNTI E LIVELLI)
   ============================================================ */
.gamif-accordion-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}

.gamif-accordion-item {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  overflow: clip;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
  backdrop-filter: blur(8px);
}

.gamif-accordion-item:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

.gamif-accordion-item.active {
  background: rgba(255, 255, 255, 0.035);
  border-color: rgba(214, 25, 32, 0.35);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(214, 25, 32, 0.15);
}

.gamif-accordion-header {
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  gap: 14px;
  background: rgba(255, 255, 255, 0.015);
  transition: background 0.2s ease;
}

.gamif-accordion-header:hover {
  background: rgba(255, 255, 255, 0.04);
}

.gamif-accordion-item.active .gamif-accordion-header {
  background: rgba(214, 25, 32, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.gamif-acc-header-info {
  flex: 1;
  min-width: 0;
}

.gamif-acc-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.gamif-acc-title {
  font-size: 1.08rem;
  font-weight: 700;
  margin: 0;
  color: #fff;
  letter-spacing: -0.01em;
}

.gamif-acc-subtitle {
  font-size: 0.84rem;
  color: var(--text-light, #94a3b8);
  margin: 4px 0 0 0;
  line-height: 1.45;
}

.gamif-acc-chevron {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light, #94a3b8);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s, color 0.2s;
  flex-shrink: 0;
}

.gamif-accordion-item.active .gamif-acc-chevron {
  transform: rotate(180deg);
  color: #fff;
  background: rgba(214, 25, 32, 0.25);
}

/* Status Pill in Header */
.gamif-status-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  transition: all 0.25s ease;
}

.gamif-status-pill .pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.gamif-status-pill.pill-active {
  background: rgba(34, 197, 94, 0.12);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.gamif-status-pill.pill-active .pill-dot {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.8);
}

.gamif-status-pill.pill-inactive {
  background: rgba(255, 255, 255, 0.05);
  color: #94a3b8;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.gamif-status-pill.pill-inactive .pill-dot {
  background: #64748b;
}

/* Collapsible Body */
.gamif-accordion-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.gamif-accordion-item.active .gamif-accordion-body {
  grid-template-rows: 1fr;
}

.gamif-accordion-inner {
  overflow: hidden;
  padding: 0 18px;
  transition: padding 0.35s ease;
}

.gamif-accordion-item.active .gamif-accordion-inner {
  padding: 16px 18px 20px;
  overflow: visible;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Scrollable containers for actions grid and tiers on mobile */
#gamif-actions-container,
#gamif-tiers-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}

#gamif-actions-container > div:first-child {
  min-width: 600px;
}

/* Status Control Bar Inside Accordion */
.gamif-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  margin-bottom: 16px;
}

.gamif-status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gamif-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  transition: all 0.25s ease;
}

.gamif-status-indicator.active .gamif-status-dot {
  background: #22c55e;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.7);
}

.gamif-status-indicator.inactive .gamif-status-dot {
  background: #64748b;
  box-shadow: none;
}

.gamif-status-text {
  font-size: 0.9rem;
  font-weight: 700;
  transition: color 0.25s ease;
}

.gamif-status-indicator.active .gamif-status-text {
  color: #4ade80;
}

.gamif-status-indicator.inactive .gamif-status-text {
  color: #94a3b8;
}

/* Toggle Switch Button */
.gamif-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
}

.gamif-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.22);
}

.gamif-toggle-switch {
  width: 38px;
  height: 22px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.16);
  position: relative;
  display: inline-block;
  transition: background 0.25s ease;
  flex-shrink: 0;
}

.gamif-toggle-knob {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.gamif-toggle-btn.active .gamif-toggle-switch {
  background: linear-gradient(135deg, #16a34a, #22c55e);
}

.gamif-toggle-btn.active .gamif-toggle-knob {
  transform: translateX(16px);
}

.gamif-toggle-btn-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #e2e8f0;
}

.gamif-toggle-btn.active .gamif-toggle-btn-label {
  color: #ffffff;
}

.gamif-module-content {
  transition: opacity 0.25s ease;
}

/* Progression Type Selector (Points vs Actions) */
.gamif-type-pill {
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-light, #94a3b8);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.gamif-type-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.22);
}

.gamif-type-pill.active {
  background: linear-gradient(135deg, var(--primary, #d61920) 0%, hsl(358, 85%, 38%) 100%);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(214, 25, 32, 0.35);
}

/* Month Selector Pills & Preset Buttons for Prize Rules */
.gamif-month-pill {
  padding: 8px 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.gamif-month-pill:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}

.gamif-month-pill.active {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #0b0f19;
  font-weight: 700;
  border-color: #fbbf24;
  box-shadow: 0 3px 12px rgba(245, 158, 11, 0.35);
}

.gamif-preset-btn {
  padding: 5px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-light, #94a3b8);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.gamif-preset-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.gamif-preset-btn.active {
  background: rgba(245, 158, 11, 0.15);
  border-color: #f59e0b;
  color: #fbbf24;
}


/* Action Check Item for Tier Progression */
.gamif-action-check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
}

.gamif-action-check-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.15);
}

.gamif-action-check-item.checked {
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.3);
}

.gamif-action-check-custom {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.gamif-action-check-item.checked .gamif-action-check-custom {
  background: #22c55e;
  border-color: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.gamif-action-check-item.checked .gamif-action-check-custom::after {
  content: "✓";
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
}

/* Prize Emoji Picker */
.prz-emoji-btn {
  width: 40px;
  height: 40px;
  font-size: 1.35rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  user-select: none;
}
.prz-emoji-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.28);
  transform: scale(1.1);
}
.prz-emoji-btn.active {
  border-color: #3b82f6 !important;
  background: rgba(59, 130, 246, 0.25) !important;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.45) !important;
  transform: scale(1.05);
}
#prz-emoji-trigger:hover {
  background: rgba(255, 255, 255, 0.09) !important;
  border-color: rgba(255, 255, 255, 0.28) !important;
}

@media (max-width: 540px) {
  .prize-dati-base-grid {
    grid-template-columns: 80px 1fr !important;
  }
  .prize-dati-base-grid .form-group-valore {
    grid-column: 1 / -1;
  }
}

/* Livelli (tier): percorso sempre visibile durante lo scroll.
   Sticky richiede che nessun antenato sia un contenitore di scroll, quindi per questo accordion
   si disattiva overflow auto/hidden sull'area interna e sul contenitore dei livelli. */
#gamif-acc-tiers.active .gamif-accordion-inner {
  overflow: visible;
}
#gamif-acc-tiers #gamif-tiers-container {
  overflow: visible;
}
.gamif-tier-track-wrap {
  position: sticky;
  top: 78px;
  z-index: 20;
  margin: 0 -6px 12px;
  padding: 8px 6px 10px;
  background: #0d1426;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 18px -12px rgba(0, 0, 0, 0.7);
}
/* Punti per azione: schede con intestazione livelli sempre visibile (sticky) */
#gamif-acc-actions.active .gamif-accordion-inner {
  overflow: visible;
}
#gamif-acc-actions #gamif-actions-container {
  overflow: visible !important;
  container-type: inline-size;
  container-name: gamif-actions;
}
.gamif-pts-head {
  position: sticky;
  top: 78px;
  z-index: 20;
  margin: 0 0 12px;
  padding: 8px 15px 10px;
  background: #0d1426;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  box-shadow: 0 10px 18px -12px rgba(0, 0, 0, 0.7);
}
.gamif-pts-head-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 6px;
}
.gamif-pts-cols {
  display: grid;
  grid-template-columns: repeat(var(--tc, 1), minmax(0, 1fr));
  gap: 6px;
}
.gamif-action-tier-head {
  font-weight: 700;
  font-size: 0.8rem;
  text-align: center;
  color: #fff;
  padding: 6px 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
  text-overflow: ellipsis;
}
.gamif-action-tier-head.is-new {
  background: rgba(250, 204, 21, 0.18);
  border: 1px solid rgba(250, 204, 21, 0.6);
}
.gamif-new-flag {
  font-size: 0.64rem;
  color: #fde047;
  font-weight: 700;
}
.gamif-action-card {
  padding: 14px;
  margin-bottom: 14px;
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.gamif-action-card.is-dragging {
  opacity: 0.45;
  border-color: #facc15;
  box-shadow: 0 12px 28px rgba(250, 204, 21, 0.25);
}
.gamif-action-card.is-drag-over {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
}
.gamif-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 38px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  cursor: grab;
  touch-action: none;
  user-select: none;
  flex-shrink: 0;
}
.gamif-drag-handle:active {
  cursor: grabbing;
  color: #facc15;
  border-color: #facc15;
}
.gamif-action-arrows {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}
.gamif-move-action-btn {
  width: 34px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: #facc15;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 800;
  transition: all 0.15s;
}
.gamif-move-action-btn:hover:not(:disabled) {
  background: rgba(250, 204, 21, 0.15);
  border-color: #facc15;
}
.gamif-move-action-btn:disabled {
  color: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.08);
  cursor: not-allowed;
}

/* Visibilità reattiva: Maniglia su Mobile (< 768px), Freccette su Desktop (>= 768px) */
@media (max-width: 767px) {
  .gamif-desktop-only {
    display: none !important;
  }
  .gamif-mobile-only {
    display: flex !important;
  }
}
@media (min-width: 768px) {
  .gamif-desktop-only {
    display: flex !important;
  }
  .gamif-mobile-only {
    display: none !important;
  }
}
.gamif-pts-row {
  margin-top: 12px;
}
/* Sfondo piu' scuro dietro le schede (livelli e punti per azione), cosi' si staccano meglio */
#gamif-acc-tiers .gamif-accordion-inner,
#gamif-acc-actions .gamif-accordion-inner {
  background: rgba(0, 0, 0, 0.3);
}
.gamif-pts-cell-label {
  display: none;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-light);
  text-align: center;
  margin-bottom: 3px;
}
/* Spazio stretto: niente intestazione fissa, ogni cella porta il nome del suo livello */
@container gamif-actions (max-width: 680px) {
  .gamif-pts-head {
    display: none;
  }
  .gamif-pts-cols.gamif-pts-row {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  }
  .gamif-pts-cell-label {
    display: block;
  }
  /* Vendita, Affitto, Entrambe: tre pulsanti sulla stessa riga */
  .gamif-reqtype-group {
    width: 100%;
    flex-wrap: nowrap !important;
  }
  .gamif-reqtype-btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 6px 4px !important;
    gap: 4px !important;
    font-size: 0.78rem !important;
  }
}
/* Il contenuto di un accordion non deve mai allargare la pagina (mobile) */
.gamif-accordion-body {
  grid-template-columns: minmax(0, 1fr);
}
.gamif-accordion-inner {
  min-width: 0;
}

/* Mobile: livelli e punti per azione */
@media (max-width: 560px) {
  .gamif-accordion-item.active .gamif-accordion-inner {
    padding: 12px 8px 16px;
  }
  .gamif-tier-row {
    padding: 10px !important;
  }
  .gamif-tier-initial {
    display: none;
  }
  .gamif-seg {
    flex: 1 1 0 !important;
  }
  .gamif-seg-name {
    font-size: 0.66rem !important;
  }
  .gamif-action-card {
    padding: 10px;
  }
  .gamif-reqtype-btn {
    flex-direction: column !important;
    gap: 2px !important;
    min-height: 52px !important;
    line-height: 1.1;
    overflow: hidden;
  }
}
/* Campi numerici di livelli e punti: dimensione media, uniforme, con unita' dentro al campo */
.gamif-field {
  display: flex;
  align-items: stretch;
  min-height: 46px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.gamif-field:hover {
  border-color: rgba(255, 255, 255, 0.4);
}
.gamif-field:focus-within {
  border-color: #facc15;
  box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.2);
  background: rgba(255, 255, 255, 0.11);
}
.gamif-field > input[type="number"] {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  height: 46px;
  box-sizing: border-box;
  margin: 0;
  padding: 0 8px;
  background: transparent;
  border: 0;
  border-radius: 0;
  outline: 0;
  box-shadow: none;
  color: #fff;
  font-size: 1.15rem;
  font-weight: 800;
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}
.gamif-field-unit {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 1 auto;
  max-width: 48%;
  padding: 0 12px;
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  color: var(--text-light);
  background: rgba(0, 0, 0, 0.28);
  border-left: 1px solid rgba(255, 255, 255, 0.12);
}
.gamif-field-static {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
}
.gamif-field.is-static {
  background: rgba(255, 255, 255, 0.04);
  border-style: dashed;
}
input.gamif-pts-input[type="number"] {
  width: 100%;
  height: 46px;
  box-sizing: border-box;
  margin: 0;
  padding: 0 6px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 12px;
  outline: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  -moz-appearance: textfield;
  appearance: textfield;
}
input.gamif-pts-input[type="number"]:hover {
  border-color: rgba(255, 255, 255, 0.4);
}
input.gamif-pts-input[type="number"]:focus {
  border-color: #facc15;
  box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.2);
  background: rgba(255, 255, 255, 0.11);
}
.gamif-field > input[type="number"]::-webkit-outer-spin-button,
.gamif-field > input[type="number"]::-webkit-inner-spin-button,
input.gamif-pts-input[type="number"]::-webkit-outer-spin-button,
input.gamif-pts-input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}