/* ============================================================
   PANEL DE ADMINISTRACIÓN — INMOBILIARIA VALDIVIA
   ============================================================ */

:root {
  --primary:      #1B4332;
  --primary-dark: #0D2318;
  --accent:       #C9A84C;
  --accent-light: #E5C96A;
  --sidebar-w:    240px;
  --white:        #FFFFFF;
  --cream:        #F8F5EF;
  --gray:         #F0F2F5;
  --border:       #E5E7EB;
  --text:         #1C2B22;
  --muted:        #6B7280;
  --danger:       #DC2626;
  --success:      #16A34A;
  --warning:      #D97706;
  --ff: 'Inter', system-ui, sans-serif;
  --r:  8px;
  --tr: all .25s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--ff); color: var(--text); background: var(--gray); display: flex; min-height: 100vh; line-height: 1.5; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }
img { display: block; max-width: 100%; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--primary-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: var(--tr);
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo .badge {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .95rem; color: var(--primary-dark);
  margin-bottom: 10px;
}
.sidebar-logo strong { display: block; color: #fff; font-size: .88rem; }
.sidebar-logo span   { font-size: .7rem; color: var(--accent); letter-spacing: .06em; text-transform: uppercase; }

.sidebar-nav { flex: 1; padding: 16px 0; }

.nav-section-label {
  padding: 12px 20px 4px;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: rgba(255,255,255,.7);
  font-size: .875rem;
  font-weight: 500;
  transition: var(--tr);
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav a.active { background: rgba(201,168,76,.12); color: var(--accent); border-left-color: var(--accent); }
.sidebar-nav a i { width: 18px; text-align: center; font-size: .9rem; }

.sidebar-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  border-radius: 10px;
  font-size: .68rem;
  font-weight: 700;
  padding: 2px 7px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-footer a {
  display: flex; align-items: center; gap: 10px;
  color: rgba(255,255,255,.5); font-size: .82rem;
  transition: var(--tr);
}
.sidebar-footer a:hover { color: #fff; }

/* ── Main content ────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar h1 { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.admin-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--gray); border-radius: 20px; padding: 6px 14px;
  font-size: .82rem; font-weight: 600; color: var(--text);
}
.admin-pill .av {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700;
}

.page-body { padding: 32px; flex: 1; }

/* ── Stats cards ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--r);
  padding: 24px;
  border: 1px solid var(--border);
  display: flex; align-items: center; gap: 18px;
}
.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.stat-icon.green  { background: #D1FAE5; color: #065F46; }
.stat-icon.gold   { background: #FEF3C7; color: #92400E; }
.stat-icon.blue   { background: #DBEAFE; color: #1E40AF; }
.stat-icon.red    { background: #FEE2E2; color: #991B1B; }
.stat-num  { font-size: 2rem; font-weight: 800; line-height: 1; color: var(--text); }
.stat-label{ font-size: .8rem; color: var(--muted); margin-top: 3px; }

/* ── Panel cards ─────────────────────────────────────────── */
.panel {
  background: var(--white);
  border-radius: var(--r);
  border: 1px solid var(--border);
  margin-bottom: 24px;
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}
.panel-head h2 { font-size: 1rem; font-weight: 700; }
.panel-body { padding: 24px; }

/* ── Tabla ───────────────────────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.admin-table th {
  text-align: left; padding: 10px 14px;
  background: var(--gray); font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.admin-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--gray); }

.prop-mini-img {
  width: 52px; height: 40px; object-fit: cover;
  border-radius: 6px; flex-shrink: 0;
}

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: .72rem; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
}
.badge-venta   { background: #FEF3C7; color: #92400E; }
.badge-arriendo{ background: #D1FAE5; color: #065F46; }
.badge-activa  { background: #D1FAE5; color: #065F46; }
.badge-inactiva{ background: #FEE2E2; color: #991B1B; }
.badge-pendiente{ background: #FEF3C7; color: #92400E; }
.badge-revisando{ background: #DBEAFE; color: #1E40AF; }
.badge-aprobada{ background: #D1FAE5; color: #065F46; }
.badge-rechazada{ background: #FEE2E2; color: #991B1B; }
.badge-leido   { background: var(--gray); color: var(--muted); }
.badge-nuevo   { background: #EDE9FE; color: #5B21B6; }

/* ── Botones ─────────────────────────────────────────────── */
.btn-admin {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--r);
  font-size: .82rem; font-weight: 600; transition: var(--tr);
}
.btn-primary  { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent   { background: var(--accent); color: var(--primary-dark); }
.btn-accent:hover { background: var(--accent-light); }
.btn-danger   { background: var(--danger); color: var(--white); }
.btn-danger:hover { opacity: .85; }
.btn-sm { padding: 5px 12px; font-size: .78rem; }
.btn-outline-sm {
  border: 1.5px solid var(--border); color: var(--text); background: var(--white);
  border-radius: 6px; padding: 5px 10px; font-size: .78rem; font-weight: 500;
  display: inline-flex; align-items: center; gap: 5px; transition: var(--tr);
}
.btn-outline-sm:hover { border-color: var(--primary); color: var(--primary); }

/* ── Formularios admin ───────────────────────────────────── */
.form-grid { display: grid; gap: 18px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.fg label { display: block; font-size: .8rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.fg input, .fg select, .fg textarea {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border); border-radius: var(--r);
  font-size: .875rem; color: var(--text); background: var(--white);
  transition: var(--tr);
}
.fg input:focus, .fg select:focus, .fg textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27,67,50,.1);
}
.fg textarea { min-height: 100px; resize: vertical; }
.form-section { font-size: .75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); padding: 8px 0 4px;
  border-bottom: 1px solid var(--border); margin-bottom: 4px; grid-column: 1 / -1; }

/* ── Alertas ─────────────────────────────────────────────── */
.alert {
  padding: 12px 18px; border-radius: var(--r);
  font-size: .875rem; font-weight: 500; margin-bottom: 20px;
  display: flex; align-items: center; gap: 10px;
}
.alert-success { background: #D1FAE5; color: #065F46; border: 1px solid #6EE7B7; }
.alert-error   { background: #FEE2E2; color: #991B1B; border: 1px solid #FCA5A5; }

/* ── Upload box ──────────────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--border); border-radius: var(--r);
  padding: 28px; text-align: center; cursor: pointer;
  transition: var(--tr); color: var(--muted); font-size: .875rem;
}
.upload-area:hover { border-color: var(--primary); color: var(--primary); }
.upload-area i { font-size: 2rem; display: block; margin-bottom: 8px; }
.upload-area--multi { background: rgba(27,67,50,.03); }

/* ── Configuración ───────────────────────────────────────── */
.config-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 32px; padding: 20px 0; border-bottom: 1px solid var(--border);
}
.config-label { font-weight: 600; font-size: .95rem; margin-bottom: 4px; }
.config-desc  { font-size: .83rem; color: var(--muted); line-height: 1.5; }

.toggle-switch { position: relative; display: inline-block; width: 52px; height: 28px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: #D1D5DB; border-radius: 28px; transition: .3s;
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 22px; height: 22px; left: 3px; bottom: 3px;
  background: white; border-radius: 50%; transition: .3s;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(24px); }

/* ── Hero carousel admin ─────────────────────────────────── */
.hero-mode-btns { display: flex; gap: 10px; flex-shrink: 0; }
.hero-mode-opt { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border: 2px solid var(--border); border-radius: 10px; cursor: pointer; font-size: .85rem; font-weight: 600; transition: var(--tr); white-space: nowrap; }
.hero-mode-opt input { display: none; }
.hero-mode-opt.active { border-color: var(--accent); background: rgba(201,168,76,.08); color: var(--accent); }
.hero-slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 4px; }
.hero-slot { border: 2px dashed var(--border); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.hero-slot.has-img { border-style: solid; border-color: var(--accent); }
.hero-slot-num { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.hero-slot-preview { width: 100%; aspect-ratio: 16/9; background: var(--gray); border-radius: 8px; display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--border); font-size: 1.8rem; }
.hero-slot-preview img { width: 100%; height: 100%; object-fit: cover; }
.hero-url-input { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: .8rem; transition: var(--tr); }
.hero-url-input:focus { outline: none; border-color: var(--primary); }

/* ── Galería admin ───────────────────────────────────────── */
.gallery-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.gallery-admin-item {
  position: relative;
  border-radius: var(--r);
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--gray-light);
  box-shadow: 0 2px 8px rgba(0,0,0,.10);
}
.gallery-admin-img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .3s;
}
.gallery-admin-item:hover .gallery-admin-img { transform: scale(1.05); }
.gallery-admin-del {
  position: absolute; top: 5px; right: 5px;
  background: rgba(220,38,38,.85);
  color: #fff;
  border: none; border-radius: 6px;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; cursor: pointer;
  opacity: 1; transition: background .2s;
}
.gallery-admin-del:hover { background: rgb(185,28,28); }

/* ── Login page ──────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
}
.login-card {
  background: var(--white); border-radius: 16px; padding: 44px 40px;
  width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-logo .badge {
  width: 56px; height: 56px; background: var(--primary); color: var(--accent);
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 700; margin-bottom: 12px;
}
.login-logo h1 { font-size: 1.15rem; color: var(--text); }
.login-logo p  { font-size: .8rem; color: var(--muted); margin-top: 3px; }

/* ── Paginación ──────────────────────────────────────────── */
.pagination { display: flex; gap: 6px; flex-wrap: wrap; }
.page-btn {
  width: 34px; height: 34px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 600; border: 1.5px solid var(--border);
  color: var(--text); background: var(--white); transition: var(--tr);
}
.page-btn:hover, .page-btn.active { background: var(--primary); color: var(--white); border-color: var(--primary); }

/* ── Mensaje detalle ─────────────────────────────────────── */
.msg-bubble {
  background: var(--gray); border-radius: var(--r); padding: 16px 20px;
  font-size: .9rem; line-height: 1.65; color: var(--text); white-space: pre-wrap;
}

/* ── Selector de tema de color ───────────────────────────── */
.tema-opciones { display: flex; gap: 14px; flex-wrap: wrap; flex-shrink: 0; }
.tema-card {
  display: flex; flex-direction: column; gap: 10px;
  border: 2px solid var(--border); border-radius: 12px;
  padding: 14px; cursor: pointer; width: 168px;
  transition: var(--tr); position: relative;
  background: var(--white);
}
.tema-card input { display: none; }
.tema-card:hover { border-color: #aaa; box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.tema-card.tema-active { border-color: var(--accent); background: rgba(201,168,76,.06); }
.tema-preview-strip { border-radius: 8px; overflow: hidden; }
.tema-bar { height: 28px; width: 100%; }
.tema-bar--sub { height: 10px; }
.tema-dots { display: flex; gap: 6px; padding: 8px 10px; background: #f8f5ef; }
.tema-dots span { width: 16px; height: 16px; border-radius: 50%; display: inline-block; }
.tema-label { display: flex; flex-direction: column; gap: 2px; }
.tema-nombre { font-size: .82rem; font-weight: 700; color: var(--text); }
.tema-desc { font-size: .72rem; color: var(--muted); }
.tema-check { position: absolute; top: 10px; right: 10px; color: var(--accent); font-size: 1rem; opacity: 0; transition: opacity .2s; }
.tema-card.tema-active .tema-check { opacity: 1; }

/* ── Aliases para módulos de edición ─────────────────────── */
.admin-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 32px;
}
.admin-topbar {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
}
.admin-topbar h1 { font-size: 1.15rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 10px; }
.admin-card {
  background: var(--white);
  border-radius: var(--r);
  border: 1px solid var(--border);
  overflow: hidden;
}
.admin-card-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--gray);
}
.admin-card-header h2 { font-size: .95rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.admin-card-body { padding: 24px; }

/* Inputs fuera de .fg */
.admin-main input[type="text"],
.admin-main input[type="email"],
.admin-main input[type="url"],
.admin-main textarea,
.admin-main select {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-size: .875rem;
  color: var(--text);
  background: var(--white);
  transition: var(--tr);
}
.admin-main input:focus,
.admin-main textarea:focus,
.admin-main select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27,67,50,.1);
}
.admin-main label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.fgl-full { width: 100%; }

/* Botones alias */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 20px; border-radius: var(--r);
  font-size: .875rem; font-weight: 600; transition: var(--tr);
  cursor: pointer; border: none;
}
.btn-dark { background: var(--primary); color: var(--white); }
.btn-dark:hover { background: var(--primary-dark); }
.btn-outline-dark {
  background: var(--white); color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-outline-dark:hover { border-color: var(--primary); color: var(--primary); }

/* Alertas adicionales */
.alert-info { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }

/* ── Responsive básico ───────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 500px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-body { padding: 16px; }
}
