/* =========================================================
   Puganova — Hoja de estilos principal
   ========================================================= */

:root {
  --color-primary: #12314d;
  --color-primary-light: #1d4a72;
  --color-accent: #c8963e;
  --color-accent-light: #e0b56a;
  --color-bg: #f7f8fa;
  --color-surface: #ffffff;
  --color-text: #1f2937;
  --color-text-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-success-bg: #e7f7ee;
  --color-success-text: #15803d;
  --color-error-bg: #fdecec;
  --color-error-text: #b91c1c;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 2px 10px rgba(18, 49, 77, 0.08);
  --shadow-lg: 0 12px 32px rgba(18, 49, 77, 0.14);
  --max-width: 1200px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
}

img { max-width: 100%; display: block; }

a { color: inherit; text-decoration: none; }

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; font-weight: 700; color: var(--color-primary); }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: var(--radius); font-weight: 600; font-size: 15px;
  border: 2px solid transparent; cursor: pointer; transition: all .15s ease;
}
.btn-primary { background: var(--color-accent); color: #fff; }
.btn-primary:hover { background: var(--color-accent-light); }
.btn-secondary { background: var(--color-primary); color: #fff; }
.btn-secondary:hover { background: var(--color-primary-light); }
.btn-outline { background: transparent; border-color: currentColor; }
.btn-outline:hover { background: rgba(0,0,0,.05); }
.btn-danger { background: #b91c1c; color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 14px; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }

/* ---------- Header ---------- */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky; top: 0; z-index: 50;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 72px; gap: 24px; }
.logo { font-size: 24px; font-weight: 800; color: var(--color-primary); white-space: nowrap; }
.logo span { color: var(--color-accent); }
.main-nav { display: flex; align-items: center; gap: 20px; margin-left: auto; flex-wrap: wrap; }
.main-nav a { font-weight: 600; color: var(--color-text); padding: 6px 2px; border-bottom: 2px solid transparent; }
.main-nav a.active, .main-nav a:hover { color: var(--color-primary); border-color: var(--color-accent); }
.nav-user { display: flex; align-items: center; gap: 10px; padding-left: 12px; border-left: 1px solid var(--color-border); }
.nav-icon-link { white-space: nowrap; }
.nav-toggle { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: 8px; }
.nav-toggle span { width: 26px; height: 3px; background: var(--color-primary); border-radius: 2px; }

/* ---------- Flash messages ---------- */
.flash { padding: 14px 0; font-weight: 600; }
.flash-success { background: var(--color-success-bg); color: var(--color-success-text); }
.flash-error { background: var(--color-error-bg); color: var(--color-error-text); }
.flash .container { display: block; }

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, var(--color-primary) 0%, #0a1f33 100%);
  color: #fff; padding: 70px 0 90px; text-align: center;
}
.hero h1 { color: #fff; font-size: clamp(28px, 5vw, 48px); margin-bottom: 14px; }
.hero p { font-size: 18px; color: #cfd9e3; max-width: 620px; margin: 0 auto 32px; }

.search-box {
  background: var(--color-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 22px; max-width: 900px; margin: 0 auto; text-align: left;
}
.search-box form { display: grid; grid-template-columns: repeat(4, 1fr) auto; gap: 12px; align-items: end; }
.search-box .field { display: flex; flex-direction: column; gap: 6px; }
.search-box label { font-size: 13px; font-weight: 600; color: var(--color-text-muted); }

/* ---------- Formularios ---------- */
input, select, textarea {
  font-family: inherit; font-size: 15px; padding: 11px 14px; border: 1px solid var(--color-border);
  border-radius: 8px; background: #fff; color: var(--color-text); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--color-primary-light); box-shadow: 0 0 0 3px rgba(29,74,114,.15); }
label { font-weight: 600; font-size: 14px; margin-bottom: 4px; display: inline-block; }
.form-group { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.form-hint { font-size: 13px; color: var(--color-text-muted); margin-top: 4px; }
.form-error { font-size: 13px; color: var(--color-error-text); margin-top: 4px; }
fieldset { border: 1px solid var(--color-border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
legend { font-weight: 700; color: var(--color-primary); padding: 0 8px; }

/* ---------- Tarjetas de propiedad ---------- */
.section { padding: 56px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 28px; flex-wrap: wrap; gap: 8px; }
.section-head p { color: var(--color-text-muted); margin: 0; }

.property-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px;
}
.property-card {
  background: var(--color-surface); border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow); transition: transform .18s ease, box-shadow .18s ease;
  display: flex; flex-direction: column; position: relative;
}
.property-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.property-card .thumb { position: relative; aspect-ratio: 4/3; overflow: hidden; background: #ddd; }
.property-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.badge {
  display: inline-block; padding: 4px 10px; border-radius: 100px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em;
}
.badge-venta { background: #12314d; color: #fff; }
.badge-renta { background: var(--color-accent); color: #fff; }
.badge-featured { background: #fff; color: var(--color-primary); }
.thumb .badges { position: absolute; top: 12px; left: 12px; display: flex; gap: 6px; }
.fav-btn {
  position: absolute; top: 10px; right: 10px; width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,.92); border: none; cursor: pointer; font-size: 18px; color: #b91c1c;
  display: flex; align-items: center; justify-content: center;
}
.property-card .body { padding: 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.property-card .price { font-size: 20px; font-weight: 800; color: var(--color-primary); }
.property-card .title { font-size: 16px; font-weight: 700; margin: 0; }
.property-card .location { color: var(--color-text-muted); font-size: 14px; }
.property-card .meta { display: flex; gap: 14px; font-size: 14px; color: var(--color-text-muted); margin-top: auto; padding-top: 10px; border-top: 1px solid var(--color-border); }

/* ---------- Filtros de búsqueda (listado) ---------- */
.listing-layout { display: grid; grid-template-columns: 280px 1fr; gap: 32px; align-items: start; }
.filters-panel { background: var(--color-surface); border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow); position: sticky; top: 90px; }
.filters-panel h3 { font-size: 17px; margin-bottom: 16px; }
.results-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.results-bar .count { color: var(--color-text-muted); }

/* ---------- Paginación ---------- */
.pagination { display: flex; gap: 8px; justify-content: center; margin-top: 36px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 9px 15px; border-radius: 8px; border: 1px solid var(--color-border); background: #fff; font-weight: 600;
}
.pagination a:hover { border-color: var(--color-primary); }
.pagination .active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.pagination .disabled { opacity: .4; pointer-events: none; }

/* ---------- Detalle de propiedad ---------- */
.gallery { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 32px; }
.gallery .main-img { aspect-ratio: 16/11; }
.gallery .main-img img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.gallery .thumbs { display: grid; grid-template-rows: repeat(2, 1fr); gap: 10px; }
.gallery .thumbs img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; aspect-ratio: 16/8; }

.detail-layout { display: grid; grid-template-columns: 2fr 1fr; gap: 40px; align-items: start; }
.detail-header { display: flex; justify-content: space-between; align-items: start; gap: 16px; margin-bottom: 8px; flex-wrap: wrap; }
.detail-price { font-size: 30px; font-weight: 800; color: var(--color-primary); }
.detail-specs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 24px 0; padding: 20px 0; border-top: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); }
.spec-item { text-align: center; }
.spec-item .value { font-size: 20px; font-weight: 800; color: var(--color-primary); display: block; }
.spec-item .label { font-size: 13px; color: var(--color-text-muted); }
.features-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; list-style: none; padding: 0; }
.features-list li:before { content: "✓ "; color: var(--color-accent); font-weight: 800; }

.agent-card { background: var(--color-surface); border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow); position: sticky; top: 90px; }
.agent-card .agent-info { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.agent-card img { width: 60px; height: 60px; border-radius: 50%; object-fit: cover; }
.agent-card .agent-name { font-weight: 700; }
.agent-card .agent-agency { font-size: 13px; color: var(--color-text-muted); }

/* ---------- Auth / cuentas ---------- */
.auth-wrapper { max-width: 460px; margin: 60px auto; background: var(--color-surface); padding: 36px; border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.auth-wrapper h1 { text-align: center; }
.auth-switch { text-align: center; margin-top: 16px; font-size: 14px; color: var(--color-text-muted); }
.role-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.role-picker label {
  border: 2px solid var(--color-border); border-radius: var(--radius); padding: 14px; text-align: center;
  cursor: pointer; font-weight: 600; display: block;
}
.role-picker input { width: auto; display: inline; }
.role-picker input:checked + span, .role-picker label:has(input:checked) { border-color: var(--color-primary); }

/* ---------- Panel de agente ---------- */
.dashboard-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 32px; }
.stat-card { background: var(--color-surface); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow); }
.stat-card .value { font-size: 28px; font-weight: 800; color: var(--color-primary); }
.stat-card .label { color: var(--color-text-muted); font-size: 14px; }

.table-wrapper { overflow-x: auto; background: var(--color-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--color-border); font-size: 14px; }
th { color: var(--color-text-muted); font-size: 13px; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
.table-thumb { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; }
.status-pill { padding: 3px 10px; border-radius: 100px; font-size: 12px; font-weight: 700; }
.status-disponible { background: #e7f7ee; color: #15803d; }
.status-vendido, .status-rentado { background: #eef2ff; color: #4338ca; }
.status-pausado { background: #f3f4f6; color: #6b7280; }
.action-links { display: flex; gap: 10px; }
.action-links form { display: inline; }
.action-links button { background: none; border: none; padding: 0; color: #b91c1c; cursor: pointer; font-weight: 600; font-size: 14px; }

.image-upload-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 10px; }
.image-upload-grid .existing-img { position: relative; border-radius: 8px; overflow: hidden; aspect-ratio: 1; }
.image-upload-grid .existing-img img { width: 100%; height: 100%; object-fit: cover; }
.image-upload-grid .existing-img label { position: absolute; bottom: 6px; left: 6px; background: rgba(0,0,0,.6); color: #fff; padding: 2px 8px; border-radius: 100px; font-size: 11px; }

/* ---------- Tarjetas genéricas / empty state ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--color-text-muted); }
.empty-state h3 { color: var(--color-text); }

.info-card { background: var(--color-surface); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow); }

/* ---------- Página Acerca / Contacto ---------- */
.page-hero { background: var(--color-primary); color: #fff; padding: 48px 0; text-align: center; }
.page-hero h1 { color: #fff; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: center; }
.contact-methods { display: grid; gap: 16px; margin-top: 20px; }
.contact-method { display: flex; gap: 14px; align-items: flex-start; }
.contact-method .icon { font-size: 22px; }

/* ---------- Utilidades ---------- */
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.muted { color: var(--color-text-muted); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .property-grid { grid-template-columns: repeat(2, 1fr); }
  .listing-layout { grid-template-columns: 1fr; }
  .filters-panel { position: static; }
  .detail-layout { grid-template-columns: 1fr; }
  .agent-card { position: static; }
  .dashboard-stats { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .nav-toggle { display: flex; }
  .main-nav {
    display: none; position: absolute; top: 72px; left: 0; right: 0; background: #fff;
    flex-direction: column; align-items: stretch; padding: 16px 20px; border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow);
  }
  .main-nav.open { display: flex; }
  .nav-user { border-left: none; padding-left: 0; border-top: 1px solid var(--color-border); padding-top: 12px; margin-top: 8px; }
  .search-box form { grid-template-columns: 1fr; }
  .property-grid { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .detail-specs { grid-template-columns: repeat(2, 1fr); }
  .gallery { grid-template-columns: 1fr; }
  .gallery .thumbs { grid-template-rows: unset; grid-template-columns: repeat(2, 1fr); }
  .dashboard-stats { grid-template-columns: 1fr; }
  .image-upload-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Lightbox ---------- */
.lightbox-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.9); display: none; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
}
.lightbox-overlay.open { display: flex; }
.lightbox-overlay img { max-width: 100%; max-height: 90vh; border-radius: 8px; }
.lightbox-close { position: absolute; top: 20px; right: 30px; color: #fff; font-size: 32px; background: none; border: none; cursor: pointer; }
