/* =========================================================
   Bienes Raíces Los Ángeles — estilos compartidos del panel
   Misma paleta que la app móvil
   ========================================================= */
:root {
    --primary: #0056B3;
    --primary-dark: #003D82;
    --primary-soft: #E8F1FB;
    --success: #16A34A;
    --success-soft: #E7F7EE;
    --danger: #DC2626;
    --danger-soft: #FDECEC;
    --warning: #D97706;
    --warning-soft: #FEF3E2;
    --whatsapp: #25D366;
    --bg: #F3F6FA;
    --card: #FFFFFF;
    --text: #0F172A;
    --text-soft: #475569;
    --muted: #94A3B8;
    --border: #E2E8F0;
    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --shadow: 0 6px 18px rgba(15, 23, 42, .07);
    --shadow-lg: 0 18px 40px rgba(15, 23, 42, .14);
}

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

html, body { margin: 0; padding: 0; }

body {
    font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); }
.hidden { display: none !important; }

/* ---------- Barra superior ---------- */
.topbar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    padding: 18px 24px 64px;
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}
.topbar-inner {
    max-width: 1200px; margin: 0 auto;
    display: flex; align-items: center; gap: 14px;
}
.topbar .back {
    width: 44px; height: 44px; border-radius: 50%;
    background: rgba(255,255,255,.15); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    text-decoration: none; font-size: 1.2rem; flex-shrink: 0; border: 0; cursor: pointer;
    transition: background .2s;
}
.topbar .back:hover { background: rgba(255,255,255,.25); }
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { margin: 0; font-size: 1.45rem; font-weight: 700; line-height: 1.2; }
.topbar-title p { margin: 2px 0 0; font-size: .85rem; opacity: .8; }
.topbar-icon {
    width: 48px; height: 48px; border-radius: 14px;
    background: rgba(255,255,255,.15);
    display: flex; align-items: center; justify-content: center; font-size: 1.35rem; flex-shrink: 0;
}
.user-chip {
    display: flex; align-items: center; gap: 10px;
    background: rgba(255,255,255,.12); padding: 6px 6px 6px 14px; border-radius: 999px;
}
.user-chip span { font-size: .85rem; font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(255,255,255,.25); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700;
}

/* Contenido que se monta sobre la barra */
.page { max-width: 1200px; margin: -44px auto 40px; padding: 0 20px; position: relative; }
.page-narrow { max-width: 640px; }
.page-medium { max-width: 900px; }

/* ---------- Tarjetas ---------- */
.card {
    background: var(--card); border-radius: var(--radius-xl);
    box-shadow: var(--shadow); padding: 24px; margin-bottom: 18px;
}
.card-title { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; }
.card-title h2, .card-title h3 { margin: 0; font-size: 1.1rem; font-weight: 700; }
.card-title p { margin: 2px 0 0; color: var(--text-soft); font-size: .85rem; }
.icon-box {
    width: 44px; height: 44px; border-radius: 14px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 1.25rem;
    background: var(--primary-soft); color: var(--primary);
}
.icon-box.success { background: var(--success-soft); color: var(--success); }
.icon-box.warning { background: var(--warning-soft); color: var(--warning); }
.icon-box.danger  { background: var(--danger-soft);  color: var(--danger); }

/* ---------- Formularios ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }
.input, .select, .textarea {
    width: 100%; font: inherit; font-size: .95rem; color: var(--text);
    background: #F8FAFC; border: 1.5px solid var(--border); border-radius: var(--radius);
    padding: 12px 14px; outline: none; transition: border-color .2s, background .2s, box-shadow .2s;
}
.input:focus, .select:focus, .textarea:focus {
    border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px rgba(0,86,179,.1);
}
.textarea { min-height: 96px; resize: vertical; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-icon > .input { padding-left: 42px; }
.input-icon .input-action {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 8px; font-size: 1.05rem;
}
.row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* ---------- Botones ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font: inherit; font-weight: 600; font-size: .95rem;
    border: 0; border-radius: var(--radius); padding: 13px 20px; cursor: pointer;
    text-decoration: none; transition: transform .1s, filter .2s, background .2s, opacity .2s;
    white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-lg { padding: 16px 22px; font-size: 1rem; }
.btn-sm { padding: 8px 12px; font-size: .82rem; border-radius: var(--radius-sm); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.08); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-ghost { background: #F1F5F9; color: var(--text-soft); }
.btn-ghost:hover { background: #E2E8F0; }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-soft:hover { background: #D9E8F8; }
.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:hover { background: var(--primary-soft); }

/* ---------- Insignias ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: .74rem; font-weight: 700; padding: 4px 10px; border-radius: 999px;
    background: #F1F5F9; color: var(--text-soft);
}
.badge.primary { background: var(--primary-soft); color: var(--primary); }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger  { background: var(--danger-soft);  color: var(--danger); }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }
table.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th {
    background: #F8FAFC; color: var(--text-soft); font-weight: 600; font-size: .78rem;
    text-transform: uppercase; letter-spacing: .03em; text-align: left; padding: 12px 14px;
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #FAFCFF; }

/* ---------- Listas de resultados ---------- */
.result-list { list-style: none; margin: 10px 0 0; padding: 0; }
.result-item {
    display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--radius-lg);
    background: #fff; border: 1px solid var(--border); margin-bottom: 8px; cursor: pointer;
    transition: border-color .2s, box-shadow .2s, transform .1s;
}
.result-item:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.result-item .avatar-sm {
    width: 42px; height: 42px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
    display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0;
}
.result-item .info { flex: 1; min-width: 0; }
.result-item .info strong { display: block; font-size: .95rem; }
.result-item .info small { color: var(--text-soft); }

/* ---------- Estados vacíos y carga ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--text-soft); }
.empty .icon-circle {
    width: 80px; height: 80px; border-radius: 50%; margin: 0 auto 14px;
    background: var(--primary-soft); color: var(--primary);
    display: flex; align-items: center; justify-content: center; font-size: 2rem;
}
.empty h3 { margin: 0 0 6px; color: var(--text); font-size: 1.05rem; }
.empty p { margin: 0; font-size: .9rem; }
.spinner {
    width: 36px; height: 36px; border-radius: 50%;
    border: 4px solid var(--primary-soft); border-top-color: var(--primary);
    animation: spin .8s linear infinite; margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Modal (lo crea js/ui.js) ---------- */
.ui-overlay {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .55); backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center; padding: 20px;
    z-index: 10000; opacity: 0; transition: opacity .18s;
}
.ui-overlay.show { opacity: 1; }
.ui-modal {
    background: #fff; border-radius: var(--radius-xl); width: 100%; max-width: 420px;
    padding: 28px 24px 22px; text-align: center; box-shadow: var(--shadow-lg);
    transform: scale(.92); transition: transform .2s cubic-bezier(.2,.9,.3,1.2);
}
.ui-overlay.show .ui-modal { transform: scale(1); }
.ui-modal .ui-icon {
    width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 16px;
    display: flex; align-items: center; justify-content: center; font-size: 2rem;
}
.ui-modal h3 { margin: 0 0 8px; font-size: 1.2rem; font-weight: 700; }
.ui-modal p { margin: 0; color: var(--text-soft); font-size: .95rem; line-height: 1.5; white-space: pre-line; }
.ui-modal .ui-actions { display: flex; gap: 10px; margin-top: 22px; }
.ui-modal .ui-actions .btn { flex: 1; }

/* Modal de contenido (fotos, formularios) */
.sheet-overlay {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .6); backdrop-filter: blur(3px);
    display: none; align-items: center; justify-content: center; padding: 20px; z-index: 9000;
}
.sheet-overlay.show { display: flex; }
.sheet {
    background: #fff; border-radius: var(--radius-xl); width: 100%; max-width: 560px;
    max-height: 92vh; overflow-y: auto; padding: 24px; box-shadow: var(--shadow-lg);
    animation: pop .2s ease-out;
}
@keyframes pop { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.sheet-head h3 { margin: 0; flex: 1; font-size: 1.15rem; }
.sheet-close {
    width: 38px; height: 38px; border-radius: 50%; border: 0; background: #F1F5F9; color: var(--text-soft);
    cursor: pointer; font-size: 1.1rem;
}

/* ---------- Toast ---------- */
.ui-toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 11000; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.ui-toast {
    display: flex; align-items: center; gap: 10px; background: var(--text); color: #fff;
    padding: 12px 18px; border-radius: 999px; font-size: .9rem; box-shadow: var(--shadow-lg);
    animation: toastIn .25s ease-out;
}
.ui-toast.success i { color: #4ADE80; }
.ui-toast.danger i { color: #F87171; }
.ui-toast.warning i { color: #FBBF24; }
@keyframes toastIn { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
    .topbar { padding: 14px 16px 58px; }
    .topbar-title h1 { font-size: 1.2rem; }
    .user-chip span { display: none; }
    .user-chip { padding: 4px; }
    .page { padding: 0 14px; }
    .card { padding: 18px; border-radius: var(--radius-lg); }
}

/* ---------- Impresión ---------- */
@media print {
    .no-print { display: none !important; }
}
