/* ReClub CSS Design System - Premium Light Real Estate Boutique */

:root {
  --bg-app: #fcfbfa; /* Warm premium off-white/cream */
  --bg-surface: rgba(255, 255, 255, 0.85); /* Translucent white */
  --bg-surface-solid: #ffffff; /* Solid white for cards */
  --primary: #0c2340; /* Deep Navy Blue for trust & authority */
  --primary-hover: #14355e;
  --primary-glow: rgba(12, 35, 64, 0.08);
  --success: #1d9c4c; /* Trust Green for WhatsApp and cash payouts */
  --success-glow: rgba(29, 156, 76, 0.08);
  --warning: #c5a059; /* Warm Bronze/Gold representing prestige and rewards */
  --warning-glow: rgba(197, 160, 89, 0.12);
  --danger: #d93838;
  --danger-glow: rgba(217, 56, 56, 0.08);
  --info: #0ea5e9;
  --info-glow: rgba(14, 165, 233, 0.12);
  --border: rgba(12, 35, 64, 0.08); /* Soft navy-tinted border */
  --border-focus: rgba(12, 35, 64, 0.25);
  --text: #1e293b; /* Dark charcoal for body text */
  --text-muted: #576575; /* Slate grey for secondary text */
  --text-dark: #0c2340;
  --shadow: rgba(12, 35, 64, 0.03);
  --font-title: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: #f6f5f2; /* Soft grey-beige screen surround */
  font-family: var(--font-body);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

/* Container di App (Simulazione telefono su Desktop) */
.app-container {
  width: 100%;
  max-width: 480px; /* Layout mobile-first */
  background-color: var(--bg-app);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  box-shadow: 0 10px 50px rgba(12, 35, 64, 0.06);
}

/* Header dell'App */
.app-header {
  height: 64px;
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  width: 24px;
  height: 24px;
  color: var(--primary);
}

.logo-text {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.5px;
  color: var(--primary);
}

.logo-text span {
  color: var(--warning); /* Gold color for 'Club' */
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(12, 35, 64, 0.03);
  padding: 6px 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
}

.user-avatar {
  width: 20px;
  height: 20px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.user-name-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

/* Contenuto Principale */
.app-content {
  flex: 1;
  padding: 24px 20px 100px 20px;
  overflow-y: auto;
}

/* Schermate SPA (Virtual Routing) */
.app-view {
  display: none;
  animation: fadeIn 0.4s ease-out forwards;
}

.app-view.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Titoli delle Viste */
.view-header {
  margin-bottom: 24px;
}

.view-header h1 {
  font-family: var(--font-title);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--primary);
  margin-bottom: 4px;
}

.view-subtitle {
  color: var(--text-muted);
  font-size: 14px;
}

/* Griglia KPI */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.kpi-card:nth-child(1) {
  grid-column: span 2;
}

.kpi-card {
  background: var(--bg-surface-solid);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
  box-shadow: 0 4px 12px var(--shadow);
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: rgba(12, 35, 64, 0.15);
  box-shadow: 0 6px 16px rgba(12, 35, 64, 0.05);
}

.kpi-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 35, 64, 0.03);
  border: 1px solid var(--border);
}

.kpi-card.navy-glow .kpi-icon-wrap { color: var(--primary); background: var(--primary-glow); }
.kpi-card.green-glow .kpi-icon-wrap { color: var(--success); background: var(--success-glow); }
.kpi-card.gold-glow .kpi-icon-wrap { color: var(--warning); background: var(--warning-glow); }

.kpi-card.navy-glow { box-shadow: 0 6px 20px rgba(12, 35, 64, 0.02); }
.kpi-card.green-glow { box-shadow: 0 6px 20px rgba(29, 156, 76, 0.02); }
.kpi-card.gold-glow { box-shadow: 0 6px 20px rgba(197, 160, 89, 0.02); }

.kpi-data {
  display: flex;
  flex-direction: column;
}

.kpi-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.kpi-value {
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

/* Card Sezioni Generiche */
.section-card {
  background: var(--bg-surface-solid);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 4px 12px var(--shadow);
}

.section-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-card h2 {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

/* Bottoni */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 12px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #14355e);
  color: white;
  box-shadow: 0 4px 12px rgba(12, 35, 64, 0.15);
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 16px rgba(12, 35, 64, 0.2);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  background: rgba(12, 35, 64, 0.03);
  border-color: rgba(12, 35, 64, 0.15);
}

.btn-danger {
  background: rgba(217, 56, 56, 0.08);
  color: var(--danger);
  border: 1px solid rgba(217, 56, 56, 0.2);
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 8px;
}

.w-full {
  width: 100%;
}

.btn svg {
  width: 16px;
  height: 16px;
}

/* Form Premium */
.premium-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media(min-width: 400px) {
  .form-row {
    grid-template-columns: 1fr 1fr;
  }
}

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

input[type="text"],
input[type="tel"],
input[type="url"],
select,
textarea {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  transition: var(--transition);
  outline: none;
  box-shadow: inset 0 1px 2px rgba(12, 35, 64, 0.02);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(12, 35, 64, 0.08), inset 0 1px 2px rgba(12, 35, 64, 0.02);
  background: #ffffff;
}

.form-help {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

.form-fieldset {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: rgba(12, 35, 64, 0.01);
}

.form-fieldset legend {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  padding: 0 8px;
  font-family: var(--font-title);
}

/* File Upload & Immagine */
.image-upload-wrapper {
  position: relative;
  width: 100%;
  min-height: 120px;
}

.image-upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
  background: #ffffff;
}

.image-upload-label:hover {
  border-color: var(--primary);
  background: rgba(12, 35, 64, 0.02);
}

.image-upload-label svg {
  width: 32px;
  height: 32px;
  color: var(--text-muted);
}

.image-upload-label span {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}

.image-upload-label small {
  font-size: 11px;
  color: var(--text-muted);
}

#input-photo {
  display: none;
}

#photo-preview-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

#photo-preview-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.btn-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(12, 35, 64, 0.8);
  color: white;
  border: none;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-remove:hover {
  background: var(--danger);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 10px;
}

/* Lista Segnalazioni (Dashboard) */
.leads-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-state {
  text-align: center;
  padding: 30px 20px;
}

.empty-icon-wrap {
  width: 56px;
  height: 56px;
  background: rgba(12, 35, 64, 0.03);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.empty-icon-wrap svg {
  width: 28px;
  height: 28px;
}

.empty-state p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* Card Lead Singola */
.lead-item-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 2px 6px rgba(12, 35, 64, 0.01);
}

.lead-item-card:hover {
  border-color: rgba(12, 35, 64, 0.15);
  background: rgba(12, 35, 64, 0.01);
}

.lead-card-summary {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.lead-info-main {
  flex: 1;
}

.lead-address {
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 2px;
}

.lead-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.lead-status-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: 0.3px;
}

/* Colori Stato */
.badge-bozza { background: rgba(12, 35, 64, 0.05); color: var(--text-muted); }
.badge-offline { background: var(--warning-glow); color: #b0893f; border: 1px solid rgba(197, 160, 89, 0.2); }
.badge-inviato { background: var(--info-glow); color: #0284c7; }
.badge-trattativa { background: rgba(12, 35, 64, 0.08); color: var(--primary); }
.badge-concluso { background: var(--success-glow); color: var(--success); }
.badge-rifiutato { background: var(--danger-glow); color: var(--danger); }

/* Dettagli Espansi Lead */
.lead-card-details {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease-out;
  padding-top: 0;
  border-top: 1px solid transparent;
  margin-top: 0;
}

.lead-item-card.expanded .lead-card-details {
  max-height: 500px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

.details-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  font-size: 13px;
}

@media(min-width: 380px) {
  .details-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.details-img-preview {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.detail-block span {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.detail-block strong {
  color: var(--text);
  font-weight: 500;
}

.detail-span-full {
  grid-column: span 1;
}

@media(min-width: 380px) {
  .detail-span-full {
    grid-column: span 2;
  }
}

.lead-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

/* Navigazione Inferiore (Coerente con lo stile chiaro) */
.app-nav {
  height: 68px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 100;
}

.nav-item {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  transition: var(--transition);
}

.nav-item svg {
  width: 20px;
  height: 20px;
  transition: var(--transition);
  color: var(--text-muted);
}

.nav-item:hover {
  color: var(--primary);
}

.nav-item:hover svg {
  color: var(--primary);
}

.nav-item.active {
  color: var(--warning); /* Gold active accent */
}

.nav-item.active svg {
  transform: translateY(-2px);
  color: var(--warning);
  filter: drop-shadow(0 2px 6px rgba(197, 160, 89, 0.3));
}

/* Stato Connessione Banner */
#connection-status {
  position: absolute;
  top: 64px;
  left: 0;
  width: 100%;
  height: 24px;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  z-index: 90;
  transition: var(--transition);
  transform: translateY(-100%);
  opacity: 0;
}

#connection-status.offline {
  transform: translateY(0);
  opacity: 1;
  background: #78350f; /* Rust / Orange brown */
  color: #fde68a;
}

#connection-status.online-syncing {
  transform: translateY(0);
  opacity: 1;
  background: #065f46; /* Emerald dark */
  color: #a7f3d0;
}

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

#connection-status.online-syncing .status-dot {
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.3; }
  to { opacity: 1; }
}

/* Generatore QR & Totem Flyer */
.totem-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.preview-card {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.totem-printable-container {
  width: 100%;
  max-width: 320px;
  background: linear-gradient(135deg, #0c2340 0%, #142844 100%); /* Deep Navy Luxury Background */
  border-radius: 20px;
  padding: 30px 20px;
  border: 2px solid var(--warning); /* Gold Border for Prestige */
  box-shadow: 0 15px 35px rgba(12, 35, 64, 0.2);
  text-align: center;
  overflow: hidden;
}

.totem-flyer {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.flyer-header h3 {
  font-family: var(--font-title);
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(135deg, #ffffff 30%, #f3e5c8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

.flyer-header p {
  font-size: 13px;
  color: #94a3b8;
}

.flyer-header strong {
  color: var(--warning); /* Gold price */
  font-size: 20px;
  font-weight: 800;
  display: block;
  margin-top: 4px;
}

.flyer-qr-wrapper {
  background: white;
  padding: 16px;
  border-radius: 16px;
  width: 170px;
  height: 170px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.qr-placeholder {
  font-size: 11px;
  color: #64748b;
  font-weight: 500;
}

#qrcode-display img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.flyer-footer p {
  font-size: 12px;
  color: #94a3b8;
}

.partner-text {
  margin-top: 8px;
  font-size: 11px;
}

.partner-text span {
  color: var(--warning); /* Gold partner name */
  font-weight: 700;
}

/* Stili Utility */
.hidden { display: none !important; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-6 { margin-bottom: 24px; }
.stats-mini-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}
.flex-wrap { flex-wrap: wrap; gap: 8px; }

/* STILI DI STAMPA PER IL TOTEM */
@media print {
  body * {
    visibility: hidden;
  }
  #totem-print-area, #totem-print-area * {
    visibility: visible;
  }
  #totem-print-area {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(1.5);
    border: none;
    box-shadow: none;
  }
}
