/* Los colores (--fg, --bg, --accent, etc.) los define el tema activo en
   css/themes/*.css, cargado después de este archivo — ver includes/header.php
   e includes/themes.php. Este archivo es solo estructura/layout. */
:root {
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
  width: 100%;
}

a { color: inherit; }

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
}
.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; text-decoration: none; }
.brand img { display: block; width: 32px; height: auto; }
.main-nav { display: flex; gap: 16px; font-size: 14px; align-items: center; }
.main-nav a { text-decoration: none; }
.main-nav a:hover { text-decoration: underline; }
.nav-toggle {
  display: none;
  background: none; border: none; font-size: 22px; line-height: 1;
  cursor: pointer; color: var(--fg); padding: 4px 6px;
}
@media (max-width: 720px) {
  .site-header-inner { flex-wrap: wrap; }
  .nav-toggle { display: block; }
  .main-nav {
    display: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    padding: 8px 0 12px;
  }
  .main-nav.is-open { display: flex; }
  .main-nav a { display: block; width: 100%; padding: 8px 4px; }
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 40px;
  padding: 20px 0;
  color: var(--muted);
  font-size: 13px;
}

main.wrap { flex: 1; padding-top: 32px; padding-bottom: 48px; }

/* Flash messages */
.flash { padding: 10px 14px; border-radius: var(--radius); margin: 16px 0; font-size: 14px; }
.flash-success { background: #dcfce7; color: #14532d; }
.flash-error { background: #fee2e2; color: #7f1d1d; }
@media (prefers-color-scheme: dark) {
  .flash-success { background: #14532d; color: #dcfce7; }
  .flash-error { background: #7f1d1d; color: #fee2e2; }
}

/* Typography */
h1 { font-size: 28px; margin: 0 0 8px; }
h2 { font-size: 16px; margin: 0 0 8px; color: var(--muted); }
.lead { color: var(--muted); max-width: 560px; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* Forms */
form.stack { display: flex; flex-direction: column; gap: 14px; max-width: 420px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 13px; font-weight: 500; }
.field .hint { font-size: 12px; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"],
input[type="url"], input[type="number"], input[type="time"], input[type="file"],
select, textarea {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  width: 100%;
}
textarea { resize: vertical; }
.row { display: flex; gap: 12px; }
.row > .field { flex: 1; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--fg); }
.btn-green { background: var(--green); color: #fff; }
.btn-red { background: var(--red); color: #fff; }
.btn-amber { background: var(--amber); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-link { background: none; border: none; padding: 0; text-decoration: underline; cursor: pointer; color: inherit; font: inherit; }

/* Cards / lists */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } .row { flex-direction: column; } }

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card + .card { margin-top: 12px; }
.card h3 { margin: 0 0 4px; font-size: 16px; }
.card .meta { color: var(--muted); font-size: 13px; margin: 2px 0; }

/* Animaciones — solo si la función "card_animations" está activa
 * (admin/funciones.php agrega .fx-on en <body>). Respeta
 * prefers-reduced-motion. */
body.fx-on .card {
  transition: transform .15s ease, box-shadow .15s ease;
}
body.fx-on .card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
}
body.fx-on .card img { transition: opacity .3s ease; }
body.fx-on .gallery img, body.fx-on [data-lightbox] {
  transition: transform .15s ease;
  cursor: zoom-in;
}
body.fx-on .gallery img:hover, body.fx-on [data-lightbox]:hover {
  transform: scale(1.05);
}
@media (prefers-reduced-motion: reduce) {
  body.fx-on .card, body.fx-on .card:hover, body.fx-on .gallery img, body.fx-on [data-lightbox] {
    transition: none; transform: none;
  }
}

.lightbox-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; opacity: 0; transition: opacity .2s ease; cursor: zoom-out;
}
.lightbox-overlay.is-open { opacity: 1; }
.lightbox-overlay img {
  max-width: 90vw; max-height: 90vh; border-radius: var(--radius);
  transform: scale(.92); transition: transform .2s ease;
}
.lightbox-overlay.is-open img { transform: scale(1); }

/* Search bar */
.search-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.search-bar input[type="text"] { flex: 1; min-width: 200px; }
.search-bar select { width: auto; }

/* Hero de portada — banda de color (o foto de portada, si se sube una
 * desde Diseño) con el encabezado del sitio. En inmobiliaria envuelve
 * también la barra de búsqueda (protagonista, como raudarealestate.com);
 * en directorio/blog envuelve solo el encabezado. var(--navy) con
 * respaldo a var(--accent) porque el tema Predeterminado no define --navy. */
.hero-band {
  position: relative;
  background: var(--navy, var(--accent));
  background-size: cover;
  background-position: center;
  color: #fff;
  border-radius: var(--radius);
  padding: 32px 24px;
  margin-bottom: 24px;
  overflow: hidden;
}
.hero-band.has-cover::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(rgba(0,0,0,0.45), rgba(0,0,0,0.45));
}
.hero-band > * { position: relative; z-index: 1; }
.hero-band h1, .hero-band .lead { color: #fff; }
.hero-band .lead { opacity: .85; max-width: none; }
.hero-band .search-bar { margin-bottom: 0; }
.hero-band .search-bar input, .hero-band .search-bar select { border: none; }

/* Tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.tab { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border); font-size: 13px; text-decoration: none; cursor: pointer; background: transparent; color: inherit; font: inherit; }
.tab.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

/* Chip — insignias y etiquetas (categorías, "Nuevo", tags de blog). Estilo
 * base genérico aquí; algunos temas lo redefinen para su paleta. */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--navy, var(--accent)); color: #fff;
  border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 500;
}

/* Admin shell */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar { width: 220px; flex-shrink: 0; border-right: 1px solid var(--border); padding: 20px; }
.admin-sidebar nav { display: flex; flex-direction: column; gap: 2px; font-size: 14px; margin-top: 20px; }
.admin-sidebar nav a { padding: 6px 8px; border-radius: 6px; text-decoration: none; }
.admin-sidebar nav a:hover { background: var(--border); }
.admin-content { flex: 1; padding: 24px; min-width: 0; }
.admin-user-box { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }

@media (max-width: 860px) {
  .admin-shell { flex-direction: column; min-height: 0; }
  .admin-sidebar {
    width: 100%; border-right: none; border-bottom: 1px solid var(--border);
    padding: 14px 16px;
  }
  .admin-sidebar nav {
    flex-direction: row; flex-wrap: nowrap; overflow-x: auto;
    margin-top: 12px; gap: 4px; padding-bottom: 4px; -webkit-overflow-scrolling: touch;
  }
  .admin-sidebar nav a { white-space: nowrap; }
  .admin-user-box { margin-top: 12px; padding-top: 12px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
  .admin-user-box p { margin: 0 !important; }
  .admin-content { padding: 16px; }
}

/* Cualquier tabla se vuelve deslizable horizontal en vez de desbordar la
 * pantalla (paneles de admin con muchas columnas, en celulares angostos). */
.admin-content table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.stat-grid .card { text-align: center; }
.stat-grid .stat-value { font-size: 24px; font-weight: 600; }
.stat-grid .stat-label { color: var(--muted); font-size: 13px; }
@media (max-width: 640px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }

.gallery { display: flex; flex-wrap: wrap; gap: 8px; }
.gallery img { width: 90px; height: 90px; object-fit: cover; border-radius: 6px; }
.gallery .thumb { position: relative; }
.gallery .thumb .remove {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--accent); color: var(--accent-fg);
  border: none; cursor: pointer; font-size: 12px; line-height: 1;
}

/* Galería de la ficha pública (negocio.php): tira horizontal con scroll y
 * botones ‹ › a los costados, en vez de envolver en varias filas. */
.gallery-wrap { position: relative; padding: 0 32px; }
.gallery-scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: 4px;
}
.gallery-scroll img {
  width: 220px; height: 220px; flex: 0 0 auto;
  scroll-snap-align: start;
  border-radius: var(--radius);
}
@media (max-width: 640px) { .gallery-scroll img { width: 160px; height: 160px; } }
.gallery-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--bg); color: var(--fg); font-size: 18px; line-height: 1;
  cursor: pointer; z-index: 2; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.gallery-nav-prev { left: 0; }
.gallery-nav-next { right: 0; }
.gallery-nav:disabled { opacity: .3; cursor: default; }
.gallery-nav:hover:not(:disabled) { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
@media (max-width: 640px) {
  .gallery-wrap { padding: 0 34px; }
  .gallery-nav { width: 30px; height: 30px; font-size: 15px; }
}

/* Botón flotante de WhatsApp (includes/footer.php) — fijo en la esquina,
 * visible en todo el sitio si hay un número configurado en Ajustes. */
.whatsapp-float {
  position: fixed; right: 18px; bottom: 18px; z-index: 900;
  width: 52px; height: 52px; border-radius: 50%;
  background: #25D366; color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 12px rgba(0,0,0,0.25);
  transition: transform .15s ease;
}
.whatsapp-float:hover { transform: scale(1.06); }
@media (max-width: 640px) {
  .whatsapp-float { right: 14px; bottom: 14px; width: 46px; height: 46px; }
  .whatsapp-float svg { width: 24px; height: 24px; }
}

/* Flechas de navegación dentro del lightbox (fotos siguiente/anterior). */
.lightbox-nav {
  position: fixed; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border-radius: 50%; border: none;
  background: rgba(255,255,255,0.15); color: #fff; font-size: 22px; line-height: 1;
  cursor: pointer; z-index: 1001;
}
.lightbox-nav:hover { background: rgba(255,255,255,0.3); }
.lightbox-nav-prev { left: 16px; }
.lightbox-nav-next { right: 16px; }

/* Utilidades de layout para plantillas por tema (theme-templates/) — capas
 * genéricas de estructura, sin color propio, para que cualquier tema las
 * pueda usar armando una portada con otra forma (panel lateral, filas de
 * listado, barra lateral de widgets…) en vez del layout por defecto. */
.layout-sidebar { display: grid; grid-template-columns: 260px 1fr; gap: 28px; align-items: start; }
@media (max-width: 800px) { .layout-sidebar { grid-template-columns: 1fr; } }

.filter-panel { position: sticky; top: 16px; }
.filter-panel .field { margin-bottom: 12px; }
.filter-panel .field:last-child { margin-bottom: 0; }
/* En columna única (ver .layout-sidebar arriba) el panel de filtros
 * queda apilado ARRIBA de los resultados, no al costado — dejarlo
 * "sticky" ahí lo mantendría pegado a la pantalla mientras se
 * desplazan los resultados debajo, tapándolos. Solo tiene sentido
 * fijo cuando de verdad está al costado (2 columnas). */
@media (max-width: 800px) { .filter-panel { position: static; } }

.sidebar-widget h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin: 0 0 10px; }
.sidebar-widget + .sidebar-widget { margin-top: 20px; }
.sidebar-widget .widget-list { list-style: none; margin: 0; padding: 0; }
.sidebar-widget .widget-list li { margin-bottom: 10px; font-size: 14px; }
.sidebar-widget .widget-list a { text-decoration: none; }
.sidebar-widget .widget-list a:hover { text-decoration: underline; }

.listing-row {
  display: flex; gap: 16px; padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.listing-row:first-child { padding-top: 0; }
.listing-row img { width: 140px; height: 105px; object-fit: cover; border-radius: var(--radius); flex-shrink: 0; }
.listing-row .listing-body { flex: 1; min-width: 0; }
.listing-row h3 { margin: 0 0 4px; }
@media (max-width: 560px) { .listing-row { flex-direction: column; } .listing-row img { width: 100%; height: 160px; } }
