:root {
  --ink: #243c34;
  --green: #009a4d;
  --muted: #67766c;
  --line: #dce3da;
  --paper: #f7f8f2;
  --search-btn: #ff9705;
  --search-btn-hover: #ff7c01;
}

* { box-sizing: border-box; }

/* Estructura base integrada correctamente para el Sticky Footer */
html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background-color: var(--paper);
  background-image: linear-gradient(to bottom, #ffd103 0%, #ffeb3f00 20%);
  background-repeat: no-repeat;
  color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, Segoe UI, sans-serif;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

button,
.button {
  display: inline-block;
  padding: 13px 21px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: white;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button:hover,
.button:hover { background: #007a3d; text-decoration: none; }

/* Encabezado */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1240px;
  margin: auto;
  padding: 12px 28px 8px;
}

.brand { display: block; flex-shrink: 0; width: 220px; max-width: 100%; line-height: 0; margin: 8px 0 0 10px; }
.brand img { display: block; width: 100%; height: auto; }
nav { display: flex; align-items: center; gap: 20px; font-size: 14px; }

nav a.account-link-mobile {
    font-weight: 500;
}

main { 
  flex: 1 0 auto;
  width: 100%;
  max-width: 1184px; 
  margin: auto; 
  padding: 0;
  display: flex;
  flex-direction: column;
}

.page-wrapper {
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* Portada */
.hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  overflow: hidden;
  margin-top: 0;
  border-radius: 18px;
  background: #dbe7dc;
}

.hero-copy {
  display: flex;
  align-self: stretch;
  align-items: flex-start;
  justify-content: center;
  padding: 74px 56px 20px 80px;
}

.hero-copy-content {
  width: 100%;
  max-width: 520px;
  text-align: left;
  zoom: 1.1;
}

.hero-copy-content > p:not(.eyebrow) { 
  max-width: 480px; 
  margin-bottom: 0;
}

.hero img { align-self: stretch; width: 100%; height: 100%; min-height: 0; object-fit: cover; }

.eyebrow { color: var(--green); font-size: 11px; font-weight: 750; letter-spacing: 2px; text-transform: uppercase; }
h1 { margin: 15px 0; font-size: 41px; line-height: 1.12; letter-spacing: -1.2px; overflow-wrap: break-word; }
h1 em { color: var(--green); font-family: Georgia, serif; font-weight: 400; }

h2 { font-size: 25px; line-height: 1.3; letter-spacing: -0.6px; }
h3 { line-height: 1.4; }
p { color: var(--muted); }

.pills { display: flex; gap: 10px; margin-top: 26px; }
.pills a { padding: 10px 20px; border-radius: 25px; background: white; font-size: 14px; }

/* Inputs generales */
label { display: block; margin: 0 0 16px; font-size: 13px; font-weight: 600; }

input,
select,
textarea {
  display: block;
  width: 100%;
  margin-top: 7px;
  padding: 12px;
  border: 1px solid #ccd5cb;
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font: inherit;
}

textarea { font-size: 16px; }
input:focus,
select:focus,
textarea:focus { outline: 2px solid #529c85; outline-offset: 2px; }

/* Buscador en Encabezado (PC) */
.search-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
}

.search-header label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.search-header label span { color: var(--muted); flex-shrink: 0; }

.search-header input,
.search-header select {
  margin-top: 0;
  padding: 8px 12px;
  font-size: 13px;
}

#search-city-wrap input { width: 120px; }

.search-header input::placeholder { color: #a0aca3; opacity: 1; }

.search-header select option[value=""],
.search-header select:invalid { color: #a0aca3 !important; }

.search-header select option:not([value=""]) { color: var(--ink) !important; }

.search-header button {
  padding: 8px 16px; 
  font-size: 13px; 
  border-radius: 6px; 
  white-space: nowrap;
  background: linear-gradient(to bottom, #ffbc05, #ff9705);
  border: 1px solid rgba(0,0,0,0.15);
  text-shadow: 0 1px 1px rgba(0,0,0,0.25);
}
.search-header button:hover { background: linear-gradient(to bottom, #ffc733, #e08404); }

/* Buscador inferior móvil (Oculto por defecto) */
.search-mobile-bottom { display: none; }

/* Buscador extendido */
.extended-search { margin-bottom: 20px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.extended-search summary { padding: 8px 14px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--green); }
.extended-search-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; padding: 6px 14px 12px; }

.extended-search-form label { 
  display: flex; 
  flex-direction: column; 
  align-items: flex-start; 
  gap: 3px; 
  margin: 0; 
  font-size: 13px; 
  font-weight: 600; 
}

.extended-search-form label span { color: var(--muted); font-size: 12px; }

.extended-search-form input:not([type="hidden"]), .extended-search-form select { 
  width: 120px; 
  margin-top: 0;
  padding: 8px 12px;
  font-size: 13px;
}

.extended-search-form .filter-short input, .extended-search-form .filter-short select { width: 80px; }

.filter-range-group { display: flex; align-items: flex-end; gap: 4px; margin: 0; }
.filter-range-group .filter-short input { width: 72px !important; }

.range-separator { display: flex; align-items: center; padding-bottom: 8px; color: var(--muted); font-weight: bold; }

.extended-search-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; }
.extended-search-actions a { font-size: 13px; }
.extended-search-actions button { padding: 8px 16px; font-size: 13px; border-radius: 6px; background: var(--search-btn); }
.extended-search-actions button:hover { background: var(--search-btn-hover); }

/* Avisos y resultados */
.sectionhead { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.sectionhead h2 { margin-top: 4px; }
.sectionhead h2 span { color: var(--muted); font-size: 16px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }

/* Tarjetas de resultados */
.card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover { 
  transform: translateY(-2px); 
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  text-decoration: none; 
}

.card .card-photo {
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background-color: #f0f0f0;
}

.card .card-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.cardbody { padding: 14px 16px; display: flex; flex-direction: column; flex-grow: 1; }
.cardbody h3 { 
  margin: 0 0 12px 0; 
  font-size: 17px; 
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.card-meta { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); min-width: 0; overflow: hidden; }
.card-location { font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-type {
  background: var(--paper);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10.5px;
  text-transform: uppercase;
  border: 1px solid var(--line);
  white-space: nowrap;
  flex-shrink: 0;
}

.card-price strong { font-size: 17px; font-weight: 700; color: var(--green); }

/* Ficha del Aviso */
.listing-detail { max-width: 1050px; }
.back-link { display: inline-block; margin-bottom: 20px; font-weight: 600; }

.listing-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; align-items: start; }
.listing-media { overflow: hidden; border-radius: 12px; background: #edf0e5; }
.listingphoto { display: block; width: 100%; height: auto; aspect-ratio: 740 / 466; border-radius: 12px; object-fit: cover; }

.listing-info .location { margin-top: -5px; font-size: 15px; }
.listing-info .price { margin: 15px 0 20px; color: var(--green); font-size: 32px; font-weight: 800; }

.advertiser-card { padding: 20px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.advertiser-card h3 { margin: 0 0 5px; font-size: 18px; }
.advertiser-card h3 small { color: var(--muted); font-weight: 400; }
.advertiser-card p { margin: 0 0 15px; font-size: 14px; }

.button-wa { display: block; width: 100%; background: #25d366; text-align: center; }
.button-wa:hover { background: #1eb956; }

.empty { padding: 45px; border: 1px dashed #b7c9bb; border-radius: 12px; text-align: center; }

/* Bloques generales y Footer integrado con margen automático */
.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 45px;
  padding: 25px 32px;
  border-radius: 12px;
  background: #e5eddf;
}

.panel { margin: 30px auto; padding: 35px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.narrow { max-width: 750px; }
.twocol { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.box { margin-bottom: 18px; padding: 20px; border: 1px solid var(--line); border-radius: 10px; }

.description { column-count: 2; column-gap: 30px; orphans: 2; widows: 2; }

/* Utilidades adicionales (Checkboxes) */
.checkbox-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 15px; margin: 15px 0; }
.checkbox-label { display: flex !important; align-items: center !important; gap: 8px; font-weight: normal; margin-bottom: 0; cursor: pointer; }
.checkbox-label input[type="checkbox"] { display: inline-block; width: 18px; height: 18px; margin: 0; flex: none; }




/* ==========================================================================
   RESPONSIVE: PANTALLAS MEDIANAS (Hasta 900px)
   ========================================================================== */
@media (max-width: 900px) {
  main { padding: 0 20px 40px; }
  .top { flex-wrap: wrap; }
  .search-header { order: 3; width: 100%; flex-wrap: wrap; }
  .hero .hero-copy { padding: 25px; }
  .hero-copy-content { zoom: 1; }
  h1 { font-size: 32px; }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .listing-grid { grid-template-columns: 1fr; gap: 20px; }
  .description { column-count: 1; }
}


/* ==========================================================================
   RESPONSIVE: MÓVILES (Hasta 700px)
   ========================================================================== */
@media (max-width: 700px) {

  body {
    background-size: 100% 800px; 
    background-repeat: no-repeat;
  }

  .top { 
    padding: 6px 20px 6px 14px; 
    flex-wrap: nowrap; 
    justify-content: space-between;
    align-items: center; 
    gap: 15px;
  }
  
  .brand { 
    width: 200px; 
    max-width: 55%; 
    margin: 10px 0 0 10px; 
  }
  
  nav { display: flex; flex-direction: column; align-items: center; gap: 12px; font-size: 13px; margin-right: 5px; }
  nav a.account-link-mobile { display: block; text-align: center;}
  nav .button { padding: 6px 10px; font-size: 12px; }

  header.top .search-header,
  .top > .search-header { display: none; }

  /* Forzar el orden correcto y recortar paddings de main/wrapper para móviles sin !important */
  main {
    padding-bottom: 0;
  }

  .page-wrapper {
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    padding-bottom: 0;
  }

  .hero { 
    grid-template-columns: 1fr; 
    margin-top: 6px; 
    order: 1;
  }

  .search-mobile-bottom {
    display: flex;
    width: 100%;
    margin: 15px 0 10px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #ffffff;
    order: 2;
  }

  .results {
    order: 3;
    margin-bottom: 0;
  }

  .pagination {
    margin: 15px 0 0 0;
  }

  .hero-copy { padding: 20px; }
  .hero-copy-content > p:not(.eyebrow) { font-size: 13.5px; line-height: 1.35; margin-top: 6px; margin-bottom: 0; }
  .hero img { max-height: 210px; }

  .grid, .twocol { grid-template-columns: 1fr; }
  
  button, .button { padding: 8px 12px; font-size: 13px; }

  .search-mobile-bottom form { display: flex; flex-direction: column; width: 100%; gap: 8px; margin: 0; }
  .search-mobile-bottom label { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 0; font-size: 13px; font-weight: 600; }
  .search-mobile-bottom label span { color: var(--muted); flex-shrink: 0; width: 30%; }

  .search-mobile-bottom input,
  .search-mobile-bottom select {
    width: 70%;
    margin-top: 0;
    padding: 8px 10px;
    font-size: 14px;
  }

  .search-mobile-bottom select option[value=""],
  .search-mobile-bottom select:invalid { color: #a0aca3; }
  .search-mobile-bottom select option:not([value=""]) { color: var(--ink); }

  .search-mobile-bottom button { 
    width: 100%; 
    margin-top: 4px; 
    padding: 10px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    background: linear-gradient(to bottom, #ffbc05, #ff9705);
    border: 1px solid rgba(0,0,0,0.15);
    text-shadow: 0 1px 1px rgba(0,0,0,0.25);
  }

  .banner { display: block; }
  .panel { padding: 18px; margin: 15px auto; }
  .sectionhead { align-items: start; }
  h1 { font-size: 30px; }
  .listing-info .price { font-size: 26px; }
}

/* Corrección de ancho completo para cabezal y pie en móviles */
@media (max-width: 700px) {
  html,
  body {
    width: 100%;
    min-width: 0;
  }

  body {
    align-items: stretch;
  }

  body > header.top {
    width: 100%;
    max-width: none;
    align-self: stretch;
    margin-left: 0;
    margin-right: 0;
  }

  body > footer {
    width: 100%;
    max-width: none;
    align-self: stretch;
    flex-shrink: 0;
    margin-left: 0;
    margin-right: 0;
  }
}
