/* =====================================================
   Club Mercatino – Foglio di stile
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:ital,wght@0,300;0,400;0,500;1,400&display=swap');

:root {
  --cm-bg:        #f8f8f8;
  --cm-surface:   #ffffff;
  --cm-border:    #e0d9d0;
  --cm-accent:    #f90302;
  --cm-accent2:   #e8a020;
  --cm-text:      #1a1612;
  --cm-muted:     #7a7068;
  --cm-radius:    12px;
  --cm-shadow:    0 2px 16px rgba(0,0,0,.08);
  --cm-shadow-lg: 0 8px 40px rgba(0,0,0,.16);
  --cm-font-head: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --cm-font-head-weight: 300;
  --cm-font-head-transform: uppercase;
  --cm-font-head-spacing: 0.12em;
  --cm-font-body: 'DM Sans', sans-serif;
}

/* Stile globale per tutti i titoli del plugin */
.cm-card-title,
.cm-dettaglio-titolo,
.cm-modal-body h2,
.cm-form-title,
.cm-miei-title,
.cm-miei-header h3,
.cm-form-section h3,
.cm-dettaglio-desc h3,
.cm-dettaglio-contatti h3,
.cm-btn-submit,
.cm-dettaglio-prezzo {
  font-family: var(--cm-font-head);
  font-weight: var(--cm-font-head-weight);
  text-transform: var(--cm-font-head-transform);
  letter-spacing: var(--cm-font-head-spacing);
}

.cm-card-title,
.cm-dettaglio-titolo,
.cm-modal-body h2,
.cm-form-title,
.cm-miei-title,
.cm-miei-header h3,
.cm-form-section h3,
.cm-dettaglio-desc h3,
.cm-dettaglio-contatti h3 {
  color: var(--cm-accent);
}

/* ---- WRAPPER ---- */
.cm-wrapper {
  font-family: var(--cm-font-body);
  color: var(--cm-text);
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

/* ---- FILTRI ---- */
.cm-filtri {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
  background: var(--cm-surface);
  border: 1px solid var(--cm-border);
  border-radius: var(--cm-radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.cm-search-box {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--cm-bg);
  border: 1px solid var(--cm-border);
  border-radius: 8px;
  padding: .5rem .9rem;
  flex: 1 1 200px;
}
.cm-search-box input {
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--cm-font-body);
  font-size: .95rem;
  width: 100%;
  color: var(--cm-text);
}
.cm-search-icon { font-size: 1rem; }

.cm-cat-pills {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  flex: 2 1 300px;
}
.cm-pill {
  font-family: var(--cm-font-body);
  font-size: .8rem;
  font-weight: 500;
  padding: .35rem .85rem;
  border-radius: 999px;
  border: 1.5px solid var(--cm-border);
  color: var(--cm-muted);
  text-decoration: none;
  transition: all .18s;
  background: var(--cm-bg);
}
.cm-pill:hover, .cm-pill.active {
  background: var(--cm-accent);
  border-color: var(--cm-accent);
  color: #fff;
}

.cm-btn-search {
  font-family: var(--cm-font-body);
  font-size: .9rem;
  font-weight: 600;
  padding: .55rem 1.4rem;
  background: var(--cm-text);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity .18s;
}
.cm-btn-search:hover { opacity: .8; }

/* ---- CONTEGGIO ---- */
.cm-count {
  font-size: .85rem;
  color: var(--cm-muted);
  margin-bottom: 1.25rem;
}

/* ---- GRIGLIA ---- */
.cm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

/* ---- CARD (ora è un link) ---- */
.cm-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--cm-surface);
  border: 1px solid var(--cm-border);
  border-radius: var(--cm-radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
  box-shadow: var(--cm-shadow);
}
.cm-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--cm-shadow-lg);
}

.cm-card-img {
  height: 190px;
  background-size: cover;
  background-position: center;
  background-color: var(--cm-bg);
}
.cm-card-img--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--cm-border);
}

.cm-card-body {
  padding: 1rem 1.1rem 1.1rem;
}

.cm-badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  background: var(--cm-accent2);
  color: #fff;
  padding: .2rem .65rem;
  border-radius: 999px;
  margin-bottom: .6rem;
}

.cm-card-title {
  font-family: var(--cm-font-head);
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 .4rem;
  line-height: 1.3;
}

.cm-card-desc {
  font-size: .88rem;
  color: var(--cm-muted);
  margin: 0 0 .9rem;
  line-height: 1.5;
}

.cm-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--cm-border);
  padding-top: .75rem;
  margin-top: auto;
}

.cm-prezzo {
  font-family: var(--cm-font-head);
  font-size: 1.2rem;
  color: var(--cm-accent);
}

.cm-socio {
  font-size: .8rem;
  color: var(--cm-muted);
}

/* ---- EMPTY ---- */
.cm-empty {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--cm-muted);
}
.cm-empty span { font-size: 3rem; display: block; margin-bottom: 1rem; }

/* ---- PAGINA DETTAGLIO ---- */
.cm-back-link {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .9rem;
  font-weight: 600;
  color: var(--cm-muted);
  text-decoration: none;
  margin-bottom: 1.75rem;
  transition: color .18s;
}
.cm-back-link:hover { color: var(--cm-accent); }

.cm-dettaglio-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
  align-items: start;
}

.cm-dettaglio-foto img {
  width: 100%;
  border-radius: var(--cm-radius);
  object-fit: cover;
  max-height: 420px;
  box-shadow: var(--cm-shadow);
}
.cm-dettaglio-nofoto {
  width: 100%;
  aspect-ratio: 4/3;
  background: var(--cm-bg);
  border: 1px solid var(--cm-border);
  border-radius: var(--cm-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5rem;
  color: var(--cm-border);
}

.cm-dettaglio-titolo {
  font-family: var(--cm-font-head);
  font-size: 2rem;
  font-weight: 800;
  margin: .5rem 0 .75rem;
  line-height: 1.2;
}
.cm-dettaglio-prezzo {
  font-family: var(--cm-font-head);
  font-size: 2.2rem;
  color: var(--cm-accent);
  font-weight: 800;
  margin-bottom: 1.5rem;
}

.cm-dettaglio-desc,
.cm-dettaglio-contatti {
  background: var(--cm-surface);
  border: 1px solid var(--cm-border);
  border-radius: var(--cm-radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.cm-dettaglio-desc h3,
.cm-dettaglio-contatti h3 {
  font-family: var(--cm-font-head);
  font-size: .95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--cm-muted);
  margin: 0 0 .75rem;
}
.cm-dettaglio-desc p {
  font-size: .95rem;
  line-height: 1.7;
  color: var(--cm-text);
  margin: 0;
}
.cm-dettaglio-contatti p {
  font-size: .95rem;
  line-height: 1.8;
  margin: 0;
}
.cm-dettaglio-contatti a { color: var(--cm-accent); text-decoration: none; }
.cm-dettaglio-contatti a:hover { text-decoration: underline; }

.cm-btn-contatta {
  display: inline-block;
  margin-top: 1rem;
  padding: .75rem 1.5rem;
  background: var(--cm-accent);
  color: #fff !important;
  font-family: var(--cm-font-head);
  font-weight: 700;
  font-size: 1rem;
  border-radius: 10px;
  text-decoration: none !important;
  transition: opacity .18s, transform .18s;
}
.cm-btn-contatta:hover { opacity: .88; transform: translateY(-2px); }

@media (max-width: 700px) {
  .cm-dettaglio-layout { grid-template-columns: 1fr; gap: 1.25rem; }
  .cm-dettaglio-titolo { font-size: 1.5rem; }
}

/* ---- RESPONSIVE ---- */
.cm-data { color: var(--cm-muted); font-size: .78rem; display: block; margin-top: .5rem; }

/* ---- FORM INSERIMENTO ---- */
.cm-form-wrapper { max-width: 720px; }

.cm-form-title {
  font-family: var(--cm-font-head);
  font-size: 1.9rem;
  font-weight: 800;
  margin-bottom: .25rem;
}
.cm-form-subtitle {
  color: var(--cm-muted);
  margin-bottom: 2rem;
}

.cm-form-section {
  background: var(--cm-surface);
  border: 1px solid var(--cm-border);
  border-radius: var(--cm-radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.cm-form-section h3 {
  font-family: var(--cm-font-head);
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 1.25rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--cm-border);
}

.cm-field {
  margin-bottom: 1rem;
}
.cm-field label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: .4rem;
  color: var(--cm-accent);
}
.cm-field input,
.cm-field select,
.cm-field textarea {
  width: 100%;
  font-family: var(--cm-font-body);
  font-size: .95rem;
  padding: .65rem .9rem;
  border: 1.5px solid var(--cm-border);
  border-radius: 8px;
  background: var(--cm-bg);
  color: var(--cm-text);
  outline: none;
  transition: border-color .18s;
  box-sizing: border-box;
}
.cm-field input:focus,
.cm-field select:focus,
.cm-field textarea:focus {
  border-color: var(--cm-accent);
  background: #fff;
}
.cm-field small {
  display: block;
  font-size: .78rem;
  color: var(--cm-muted);
  margin-top: .3rem;
}

.cm-field--half {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.cm-field--privacy {
  background: var(--cm-surface);
  border: 1px solid var(--cm-border);
  border-radius: var(--cm-radius);
  padding: 1rem 1.25rem;
}
.cm-field--privacy label {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  font-size: .88rem;
  font-weight: 400;
  color: var(--cm-muted);
  cursor: pointer;
}
.cm-field--privacy input[type="checkbox"] {
  width: 18px;
  flex-shrink: 0;
  margin-top: 2px;
}

.cm-btn-submit {
  display: block;
  width: 100%;
  margin-top: 1.5rem;
  padding: 1rem;
  font-family: var(--cm-font-head);
  font-size: 1.1rem;
  font-weight: 700;
  background: var(--cm-accent);
  color: #fff;
  border: none;
  border-radius: var(--cm-radius);
  cursor: pointer;
  transition: transform .18s, opacity .18s;
  letter-spacing: .03em;
}
.cm-btn-submit:hover { transform: translateY(-2px); opacity: .9; }

.cm-disclaimer {
  font-size: .82rem;
  color: var(--cm-muted);
  margin: 1rem 0 0;
  line-height: 1.5;
}

/* ---- ALERT ---- */
.cm-alert {
  padding: 1rem 1.25rem;
  border-radius: var(--cm-radius);
  margin-bottom: 1.5rem;
  font-size: .95rem;
  font-weight: 500;
}
.cm-alert--ok  { background: #eafaf1; border: 1px solid #a3d9b3; color: #1b6b38; }
.cm-alert--err { background: #fff5f0; border: 1px solid #f5b8a8; color: #8b2500; }

.cm-field-locked,
.cm-field input[readonly],
.cm-field input:read-only {
  background: var(--cm-bg) !important;
  color: var(--cm-muted) !important;
  cursor: not-allowed;
  -webkit-text-fill-color: var(--cm-muted);
}

.cm-logged-in-note {
  font-size: .85rem;
  color: var(--cm-muted);
  background: #f0f7ff;
  border: 1px solid #c5ddf7;
  border-radius: 8px;
  padding: .6rem .9rem;
  margin-bottom: 1rem;
}

/* ---- I MIEI ANNUNCI ---- */
.cm-miei-lista {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.5rem;
}

.cm-miei-card {
  display: flex;
  background: var(--cm-surface);
  border: 1px solid var(--cm-border);
  border-radius: var(--cm-radius);
  overflow: hidden;
  box-shadow: var(--cm-shadow);
}

.cm-miei-foto {
  width: 140px;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
  background-color: var(--cm-bg);
}
.cm-miei-foto--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}

.cm-miei-body {
  flex: 1;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.cm-miei-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.cm-miei-header h3 {
  font-family: var(--cm-font-head);
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
}

.cm-miei-stato {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #fff;
  padding: .2rem .7rem;
  border-radius: 999px;
  white-space: nowrap;
}

.cm-miei-meta {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: .88rem;
  margin: 0;
}

.cm-miei-desc {
  font-size: .88rem;
  color: var(--cm-muted);
  margin: 0;
  line-height: 1.5;
}

.cm-miei-actions {
  display: flex;
  gap: .6rem;
  margin-top: .25rem;
}

.cm-btn-modifica,
.cm-btn-elimina {
  font-family: var(--cm-font-body);
  font-size: .85rem;
  font-weight: 600;
  padding: .4rem .9rem;
  border-radius: 8px;
  text-decoration: none;
  transition: opacity .18s;
}
.cm-btn-modifica {
  background: #fff0f0;
  color: var(--cm-accent);
  border: 1px solid #f5b8a8;
}
.cm-btn-elimina {
  background: #fff0f0;
  color: var(--cm-accent);
  border: 1px solid #f5b8a8;
}
.cm-btn-modifica:hover,
.cm-btn-elimina:hover { opacity: .8; }

@media (max-width: 600px) {
  .cm-miei-card { flex-direction: column; }
  .cm-miei-foto { width: 100%; height: 160px; }
}

/* ---- UPLOAD FOTO (3 slot) ---- */
.cm-multi-slots {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
}

.cm-slot {
  width: 150px;
  height: 120px;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

.cm-slot-empty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cm-bg);
  border: 1.5px dashed var(--cm-border);
  border-radius: 8px;
}

.cm-slot-add {
  font-family: var(--cm-font-body);
  font-size: .78rem;
  font-weight: 600;
  color: var(--cm-muted);
  background: none;
  border: none;
  cursor: pointer;
  text-align: center;
  padding: .5rem;
  line-height: 1.4;
  transition: color .18s;
}
.cm-slot-add:hover { color: var(--cm-accent); }

.cm-slot-preview {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}
.cm-slot-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cm-slot-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,.65);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: .72rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .18s;
}
.cm-slot-preview:hover .cm-slot-remove { opacity: 1; }

.cm-slot-progress {
  width: 100%;
  height: 100%;
  background: var(--cm-bg);
  border: 1.5px solid var(--cm-border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}
.cm-slot-progress .cm-progress-track {
  width: 100%;
  height: 5px;
  background: var(--cm-border);
  border-radius: 999px;
  overflow: hidden;
}
.cm-slot-progress .cm-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--cm-accent);
  border-radius: 999px;
  transition: width .15s;
}

/* ---- GALLERIA DETTAGLIO ---- */
.cm-gallery-main {
  width: 100%;
  border-radius: var(--cm-radius);
  object-fit: contain;
  max-height: 380px;
  display: block !important;
  margin-bottom: .6rem;
}
.cm-gallery-thumbs {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: wrap !important;
  gap: .5rem !important;
  margin-top: .6rem !important;
}
.cm-gallery-thumb {
  width: 80px !important;
  height: 80px !important;
  max-width: 80px !important;
  max-height: 80px !important;
  object-fit: cover !important;
  border-radius: 6px !important;
  cursor: pointer !important;
  border: 2px solid transparent !important;
  transition: border-color .18s, opacity .18s;
  opacity: .7;
  flex: 0 0 80px !important;
}
.cm-gallery-thumb:hover { opacity: 1 !important; }
.cm-gallery-thumb.active {
  border-color: var(--cm-accent) !important;
  opacity: 1 !important;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 600px) {
  .cm-field--half { grid-template-columns: 1fr; }
  .cm-grid { grid-template-columns: 1fr; }
}

