/**
 * Immobili Proptech — Enterprise UI layer
 * Griglia 12 colonne, sidebar filtri, tabella dati, ombre morbide.
 * Si affianca agli stili inline in index.html (variabili :root ereditate).
 */

/* ─── Tipografia Inter + Plus Jakarta (SPEC) ─── */
#main-app {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.proptech-h1 {
  font-family: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--gray-900);
  line-height: 1.25;
  margin: 0;
}

.proptech-h2 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--gray-800);
  margin: 0 0 1rem;
}

.proptech-h3 {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-500);
  margin: 0 0 0.5rem;
}

/* ─── Header app — logo + nav ─── */
.proptech-app-header {
  background: var(--bg-primary);
  border-bottom: none;
  box-shadow: var(--shadow-sm);
  padding: 0 1rem;
  min-height: 56px;
  align-items: center;
  gap: 1rem;
}

.proptech-app-header .header-logo {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--gray-900);
  gap: 0.5rem;
}

.proptech-brand {
  letter-spacing: -0.02em;
}

.proptech-header-nav {
  display: none;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
  justify-content: center;
}

@media (min-width: 900px) {
  .proptech-header-nav {
    display: flex;
  }
}

.proptech-nav-link {
  padding: 0.5rem 0.85rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--gray-600);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.proptech-nav-link:hover {
  color: var(--primary);
  background: var(--primary-light);
}

/* ─── Layout CRM Immobili: griglia 12 col (3 sidebar + 9 main) ─── */
.proptech-immobili-layout {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1.25rem;
  align-items: start;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 4px;
}

.proptech-sidebar {
  grid-column: span 12;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(15, 23, 42, 0.06);
}

@media (min-width: 1024px) {
  .proptech-sidebar {
    grid-column: span 3;
    position: sticky;
    top: calc(72px + var(--safe-top));
    max-height: calc(100vh - 100px);
    overflow-y: auto;
  }
}

.proptech-content-main {
  grid-column: span 12;
  min-width: 0;
}

@media (min-width: 1024px) {
  .proptech-content-main {
    grid-column: span 9;
  }
}

/* Campi sidebar */
.proptech-field {
  margin-bottom: 1rem;
}

.proptech-field .form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.35rem;
}

.proptech-field .form-input {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  box-shadow: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.proptech-field .form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.15);
}

.proptech-search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.proptech-search-row .form-input {
  flex: 1;
  min-width: 160px;
}

.proptech-price-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.proptech-price-row .form-input {
  max-width: 120px;
}

/* Pill filtro stato — stile morbido */
.proptech-filter-pills {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.proptech-filter-pills .filter-pill {
  justify-content: flex-start;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-xs);
  padding: 0.65rem 0.85rem;
}

.proptech-filter-pills .filter-pill.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  box-shadow: var(--shadow-xs);
}

.proptech-sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.proptech-sidebar-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--gray-100);
}

/* Bottoni primari / secondari enterprise */
.proptech-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: transform 0.15s, box-shadow 0.2s;
  font-family: inherit;
}

.proptech-btn--primary {
  background: linear-gradient(145deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: var(--shadow-primary);
}

.proptech-btn--primary:hover {
  box-shadow: var(--shadow-primary-lg);
}

.proptech-btn--primary:active {
  transform: scale(0.98);
}

.proptech-btn--ghost {
  background: var(--gray-50);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-xs);
}

.proptech-btn--ghost:hover {
  background: var(--gray-100);
}

.proptech-btn--link {
  background: transparent;
  color: var(--primary);
  min-height: 48px;
  padding: 0 0.5rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ─── Tabella dati ─── */
.proptech-table-wrap {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(15, 23, 42, 0.06);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.proptech-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.proptech-table thead th {
  text-align: left;
  padding: 0.9rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-100);
}

.proptech-table tbody tr.proptech-imm-row {
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--gray-100);
}

.proptech-table tbody tr.proptech-imm-row:nth-child(even) {
  background: rgba(248, 250, 252, 0.85);
}

.proptech-table tbody tr.proptech-imm-row:hover {
  background: var(--primary-light);
}

.proptech-table tbody td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
  color: var(--gray-800);
  border: none;
}

.proptech-td-thumb {
  width: 72px;
}

.proptech-thumb-cell {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-xs);
}

.proptech-thumb-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.proptech-td-actions {
  white-space: nowrap;
  text-align: right;
}

.proptech-td-actions .card-menu-btn {
  min-width: 48px;
  min-height: 48px;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  background: var(--bg-card);
  box-shadow: var(--shadow-xs);
  box-sizing: border-box;
}

.proptech-status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
}

.proptech-address-cell {
  font-weight: 600;
  color: var(--gray-900);
  max-width: min(280px, 100%);
}

.proptech-meta-muted {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 0.25rem;
}

/* Righe vuote / empty */
.proptech-table-empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--gray-500);
}

.proptech-table-empty-strong {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 0.5rem;
}

/* Skeleton tabella */
.proptech-skeleton-row td {
  padding: 1rem;
}

.proptech-skeleton-bar {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: proptech-shimmer 1.2s ease-in-out infinite;
}

@keyframes proptech-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Risultati ricerca globale sotto H2 */
#crm-panel-immobili .global-search-results {
  margin-bottom: 1rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--gray-100);
}

/* Bordo stato sulla riga tabella */
.proptech-imm-row.border-review { --imm-row-accent: var(--primary); }
.proptech-imm-row.border-elaborazione { --imm-row-accent: var(--warning); }
.proptech-imm-row.border-pubblicato { --imm-row-accent: var(--success); }
.proptech-imm-row.border-review,
.proptech-imm-row.border-elaborazione,
.proptech-imm-row.border-pubblicato {
  box-shadow: inset 4px 0 0 0 var(--imm-row-accent);
}

.proptech-thumb-cell .thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
}

/* ─── Lista immobili CRM: card orizzontali ─── */
.proptech-table-wrap.crm-imm-cards-wrap {
  overflow: visible;
  background: transparent;
  box-shadow: none;
  border: none;
}

.crm-immobili-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.crm-imm-card {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  width: 100%;
  min-height: 108px;
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.crm-imm-card:active {
  transform: scale(0.992);
}

.crm-imm-card__thumb {
  flex: 0 0 112px;
  min-width: 112px;
  align-self: stretch;
}

.crm-imm-thumb.proptech-thumb-cell {
  width: 100%;
  height: 100%;
  min-height: 108px;
  border-radius: 0;
  box-shadow: none;
}

.crm-imm-thumb.proptech-thumb-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.crm-imm-card__body {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.crm-imm-card__top {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

@media (min-width: 480px) {
  .crm-imm-card__top {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
  }
}

.crm-imm-card__addr {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.crm-st-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.crm-st-badge--elab {
  background: rgba(245, 158, 11, 0.15);
  color: #b45309;
}

.crm-st-badge--deal {
  background: rgba(29, 78, 216, 0.12);
  color: #1d4ed8;
}

.crm-st-badge--pub {
  background: rgba(5, 150, 105, 0.14);
  color: #047857;
}

.crm-imm-card__metrics {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px 18px;
}

.crm-imm-card__price {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.crm-imm-card__mq {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-700);
}

.crm-imm-mq-unit {
  font-weight: 700;
  color: var(--gray-500);
  font-size: 0.85em;
}

.crm-imm-card__actions {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  padding: 8px 10px 8px 0;
}

.crm-imm-card__actions .card-menu-btn {
  min-width: 48px;
  min-height: 48px;
}

.crm-imm-card--skeleton {
  pointer-events: none;
  min-height: 108px;
}

.crm-imm-card--skeleton .crm-imm-card__body {
  justify-content: center;
}

/* Bordo stato card */
article.proptech-imm-row.border-review { --imm-row-accent: var(--primary); }
article.proptech-imm-row.border-elaborazione { --imm-row-accent: var(--warning); }
article.proptech-imm-row.border-pubblicato { --imm-row-accent: var(--success); }
article.proptech-imm-row.border-review,
article.proptech-imm-row.border-elaborazione,
article.proptech-imm-row.border-pubblicato {
  box-shadow: inset 4px 0 0 0 var(--imm-row-accent), 0 6px 20px rgba(15, 23, 42, 0.06);
}

/* ─── Avanzamento vendita (accordion) ─── */
.avanzamento-phases {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.avanz-phase {
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #fff;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.avanz-phase.is-open .avanz-phase-chevron {
  transform: rotate(90deg);
}

.avanz-phase-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 14px 16px;
  border: none;
  background: var(--gray-50);
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--gray-900);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.avanz-phase-head:active {
  background: var(--gray-100);
}

.avanz-phase-chevron {
  display: inline-block;
  transition: transform 0.2s ease;
  font-size: 1.25rem;
  color: var(--primary);
  font-weight: 700;
}

.avanz-phase-body {
  padding: 14px 16px 16px;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  background: #fff;
}

.avanz-notes-list {
  margin-bottom: 12px;
  max-height: 200px;
  overflow-y: auto;
}

.avanz-note-item {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--gray-50);
  margin-bottom: 8px;
  border-left: 3px solid var(--primary);
}

.avanz-note-meta {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-500);
}

.avanz-note-text {
  margin-top: 6px;
  font-size: 0.9rem;
  color: var(--gray-800);
  line-height: 1.45;
  white-space: pre-wrap;
}

.avanz-note-empty {
  font-size: 0.85rem;
  color: var(--gray-400);
  font-style: italic;
  padding: 4px 0;
}

/* ═══ Notifiche (toast) + validazione form + offline empty — PWA UX ═══ */
.form-field--error .form-label {
  color: var(--danger);
}
.form-input--error,
.form-field--error .form-input:not(:focus) {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(197, 34, 31, 0.12);
}
.form-field-error-msg {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--danger);
  margin: 6px 0 0;
  line-height: 1.35;
}
.form-section.form-field--error {
  border-radius: var(--radius);
  outline: 2px solid rgba(197, 34, 31, 0.2);
  outline-offset: 2px;
}

.form-section.form-field--error .upload-area {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(197, 34, 31, 0.1);
}

.crm-offline-empty {
  text-align: center;
  padding: 2.5rem 1.25rem;
  border-radius: 12px;
  background: var(--gray-50);
  border: 1px dashed var(--gray-200);
  max-width: 420px;
  margin: 0 auto;
}
.crm-offline-empty svg {
  width: 72px;
  height: 72px;
  margin: 0 auto 1rem;
  display: block;
  stroke: var(--gray-400);
}
.crm-offline-empty h3 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--gray-900);
}
.crm-offline-empty p {
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
  color: var(--gray-600);
  line-height: 1.5;
}
.btn.btn--loading {
  pointer-events: none;
  opacity: 0.88;
}
