/* Property Cards - Premium Design */

.properties-header {
    background: linear-gradient(135deg, #0A1512 0%, #102019 40%, #102019 100%);
    padding: 100px 0 48px;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.properties-header::before {
    content: '';
    position: absolute;
    top: -40%;
    right: -15%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(62, 207, 142,0.08) 0%, transparent 70%);
    pointer-events: none;
}

.properties-header h1 {
    font-family: var(--font-display, 'DM Sans', sans-serif);
    font-size: 2.5rem;
    color: var(--white, #fff);
    margin-bottom: 1rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}
.properties-header h1 span {
    color: var(--accent-color, #3ECF8E);
}
.properties-header p {
    font-size: 1.15rem;
    color: rgba(255, 255, 255, 0.65);
    max-width: 640px;
    margin: 0 auto 2rem;
    font-weight: 400;
}

.search-filters {
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 20px 24px;
    border-radius: var(--border-radius-xl, 20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 900px;
    margin: 0 auto;
}
.search-filters form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: center;
}
.filter-group {
    flex: 1;
    min-width: 180px;
}
.filter-group input,
.filter-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--border-radius, 8px);
    font-size: 15px;
    transition: all 0.15s;
    background: rgba(255, 255, 255, 0.08);
    color: var(--white, #fff);
    font-family: var(--font-family, 'Inter', sans-serif);
}
.filter-group input::placeholder { color: rgba(255,255,255,0.5); }
.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--accent-color, #3ECF8E);
    box-shadow: 0 0 0 3px rgba(62, 207, 142, 0.25);
    background: rgba(255, 255, 255, 0.12);
}
.filter-group option {
    color: var(--text-color, #102019);
    background: var(--white, #fff);
}
.search-filters .btn-primary {
    min-width: 120px;
}

.properties-section {
    padding: 60px 0;
    background: var(--light-gray, #F2F1EA);
}

.properties-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 24px;
    margin-top: 20px;
}

/* Cards */
.property-card {
    background: var(--white, #fff);
    border-radius: var(--border-radius-xl, 20px);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 6px 16px rgba(0,0,0,0.06);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    border: 1px solid rgba(0,0,0,0.04);
    max-width: 420px;
    margin: 0 auto;
}
.property-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
}

.property-image {
    position: relative;
    height: 220px;
    background-color: var(--light-gray, #F2F1EA);
    overflow: hidden;
}
.property-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.property-card:hover .property-image img {
    transform: scale(1.05);
}

/* Badges */
.property-badges {
    position: absolute;
    top: 14px;
    left: 14px;
    display: flex;
    gap: 8px;
    z-index: 2;
}
.property-badge {
    padding: 5px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.badge-verified {
    background: rgba(16, 185, 129, 0.9);
    color: white;
}
.badge-premium {
    background: rgba(245, 158, 11, 0.9);
    color: white;
}
.badge-opportunity {
    background: rgba(62, 207, 142, 0.9);
    color: white;
}

/* Favorite button */
.property-favorite {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 2;
    border: none;
}
.property-favorite:hover {
    background: var(--white, #fff);
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.property-favorite i {
    color: #9FA39D;
    font-size: 14px;
}
.property-favorite.favorited i {
    color: #ef4444;
}

/* Card content */
.property-info {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}
.property-info .property-title,
.property-card .property-title {
    font-family: var(--font-display, 'DM Sans', sans-serif);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary-color, #0A1512);
    margin-bottom: 6px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.property-price {
    font-family: var(--font-display, 'DM Sans', sans-serif);
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary-color, #0A1512);
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}
.property-location {
    color: var(--text-muted, #6E746F);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
}
.property-location::before {
    content: "\1F4CD";
    font-size: 13px;
}
.property-size {
    color: var(--text-muted, #6E746F);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

/* Financial Metrics */
.property-metrics {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--light-gray, #F2F1EA);
    border-radius: var(--border-radius, 8px);
}
.metric-item {
    flex: 1;
    text-align: center;
}
.metric-label {
    font-size: 11px;
    color: var(--text-muted, #6E746F);
    margin-bottom: 4px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.metric-value.yield {
    font-family: var(--font-display, 'DM Sans', sans-serif);
    font-size: 1.05rem;
    font-weight: 700;
    color: #3ECF8E;
}
.metric-value.cashflow {
    font-family: var(--font-display, 'DM Sans', sans-serif);
    font-size: 1.05rem;
    font-weight: 700;
    color: #F59E0B;
}

/* Property details */
.property-details {
    font-size: 0.85rem;
    color: var(--text-muted, #6E746F);
    margin-bottom: 16px;
    line-height: 1.5;
}
.property-detail-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--light-gray, #F2F1EA);
}
.property-detail-row:last-child {
    border-bottom: none;
}
.property-detail-label { font-weight: 500; }
.property-detail-value { text-align: right; font-weight: 600; color: var(--primary-color, #0A1512); }

/* Actions */
.property-actions {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid rgba(0,0,0,0.04);
    background: var(--white, #fff);
}
.property-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: var(--border-radius, 8px);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-family: var(--font-family, 'Inter', sans-serif);
}
.btn-details {
    background: var(--accent-color, #3ECF8E);
    color: var(--white, #fff);
}
.btn-details:hover {
    background: var(--accent-hover, #34A574);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(62, 207, 142, 0.3);
}
.btn-compare {
    background: var(--white, #fff);
    color: var(--text-color, #102019);
    border: 1px solid var(--border-color, #E8E7E1);
}
.btn-compare:hover {
    background: var(--light-gray, #F2F1EA);
    border-color: var(--accent-color, #3ECF8E);
    color: var(--accent-color, #3ECF8E);
}
.btn-details:focus,
.btn-compare:focus {
    outline: 2px solid var(--accent-color, #3ECF8E);
    outline-offset: 2px;
}

.btn-success {
    background: linear-gradient(135deg, #3ECF8E, #059669);
    color: white;
    padding: 12px 24px;
    border-radius: var(--border-radius, 8px);
    font-weight: 600;
    text-decoration: none;
    transition: all 0.25s;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}
.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.cta-section {
    background: linear-gradient(135deg, #0A1512 0%, #102019 50%, #102019 100%);
    color: white;
    padding: 80px 0;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.cta-section::before {
    content: '';
    position: absolute;
    top: -50%;
    left: 50%;
    transform: translateX(-50%);
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(62, 207, 142,0.08) 0%, transparent 70%);
    pointer-events: none;
}
.cta-content { position: relative; z-index: 1; }
.cta-content h2 {
    font-family: var(--font-display, 'DM Sans', sans-serif);
    font-size: 2rem;
    margin-bottom: 15px;
    font-weight: 800;
    letter-spacing: -0.02em;
}
.cta-content p {
    font-size: 1.1rem;
    margin-bottom: 30px;
    color: rgba(255, 255, 255, 0.65);
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 0;
    width: 100%;
    text-align: center;
}
.spinner {
    border: 3px solid rgba(0, 0, 0, 0.06);
    border-radius: 50%;
    border-top: 3px solid var(--accent-color, #3ECF8E);
    width: 44px;
    height: 44px;
    animation: spin 0.8s linear infinite;
    margin-bottom: 20px;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.no-results, .error-message {
    text-align: center;
    padding: 48px 24px;
    border-radius: var(--border-radius-xl, 20px);
    background: var(--white, #fff);
    margin: 30px auto;
    max-width: 600px;
    border: 1px solid var(--border-color, #E8E7E1);
}
.error-message {
    background: #FEF2F2;
    border-left: 4px solid #EF4444;
}
.error-message i, .no-results i {
    font-size: 2.5rem;
    color: #EF4444;
    margin-bottom: 16px;
}
.no-results i { color: var(--text-muted, #6E746F); }
.error-details {
    margin-top: 16px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: var(--border-radius, 8px);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
    color: #991B1B;
}

/* Responsive */
@media (max-width: 768px) {
    .properties-header { padding: 90px 0 36px; }
    .properties-header h1 { font-size: 1.75rem; }
    .search-filters { padding: 16px; }
    .search-filters form { flex-direction: column; }
    .filter-group { width: 100%; min-width: 100%; }
    .properties-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .property-image { height: 200px; }
    .property-info h3, .property-card .property-title { font-size: 1.1rem; }
    .property-price { font-size: 1.4rem; }
}

/* === Card v2 fix: badge + dettagli puliti (2026-04) === */
.property-badge.badge-high-yield {
  background: #fef3c7;
  color: #92400e;
  font-weight: 700;
}
.property-badge.badge-verified {
  background: #d1fae5;
  color: #065f46;
  font-weight: 700;
}

/* Override per .property-card-details — niente flex legacy, layout label/value pulito */
.property-card .property-card-details {
  display: block;
  margin: 12px 0 16px;
  padding: 12px 0;
  border-top: 1px solid #E8E7E1;
  border-bottom: 1px solid #E8E7E1;
}
.property-card .pcd-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 4px 0;
  font-size: 0.875rem;
  line-height: 1.4;
}
.property-card .pcd-label {
  color: #6E746F;
  font-weight: 500;
  flex-shrink: 0;
}
.property-card .pcd-value {
  color: #0A1512;
  font-weight: 600;
  text-align: right;
}

/* === Placeholder neutro "Foto non disponibile" (pre-lancio T6) ===
   Legacy: mantenuto per superfici non ancora migrate alle immagini
   rappresentative di categoria (FASE 2). */
.photo-placeholder {
  width: 100%;
  height: 100%;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #ECEBE4;
  color: #6E746F;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
  text-align: center;
}
.photo-placeholder svg { opacity: .55; }

/* === Immagine rappresentativa di categoria (FASE 2) ===
   Quando l'annuncio non ha foto reali, mostriamo la fotografia di
   categoria (JPG "-v2") con badge trasparente: mai un fallback
   presentato come foto reale dell'immobile. */
.img-representative-badge {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(10, 21, 18, 0.72);
  color: #ECEBE4;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  line-height: 1.2;
  pointer-events: none;
  white-space: nowrap;
}
/* Il badge richiede un contenitore posizionato: le card lo hanno già
   (.property-image, .hero-featured__media, ...); guardia difensiva. */
.property-image,
.similar-card__media,
.hero-featured__media,
.main-image {
  position: relative;
}
/* Aspect-ratio stabile per i fallback: niente layout shift quando il
   JPG carica (le foto reali mantengono il sizing esistente). */
img.img-category-default {
  width: 100%;
  height: 100%;
  min-height: 200px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

/* ===== DARK MODE ===== */
/* .properties-header e .cta-section sono già scuri (gradiente ink) in light:
   restano intatti by design. Idem badge overlay su foto e filtri glassy
   nell'hero (rgba bianco su fondo scuro): non toccare. */

/* Sezione lista annunci — fondo pagina scuro */
html[data-theme="dark"] .properties-section {
    background: var(--color-bg);
}

/* Cards — superficie scura, bordo di stacco, ombra densa */
html[data-theme="dark"] .property-card {
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--color-border);
}
html[data-theme="dark"] .property-card:hover {
    box-shadow: var(--shadow-card-hover);
}
html[data-theme="dark"] .property-image {
    background-color: var(--color-bg-muted);
}

/* Testi card */
html[data-theme="dark"] .property-info .property-title,
html[data-theme="dark"] .property-card .property-title {
    color: var(--color-text-strong);
}
html[data-theme="dark"] .property-price {
    color: var(--color-text-strong);
}
html[data-theme="dark"] .property-location,
html[data-theme="dark"] .property-size,
html[data-theme="dark"] .property-details,
html[data-theme="dark"] .metric-label {
    color: var(--color-text-muted);
}
html[data-theme="dark"] .property-detail-value {
    color: var(--color-text-strong);
}
html[data-theme="dark"] .property-detail-row {
    border-bottom: 1px solid var(--color-border);
}

/* Metriche finanziarie — pannello incassato */
html[data-theme="dark"] .property-metrics {
    background: var(--color-surface-sunken);
}
html[data-theme="dark"] .metric-value.yield {
    color: var(--color-success);
}
html[data-theme="dark"] .metric-value.cashflow {
    color: var(--color-warning);
}

/* Favorite button — pill su foto: manteniamo superficie scura leggibile */
html[data-theme="dark"] .property-favorite {
    background: rgba(18, 33, 26, 0.85);
}
html[data-theme="dark"] .property-favorite:hover {
    background: var(--color-surface-raised);
}
html[data-theme="dark"] .property-favorite i {
    color: var(--color-text-muted);
}

/* Actions footer */
html[data-theme="dark"] .property-actions {
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}
html[data-theme="dark"] .btn-compare {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}
html[data-theme="dark"] .btn-compare:hover {
    background: var(--color-surface-raised);
    border-color: var(--color-accent);
    color: var(--color-accent);
}

/* Stati vuoti / errore */
html[data-theme="dark"] .no-results,
html[data-theme="dark"] .error-message {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
}
html[data-theme="dark"] .error-message {
    background: var(--color-danger-soft);
    border-left: 4px solid var(--color-danger);
}
html[data-theme="dark"] .no-results i {
    color: var(--color-text-muted);
}
html[data-theme="dark"] .error-details {
    background: rgba(0, 0, 0, 0.3);
    color: var(--color-danger);
}
html[data-theme="dark"] .spinner {
    border: 3px solid var(--color-border);
    border-top: 3px solid var(--color-accent);
}

/* Card v2 badge — soft dark ricalibrati */
html[data-theme="dark"] .property-badge.badge-high-yield {
    background: var(--color-warning-soft);
    color: var(--color-warning);
}
html[data-theme="dark"] .property-badge.badge-verified {
    background: var(--color-verified-soft);
    color: var(--color-verified-strong);
}

/* Dettagli label/value puliti */
html[data-theme="dark"] .property-card .property-card-details {
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
}
html[data-theme="dark"] .property-card .pcd-label {
    color: var(--color-text-muted);
}
html[data-theme="dark"] .property-card .pcd-value {
    color: var(--color-text-strong);
}

/* Placeholder "Foto non disponibile" — superficie scura */
html[data-theme="dark"] .photo-placeholder {
    background: var(--color-bg-muted);
    color: var(--color-text-muted);
}
