/* ============================================
   CRM Viviendas - Estilos
   ============================================ */
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f5f7fa;
    color: #1f2937;
    line-height: 1.5;
}
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1280px; margin: 0 auto; padding: 0 20px; }

/* Topbar */
.topbar {
    background: #1e293b;
    color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,.1);
    margin-bottom: 24px;
}
.topbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 14px;
    padding-bottom: 14px;
    flex-wrap: wrap;
    gap: 12px;
}
.logo {
    font-size: 20px;
    font-weight: 700;
    color: #fff !important;
    text-decoration: none;
}
.topbar nav {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.topbar nav a {
    color: #cbd5e1 !important;
    padding: 8px 14px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
    transition: background .15s;
}
.topbar nav a:hover { background: #334155; color: #fff !important; }
.topbar nav a.active { background: #3b82f6; color: #fff !important; }
.topbar nav .btn-import { background: #10b981; color: #fff !important; font-weight: 600; }
.topbar nav .btn-import:hover { background: #059669; }
.counter {
    background: rgba(255,255,255,.15);
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 12px;
    margin-left: 4px;
}

/* Headings */
h1 { margin: 0 0 16px; font-size: 28px; }
h1 .muted { color: #6b7280; font-weight: 400; font-size: 18px; }
h2 { margin-top: 32px; }

/* Stats */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.stat {
    background: #fff;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 14px;
    text-align: center;
    text-decoration: none !important;
    color: #1f2937 !important;
    transition: all .15s;
    cursor: pointer;
}
.stat:hover { border-color: #3b82f6; transform: translateY(-1px); }
.stat.active { border-color: #3b82f6; background: #eff6ff; }
.stat-num { display: block; font-size: 26px; font-weight: 700; color: #1e293b; }
.stat-label { display: block; font-size: 12px; color: #6b7280; margin-top: 4px; }

/* Filtros */
.filtros {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    background: #fff;
    padding: 14px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}
.filtros input[type="text"], .filtros input[type="number"] {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    flex: 1;
    min-width: 140px;
}
.filtros button {
    padding: 8px 18px;
    background: #3b82f6;
    color: #fff;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}
.filtros button:hover { background: #2563eb; }
.btn-link {
    padding: 8px 14px;
    color: #6b7280 !important;
    align-self: center;
}

/* Grid de cards */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}
.card {
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    transition: box-shadow .15s, transform .15s;
}
.card:hover { box-shadow: 0 6px 14px rgba(0,0,0,.12); transform: translateY(-2px); }
.card-link { display: block; color: inherit !important; text-decoration: none !important; }
.card-img {
    position: relative;
    aspect-ratio: 4/3;
    background: #e5e7eb;
    overflow: hidden;
}
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.no-img, .no-img-large {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%; height: 100%;
    color: #9ca3af;
    font-size: 14px;
}
.no-img-large { aspect-ratio: 4/3; background: #e5e7eb; border-radius: 8px; }
.card-body { padding: 12px 14px 14px; }
.card-precio { font-size: 20px; font-weight: 700; color: #059669; margin-bottom: 4px; }
.card-titulo { font-size: 14px; font-weight: 500; color: #1f2937; margin-bottom: 6px; min-height: 2.8em; }
.card-meta { font-size: 12px; color: #6b7280; }
.card-vendedor {
    display: inline-block;
    margin-top: 8px;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: 600;
}
.tag-pro  { background: #fee2e2; color: #991b1b; }
.tag-priv { background: #d1fae5; color: #065f46; }

/* Badges */
.badge {
    position: absolute;
    top: 8px; left: 8px;
    background: rgba(0,0,0,.65);
    color: #fff;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
}
.badge-grande {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    background: #f3f4f6;
}
.badge-pendiente, .badge-grande.badge-pendiente { background: #fef3c7; color: #92400e; }
.badge-validada,  .badge-grande.badge-validada  { background: #d1fae5; color: #065f46; }
.badge-descartada,.badge-grande.badge-descartada{ background: #fee2e2; color: #991b1b; }

/* Detalle */
.back-link {
    display: inline-block;
    margin-bottom: 12px;
    color: #6b7280 !important;
    font-size: 14px;
}
.detalle {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 24px;
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
@media (max-width: 768px) {
    .detalle { grid-template-columns: 1fr; }
}
.detalle-img img { width: 100%; border-radius: 8px; display: block; }
.detalle-info h1 { margin: 8px 0; }
.detalle-precio { font-size: 32px; font-weight: 700; color: #059669; margin-bottom: 16px; }

.ficha {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    font-size: 14px;
}
.ficha th, .ficha td {
    padding: 8px 10px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
}
.ficha th {
    width: 180px;
    color: #6b7280;
    font-weight: 500;
}

.descripcion {
    background: #f9fafb;
    border-left: 3px solid #3b82f6;
    padding: 14px;
    border-radius: 4px;
    margin-bottom: 24px;
    font-size: 14px;
    max-height: 300px;
    overflow-y: auto;
}
.descripcion h3 { margin-top: 0; }

/* Acciones */
.acciones {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
}
.acciones h3 { margin-top: 0; }
.acciones-form textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 12px;
    resize: vertical;
}
.botones-accion { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
    padding: 10px 16px;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none !important;
    display: inline-block;
    color: #fff !important;
}
.btn:hover { opacity: .9; }
.btn-validar   { background: #10b981; }
.btn-descartar { background: #ef4444; }
.btn-pendiente { background: #6b7280; }

/* Importar */
.form-import {
    background: #fff;
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    padding: 24px;
    margin-bottom: 24px;
}
.form-import input[type="file"] {
    margin: 12px 0;
    padding: 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    width: 100%;
    max-width: 400px;
}

.tabla-importaciones { background: #fff; border-radius: 8px; }
.tabla-importaciones th { background: #f9fafb; }

/* Alerts */
.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 16px;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.alert details { margin-top: 8px; }
.alert pre {
    background: rgba(0,0,0,.06);
    padding: 8px;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 12px;
}

/* Duplicados */
.duplicados-aviso {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 20px;
}
.duplicados-titulo {
    font-weight: 600;
    color: #92400e;
    margin-bottom: 8px;
    font-size: 14px;
}
.duplicados-titulo small {
    font-weight: 400;
    color: #78350f;
    margin-left: 4px;
}
.duplicados-lista {
    margin: 0;
    padding-left: 20px;
    font-size: 13px;
}
.duplicados-lista li {
    margin: 4px 0;
    color: #1f2937;
}
.duplicados-lista a { color: #1f2937; }
.duplicados-lista a:hover { color: #2563eb; }
.duplicados-lista .link-externo { color: #6b7280; font-size: 12px; }
.badge-mini {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 4px;
}

/* Leyenda del mapa */
.leyenda-mapa {
    background: #fff;
    padding: 10px 12px;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
    font-size: 12px;
    line-height: 1.8;
}
.leyenda-mapa strong { display: block; margin-bottom: 4px; font-size: 13px; }
.leyenda-mapa div { display: flex; align-items: center; gap: 8px; }
.leyenda-mapa span {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 2px rgba(0,0,0,.3);
}

/* Paginación */
.paginacion {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin: 24px 0;
}
.paginacion a {
    padding: 8px 14px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
}

.empty {
    background: #fff;
    padding: 40px;
    text-align: center;
    color: #6b7280;
    border-radius: 8px;
}

.footer {
    margin-top: 60px;
    padding: 20px 0;
    text-align: center;
    color: #9ca3af;
    border-top: 1px solid #e5e7eb;
}
