/* ============================================
   BuscaResidencias.es — Main Stylesheet
   Directory of elderly care homes in Spain
   ============================================ */

/* ----- 1. Reset & CSS Variables ----- */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent: #047857;
  --accent-light: #059669;
  --accent-dark: #064e3b;
  --accent-soft: rgba(5, 150, 105, 0.08);
  --bg: #f0fdf4;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --card-bg: #ffffff;
  --gold: #d97706;
  --gold-soft: rgba(217, 119, 6, 0.1);
  --blue: #2563eb;
  --blue-soft: rgba(37, 99, 235, 0.08);
  --orange: #ea580c;
  --orange-soft: rgba(234, 88, 12, 0.08);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
  --transition: 0.2s ease;
}

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
img, svg { display: block; max-width: 100%; height: auto; }
ul, ol { list-style: none; }
a { text-decoration: none; color: var(--accent-light); transition: color var(--transition); }
a:hover { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; border: none; outline: none; background: none; }
table { border-collapse: collapse; width: 100%; }

/* ----- 2. Base ----- */

body {
  background: #fff;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 1.25rem; }

h1, h2, h3, h4, h5, h6 { line-height: 1.25; font-weight: 700; color: var(--text); }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
p + p { margin-top: 1rem; }

.text-center { text-align: center; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.section-title {
  font-size: 1.5rem; font-weight: 700; margin-bottom: 1.5rem;
}

.results-count { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 1.5rem; }

/* ----- 3. Header ----- */

.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--card-bg);
  box-shadow: var(--shadow-sm);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; max-width: 1200px; margin: 0 auto; padding: 0 1.25rem;
}

.logo {
  display: flex; align-items: center; gap: 0.5rem;
  font-weight: 700; font-size: 1.25rem;
  color: var(--accent); text-decoration: none;
  white-space: nowrap; min-width: 0; flex-shrink: 1; overflow: hidden;
}
.logo svg, .logo img { width: 32px; height: 32px; flex-shrink: 0; }
.logo:hover { color: var(--accent-dark); }

.main-nav ul { display: flex; align-items: center; gap: 1.5rem; }
.main-nav a {
  font-size: 0.9375rem; font-weight: 500; color: var(--text-muted);
  transition: color var(--transition); padding: 0.25rem 0;
}
.main-nav a:hover, .main-nav a.active { color: var(--accent); }

.nav-toggle {
  display: none; flex-direction: column; justify-content: center;
  align-items: center; gap: 5px; width: 40px; height: 40px; cursor: pointer;
}
.nav-toggle span {
  display: block; width: 24px; height: 2px; background: var(--text);
  border-radius: 2px; transition: transform var(--transition), opacity var(--transition);
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ----- 4. Hero ----- */

.hero {
  background: linear-gradient(135deg, #047857 0%, #059669 50%, #10b981 100%);
  color: #fff; text-align: center; padding: 3.5rem 1.25rem 3rem;
  position: relative; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; top: -50%; right: -20%; width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(255,255,255,.1) 0%, transparent 70%);
  pointer-events: none;
}
.hero::after {
  content: ''; position: absolute; bottom: -40%; left: -15%; width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(255,255,255,.06) 0%, transparent 65%);
  pointer-events: none;
}
.hero h1 {
  font-size: 2.75rem; color: #fff; margin-bottom: 0.75rem;
  font-weight: 800; line-height: 1.15; position: relative;
}
.hero__subtitle {
  font-size: 1.15rem; color: rgba(255, 255, 255, 0.85);
  max-width: 640px; margin: 0 auto 2rem; line-height: 1.6; position: relative;
}
.hero__trust {
  display: flex; justify-content: center; flex-wrap: wrap; gap: 1.5rem;
  margin-top: 1.5rem; position: relative;
}
.hero__trust span {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .85rem; color: rgba(255,255,255,.75); font-weight: 500;
}
.hero__trust svg { opacity: .7; }

/* ----- 5. Search Box ----- */

.search-section { padding: 1.5rem 0; }

.search-box {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow-lg);
  max-width: 900px; margin: 0 auto; position: relative;
}

.search-form { display: flex; gap: 0.75rem; flex-wrap: wrap; }

.search-form input[type="text"],
.search-form input[type="search"],
.search-form input[list] {
  flex: 1 1 180px; padding: 0.75rem 1rem;
  border: 1px solid var(--border); border-radius: calc(var(--radius) - 4px);
  font-size: 1rem; color: var(--text); background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-form input:focus {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}
.search-form select {
  flex: 0 1 200px; padding: 0.75rem 1rem;
  border: 1px solid var(--border); border-radius: calc(var(--radius) - 4px);
  font-size: 1rem; color: var(--text); background: #fff;
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.75rem center;
  padding-right: 2.25rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-form select:focus {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}
.search-form .btn-search {
  flex-shrink: 0; padding: 0.75rem 1.5rem;
  background: var(--accent); color: #fff;
  font-weight: 600; font-size: 1rem;
  border-radius: calc(var(--radius) - 4px); cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
  display: inline-flex; align-items: center; gap: 0.5rem;
}
.search-form .btn-search:hover {
  background: var(--accent-dark);
  box-shadow: 0 2px 8px rgba(4, 120, 87, 0.3);
}
.search-form input[list] { flex: 0 1 160px; }
.search-form input[disabled] { opacity: .5; cursor: not-allowed; }

/* ----- 6. Stats Section ----- */

.stats-section { padding: 3rem 0; }
.stats-section--alt { background: var(--bg); }

.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
}
.stat-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; text-align: center;
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card__number {
  display: block; font-size: 2.25rem; font-weight: 800;
  color: var(--accent); line-height: 1.2;
}
.stat-card__label {
  display: block; font-size: 0.875rem; color: var(--text-muted); margin-top: 0.25rem;
}

/* ----- 7. Homepage Sections ----- */

/* Top grid (provincias/comunidades destacadas) */
.hp-top-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem;
}
.hp-top-card {
  display: flex; align-items: center; gap: .75rem;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .85rem 1rem; text-decoration: none; color: var(--text);
  transition: all var(--transition);
}
.hp-top-card:hover {
  box-shadow: var(--shadow-md); transform: translateY(-1px);
  border-color: var(--accent-light); color: var(--text);
}
.hp-top-card__rank {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: #fff; font-weight: 800; font-size: .85rem;
  display: flex; align-items: center; justify-content: center;
}
.hp-top-card__info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.hp-top-card__info strong { font-size: .95rem; }
.hp-top-card__info small { font-size: .8rem; color: var(--text-muted); }
.hp-top-card__arrow {
  color: var(--text-muted); font-size: 1.1rem; flex-shrink: 0;
  transition: transform var(--transition);
}
.hp-top-card:hover .hp-top-card__arrow { transform: translateX(3px); color: var(--accent); }

/* Steps */
.hp-steps {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem; margin-top: 1.5rem;
}
.hp-step { text-align: center; }
.hp-step__icon {
  width: 64px; height: 64px; border-radius: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 1rem;
  background: var(--accent-soft);
  color: var(--accent);
}
.hp-step__icon svg { width: 28px; height: 28px; }
.hp-step h3 { font-size: 1.15rem; margin-bottom: .5rem; }
.hp-step p { font-size: .9rem; color: var(--text-muted); line-height: 1.5; }

/* CTA sections */
.hp-cta {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  color: #fff; padding: 3.5rem 1.25rem; text-align: center;
}
.hp-cta h2 { color: #fff; font-size: 1.75rem; margin-bottom: .75rem; }
.hp-cta p {
  color: rgba(255,255,255,.85); max-width: 560px;
  margin: 0 auto 1.5rem; font-size: 1.05rem;
}
.hp-cta--dark {
  background: linear-gradient(135deg, var(--accent-dark) 0%, #065f46 100%);
}

/* Alpha grid (A-Z provinces) */
.hp-alpha-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.25rem;
}
.hp-alpha-group__letter {
  font-size: 1.25rem; font-weight: 800; color: var(--accent);
  padding-bottom: .35rem; margin-bottom: .5rem;
  border-bottom: 2px solid var(--accent-soft);
}
.hp-alpha-link {
  display: flex; justify-content: space-between; align-items: center;
  padding: .3rem .5rem; font-size: .875rem; color: var(--text);
  border-radius: 6px; transition: all var(--transition); text-decoration: none;
}
.hp-alpha-link:hover { background: var(--accent-soft); color: var(--accent); }
.hp-alpha-link span { font-size: .75rem; color: var(--text-muted); font-weight: 600; }

/* Blog cards */
.hp-blog-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem;
}
.hp-blog-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.5rem; text-decoration: none; color: var(--text);
  transition: all var(--transition); display: flex; flex-direction: column;
}
.hp-blog-card:hover {
  box-shadow: var(--shadow-md); transform: translateY(-2px);
  border-color: var(--accent-light); color: var(--text);
}
.hp-blog-card__cat {
  display: inline-block; font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--accent-light); margin-bottom: .75rem;
}
.hp-blog-card h3 { font-size: 1.1rem; margin-bottom: .5rem; line-height: 1.35; }
.hp-blog-card p { font-size: .875rem; color: var(--text-muted); line-height: 1.5; flex: 1; }
.hp-blog-card__link {
  font-size: .85rem; font-weight: 600; color: var(--accent-light); margin-top: 1rem;
}

/* ----- 8. Cards (Residencia Listings) ----- */

.card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.card__image {
  position: relative; width: 100%;
  padding-top: 62.5%; /* 16:10 ratio */
  overflow: hidden; background: var(--bg);
}
.card__image img {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  object-fit: cover; transition: transform 0.3s ease;
}
.card:hover .card__image img { transform: scale(1.03); }

.card__image--placeholder {
  display: flex; align-items: center; justify-content: center;
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: linear-gradient(135deg, var(--accent-soft), var(--bg));
  color: var(--accent); font-size: 2.5rem;
}

.card__content { padding: 1.25rem; }

.card__name {
  font-weight: 700; font-size: 1.0625rem; margin-bottom: 0.5rem; line-height: 1.35;
}
.card__name a { color: var(--text); text-decoration: none; }
.card__name a:hover { color: var(--accent); }

.card__badges { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.75rem; }

.card__location {
  display: flex; align-items: flex-start; gap: 0.35rem;
  font-size: 0.875rem; color: var(--text-muted); margin-bottom: 0.5rem;
}
.card__location svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }

.card__plazas {
  font-size: 0.875rem; color: var(--text-muted); margin-bottom: 0.5rem;
}
.card__plazas strong { color: var(--text); font-weight: 600; }

.card__phone-teaser {
  font-size: 0.875rem; color: var(--text-muted); margin-bottom: 0.75rem;
}
.card__phone-teaser strong { color: var(--text); }

.card__cta { margin-top: 0.75rem; }

.card__footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1.25rem; border-top: 1px solid var(--border);
  font-size: 0.8125rem; color: var(--text-muted);
}

/* Card with render_card() */
.card { position: relative; display: flex; flex-direction: column; }
.card__img-link {
  display: block; position: relative; width: 100%;
  padding-top: 62.5%; overflow: hidden; background: var(--bg);
}
.card__img {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  object-fit: cover; transition: transform 0.3s ease;
}
.card:hover .card__img { transform: scale(1.03); }
.card__badge-premium {
  position: absolute; top: 0.5rem; left: 0.5rem;
  background: linear-gradient(135deg, #d97706, #f59e0b);
  color: #fff; font-size: 0.7rem; font-weight: 700;
  padding: 0.2rem 0.55rem; border-radius: 9999px;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.card__body {
  padding: 1.1rem 1.25rem 1.25rem; flex: 1; display: flex; flex-direction: column;
}
.card__title {
  font-weight: 700; font-size: 1rem; margin-bottom: 0.4rem; line-height: 1.35;
}
.card__title a { color: var(--text); text-decoration: none; }
.card__title a:hover { color: var(--accent); }
.card__phone {
  display: flex; align-items: center; gap: 0.3rem;
  font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.4rem;
}
.card__phone svg { flex-shrink: 0; }
.card__cta {
  display: inline-block; margin-top: auto; padding-top: 0.6rem;
  color: var(--accent); font-weight: 600; font-size: 0.875rem;
}
.card__cta:hover { color: var(--accent-dark); }
.fav-btn {
  position: absolute; top: 0.5rem; right: 0.5rem;
  background: rgba(255,255,255,.85); border-radius: 50%;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 2; transition: background var(--transition);
  border: none;
}
.fav-btn:hover { background: #fff; }
.fav-btn.active svg { fill: #ef4444; stroke: #ef4444; }

/* Premium card variant */
.card--premium {
  border-color: rgba(217, 119, 6, 0.3);
  box-shadow: 0 2px 12px rgba(217, 119, 6, 0.12);
}
.card--premium:hover {
  box-shadow: 0 4px 20px rgba(217, 119, 6, 0.18);
}

/* ----- 9. Badges ----- */

.badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  font-size: 0.75rem; font-weight: 600;
  padding: 0.2rem 0.6rem; border-radius: 9999px;
  line-height: 1.4;
}

.badge-premium {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #fff;
  box-shadow: 0 1px 4px rgba(217, 119, 6, 0.3);
  text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.7rem;
}
.badge-premium svg { width: 12px; height: 12px; }

.badge-verified {
  background: rgba(5, 150, 105, 0.1); color: var(--accent);
}

.badge-tipo {
  background: var(--blue-soft); color: var(--blue);
}
.badge-tipo--centro-dia {
  background: var(--orange-soft); color: var(--orange);
}

.badge-plazas {
  background: var(--accent-soft); color: var(--accent);
}

.badge-gold {
  background: var(--gold-soft); color: var(--gold);
}

/* ----- 10. Listing Grid (Directory) ----- */

.listing-section { padding: 3rem 0; }
.listing-section h2 { margin-bottom: 1.5rem; }

.listing-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

/* Results bar (count + sort) */
.results-bar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: .75rem; margin-bottom: 1.25rem;
}
.results-sort { display: flex; align-items: center; gap: .4rem; }
.results-sort label {
  font-size: .85rem; color: var(--text-muted); font-weight: 500; white-space: nowrap;
}
.results-sort select {
  padding: .4rem .7rem; font-size: .85rem; border: 1px solid var(--border);
  border-radius: 6px; background: var(--card-bg); color: var(--text); cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .5rem center; padding-right: 1.75rem;
}

/* Residencia card (list-style, alternative to .card) */
.residencia-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-left: 4px solid var(--accent-light);
  border-radius: var(--radius); padding: 1.25rem 1.5rem;
  transition: box-shadow var(--transition), transform var(--transition);
}
.residencia-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.residencia-card--premium {
  border-left-color: var(--gold);
  box-shadow: 0 2px 12px rgba(217, 119, 6, .12);
  position: relative;
}
.residencia-card--premium:hover {
  box-shadow: 0 4px 20px rgba(217, 119, 6, .18);
}

.residencia-card__header {
  display: flex; align-items: center; gap: .75rem; margin-bottom: .6rem;
}
.residencia-card__header-text { flex: 1; min-width: 0; }

.residencia-card__avatar {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-light)); flex-shrink: 0;
}
.residencia-card__avatar--premium {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}
.residencia-card__avatar--foto {
  object-fit: cover; border: 2px solid var(--gold);
  box-shadow: 0 2px 8px rgba(217,119,6,.2);
}

.residencia-card__name { font-weight: 700; font-size: 1.0625rem; margin-bottom: 0.25rem; }
.residencia-card__name a { color: var(--text); }
.residencia-card__name a:hover { color: var(--accent); }

.residencia-card__meta { font-size: 0.875rem; color: var(--text-muted); line-height: 1.6; }
.residencia-card__meta dt { display: inline; font-weight: 600; color: var(--text); }
.residencia-card__meta dt::after { content: ": "; }
.residencia-card__meta dd { display: inline; margin: 0; }
.residencia-card__meta dd::after { content: ""; display: block; }

.residencia-card__link {
  display: inline-block; margin-top: 0.5rem;
  font-size: 0.8125rem; font-weight: 600;
  color: var(--accent-light); text-decoration: none;
}
.residencia-card__link:hover { text-decoration: underline; color: var(--accent); }

.residencia-card__premium-badge {
  position: absolute;
  top: .65rem; right: .75rem;
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #fff; font-size: .7rem; font-weight: 700;
  padding: .15rem .55rem; border-radius: 20px;
  text-transform: uppercase; letter-spacing: .04em;
  box-shadow: 0 1px 4px rgba(217, 119, 6, .3);
}

/* ----- 11. Ficha Page (Detail) ----- */

.ficha-header { padding: 2.5rem 0 1.5rem; }
.ficha-header h1 { font-size: 2rem; margin-bottom: 0.75rem; }
.ficha-header__badges { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }

.ficha-body {
  display: grid; grid-template-columns: 2fr 1fr; gap: 2rem; padding-bottom: 3rem;
}

/* Image gallery area */
.ficha-gallery {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 1.5rem;
}
.ficha-gallery__main {
  position: relative; width: 100%; padding-top: 56.25%;
  overflow: hidden; background: var(--bg);
}
.ficha-gallery__main img {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  object-fit: cover;
}
.ficha-gallery__thumbs {
  display: flex; gap: 0.5rem; padding: 0.75rem;
  overflow-x: auto;
}
.ficha-gallery__thumb {
  width: 72px; height: 54px; border-radius: 6px; overflow: hidden;
  flex-shrink: 0; cursor: pointer; border: 2px solid transparent;
  transition: border-color var(--transition);
}
.ficha-gallery__thumb.active,
.ficha-gallery__thumb:hover { border-color: var(--accent); }
.ficha-gallery__thumb img { width: 100%; height: 100%; object-fit: cover; }

/* Info sections */
.ficha-data {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.5rem;
}
.ficha-data h2 {
  font-size: 1.125rem; margin-bottom: 1rem;
  padding-bottom: 0.75rem; border-bottom: 1px solid var(--border);
}
.ficha-data table { width: 100%; border-collapse: collapse; }
.ficha-data th, .ficha-data td {
  padding: 0.55rem 0.5rem; font-size: 0.9rem;
  text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.ficha-data th { font-weight: 600; color: var(--text-muted); width: 35%; white-space: nowrap; }
.ficha-data td { color: var(--text); }
.ficha-data tr:last-child th, .ficha-data tr:last-child td { border-bottom: none; }
.ficha-data td, .ficha-data dd { word-break: break-word; overflow-wrap: anywhere; }

/* Ficha sidebar */
.ficha-sidebar { position: sticky; top: 80px; }

/* Ficha map */
.ficha-map {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 1.5rem;
}
.ficha-map h2 { font-size: 1.125rem; padding: 1.25rem 1.5rem 1rem; }
.ficha-map__container { position: relative; width: 100%; height: 300px; }
.ficha-map__container iframe {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0;
}

/* ----- 12. Province Grid ----- */

.province-section { padding: 3rem 0; }
.province-section h2 { margin-bottom: 1.5rem; }

.province-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.province-card {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.25rem;
  text-decoration: none; color: var(--text);
  transition: box-shadow var(--transition), transform var(--transition);
}
.province-card:hover {
  box-shadow: var(--shadow-md); transform: translateY(-2px); color: var(--accent);
}
.province-card__name { font-weight: 600; font-size: 1rem; }
.province-card__count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2rem; height: 1.75rem; padding: 0 0.5rem;
  background: var(--accent-soft); color: var(--accent);
  font-size: 0.8125rem; font-weight: 600; border-radius: 9999px;
}

/* ----- 13. Breadcrumb ----- */

.breadcrumb {
  padding: 1rem 0; font-size: 0.875rem; color: var(--text-muted);
  background: var(--bg);
}
.breadcrumb .container { padding-top: 0; padding-bottom: 0; }
.breadcrumb ol { display: flex; flex-wrap: wrap; align-items: center; gap: 0; }
.breadcrumb li { display: inline-flex; align-items: center; }
.breadcrumb li + li::before { content: "/"; margin: 0 0.5rem; color: var(--border); }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb li:last-child { color: var(--text); font-weight: 500; }

/* ----- 14. Pagination ----- */

.pagination {
  display: flex; justify-content: center; align-items: center;
  gap: 0.375rem; padding: 2rem 0; flex-wrap: wrap;
}
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2.5rem; height: 2.5rem; padding: 0 0.75rem;
  font-size: 0.875rem; font-weight: 500;
  border-radius: calc(var(--radius) - 4px);
  border: 1px solid var(--border); background: var(--card-bg); color: var(--text);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.pagination a:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination .current, .pagination .active {
  background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700;
}
.pagination .dots {
  border: none; background: transparent; color: var(--text-muted);
  min-width: auto; padding: 0 0.25rem;
}

/* ----- 15. Buttons ----- */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.5rem; padding: 0.625rem 1.25rem;
  font-size: 0.9375rem; font-weight: 600;
  border-radius: calc(var(--radius) - 4px);
  border: 1px solid var(--border); background: var(--card-bg); color: var(--text);
  cursor: pointer; text-decoration: none; line-height: 1.4;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), box-shadow var(--transition);
}
.btn:hover { background: var(--bg); border-color: var(--text-muted); color: var(--text); }

.btn-primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-dark); border-color: var(--accent-dark); color: #fff;
  box-shadow: 0 2px 8px rgba(4, 120, 87, 0.25);
}

.btn-lg { padding: 0.875rem 1.75rem; font-size: 1.0625rem; }

.btn-gold {
  background: var(--gold); color: #fff; border-color: var(--gold);
}
.btn-gold:hover {
  background: #b45309; border-color: #b45309; color: #fff;
}

.btn-white {
  background: #fff; color: var(--accent); border-color: #fff;
}
.btn-white:hover {
  background: rgba(255,255,255,.9); border-color: rgba(255,255,255,.9);
}

/* ----- 16. Forms ----- */

.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block; font-size: 0.875rem; font-weight: 600;
  color: var(--text); margin-bottom: 0.35rem;
}

.form-control {
  width: 100%; padding: 0.75rem 1rem;
  border: 1px solid var(--border); border-radius: calc(var(--radius) - 4px);
  font-size: 1rem; color: var(--text); background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

textarea.form-control { min-height: 120px; resize: vertical; }

select.form-control {
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.75rem center;
  padding-right: 2.25rem;
}

.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }

/* Lead form (sidebar CTA) */
.lead-form {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
}
.lead-form h3 {
  font-size: 1.125rem; margin-bottom: 0.25rem;
}
.lead-form p {
  font-size: 0.875rem; color: var(--text-muted); margin-bottom: 1.25rem;
}
.lead-form .btn-primary { width: 100%; justify-content: center; }

/* Presupuesto form (full-page) */
.presupuesto-section { padding: 3rem 0; }
.presupuesto-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 2.5rem; align-items: start;
}
.presupuesto-form {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2rem;
}
.presupuesto-form h2 { font-size: 1.375rem; margin-bottom: 0.5rem; }
.presupuesto-form > p {
  font-size: 0.9rem; color: var(--text-muted); margin-bottom: 1.5rem;
}
.presupuesto-info {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2rem;
}

/* ----- 17. Footer ----- */

.site-footer {
  background: var(--accent-dark); color: rgba(255,255,255,0.7);
  padding: 3rem 0 0; margin-top: 3rem;
}
.footer-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem;
  max-width: 1200px; margin: 0 auto; padding: 0 1.25rem 2rem;
}
.footer-grid h3, .footer-grid h4 { color: #fff; font-size: 1rem; margin-bottom: 1rem; }
.footer-grid ul { display: flex; flex-direction: column; gap: 0.5rem; }
.footer-grid a {
  color: rgba(255,255,255,0.6); font-size: 0.875rem;
  transition: color var(--transition);
}
.footer-grid a:hover { color: #fff; }
.footer-grid p { font-size: 0.875rem; line-height: 1.6; }

.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  max-width: 1200px; margin: 0 auto;
  padding: 1.25rem 1.25rem; font-size: 0.8125rem; color: rgba(255,255,255,0.45);
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem;
}
.footer-bottom a { color: rgba(255,255,255,0.45); }
.footer-bottom a:hover { color: #fff; }

/* ----- 18. No Results ----- */

.no-results { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.no-results svg { margin: 0 auto 1rem; opacity: 0.5; }
.no-results h3 { margin-bottom: 0.5rem; color: var(--text); }

/* ----- 19. Overflow fix ----- */

html, body { overflow-x: hidden; max-width: 100vw; }

/* ----- 20. Responsive ----- */

@media (max-width: 1024px) {
  .listing-grid { grid-template-columns: repeat(2, 1fr); }
  .hp-top-grid { grid-template-columns: repeat(2, 1fr); }
  .hp-blog-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .ficha-body { grid-template-columns: 1fr; }
  .ficha-sidebar { position: static; }
}

@media (max-width: 768px) {
  .nav-toggle { display: flex; }
  .main-nav {
    display: none; position: absolute; top: 64px; left: 0; right: 0;
    background: var(--card-bg); border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow); z-index: 99;
  }
  .main-nav.open { display: block; }
  .main-nav ul { flex-direction: column; gap: 0; padding: 0.5rem 0; }
  .main-nav a { display: block; padding: 0.75rem 1.5rem; font-size: 1rem; }
  .main-nav a:hover { background: var(--bg); }

  .hero { padding: 2.5rem 1rem 2rem; }
  .hero h1 { font-size: 1.85rem; }
  .hero__subtitle { font-size: 1rem; margin-bottom: 1.5rem; }
  .hero__trust { gap: .75rem; }

  .search-box { padding: 1rem; }
  .search-form { flex-direction: column; }
  .search-form input[type="text"],
  .search-form input[type="search"],
  .search-form select,
  .search-form input[list] { flex: 1 1 auto; width: 100%; }
  .search-form .btn-search { width: 100%; justify-content: center; }

  .hp-steps { grid-template-columns: 1fr; gap: 1.5rem; }
  .hp-top-grid { grid-template-columns: 1fr; }
  .hp-blog-grid { grid-template-columns: 1fr; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
  .listing-grid { grid-template-columns: 1fr; }
  .province-grid { grid-template-columns: 1fr; }

  .presupuesto-grid { grid-template-columns: 1fr; gap: 1.5rem; }

  .footer-grid { grid-template-columns: 1fr; gap: 1.5rem; }
  .footer-bottom { flex-direction: column; text-align: center; }

  .stats-section, .province-section, .listing-section { padding: 2rem 0; }

  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }

  .ficha-gallery__main { padding-top: 66%; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 1.5rem; }
  .header-inner { height: 56px; }
  .main-nav { top: 56px; }
  .container { padding: 0 0.75rem; }
  .hp-alpha-grid { grid-template-columns: repeat(2, 1fr); }

  .card__content { padding: 1rem; }
  .lead-form { padding: 1rem; }
  .presupuesto-form { padding: 1.25rem; }
}

/* ----- 21. Print ----- */

@media print {
  .site-header, .site-footer, .nav-toggle, .search-box,
  .pagination, .lead-form, .hp-cta { display: none; }
  body { background: #fff; color: #000; }
  .hero { background: none; color: #000; padding: 1rem 0; }
  .hero h1 { color: #000; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  .card:hover { transform: none; }
}
