/* ===========================================================
   PereiraRenace · Estilos (mobile-first, responsive)
   Paleta: Rojo y Amarillo/Oro — colores de la bandera de Pereira
   =========================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap');

:root {
    --red: #d81e26;
    --red-dark: #a5151b;
    --red-light: #fdeaea;
    --gold: #ffd700;
    --gold-dark: #e0b500;
    --gold-light: #fff6cc;
    --bg: #faf6f1;
    --card: #ffffff;
    --text: #2a1f1c;
    --muted: #7a6a63;
    --border: #e8ddd3;
    --danger: #b00020;
    --radius: 14px;
    --shadow: 0 2px 10px rgba(168, 21, 27, .08);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }

/* El atributo [hidden] siempre oculta (evita que display:grid/flex lo anule) */
[hidden] { display: none !important; }

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

body {
    font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--red-dark); }

h1, h2, h3 { margin: 0 0 .3rem; line-height: 1.2; }

.muted { color: var(--muted); }

/* ---------- Marca / logo ---------- */
.logo-mark {
    width: 64px; height: 64px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    color: var(--red-dark); font-weight: 800; letter-spacing: 1px;
    border-radius: 18px; font-size: 1.4rem;
    margin: 0 auto 1rem;
    box-shadow: var(--shadow);
}
.logo-mark img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.logo-mark.sm {
    width: 40px; height: 40px; border-radius: 12px;
    font-size: .95rem; margin: 0;
}

/* ---------- Login ---------- */
.auth-body {
    min-height: 100vh;
    display: grid; place-items: center;
    padding: 1.2rem;
    background:
        radial-gradient(circle at 15% 15%, rgba(216,30,38,.22), transparent 45%),
        radial-gradient(circle at 85% 85%, rgba(255,215,0,.28), transparent 45%),
        var(--bg);
}
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}
.auth-card { width: 100%; max-width: 380px; text-align: center; }
.brand { color: var(--red-dark); font-size: 1.6rem; }
.auth-card .brand { margin-top: .2rem; }
.auth-card .logo-mark { background: linear-gradient(135deg, var(--red), var(--red-dark)); color: var(--gold); }

/* ---------- Formularios ---------- */
.stack { display: grid; gap: 1rem; }
label { display: block; font-weight: 600; font-size: .9rem; color: var(--text); text-align: left; }
input[type="text"], input[type="password"], input[type="search"], input[type="tel"], input[type="file"], textarea, select {
    width: 100%; margin-top: .35rem;
    padding: .8rem .9rem;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 1rem; font-family: inherit;
    background: #fff; color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(255, 215, 0, .55);
}
textarea { resize: vertical; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .75rem 1.1rem;
    border: 1.5px solid transparent;
    border-radius: 10px;
    font-size: .95rem; font-weight: 700; font-family: inherit;
    cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: transform .05s, background .15s, border-color .15s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-ghost { background: transparent; color: var(--red-dark); border-color: var(--border); }
.btn-ghost:hover { background: var(--red-light); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8a0018; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }

/* ---------- Alertas ---------- */
.alert { padding: .8rem 1rem; border-radius: 10px; margin: .8rem 0; font-size: .9rem; text-align: left; }
.alert-err { background: #fdecea; color: var(--danger); border: 1px solid #f5c6c0; }
.alert-ok { background: var(--gold-light); color: #7a5c00; border: 1px solid #ffe58a; }
.warn { font-size: .82rem; color: var(--muted); }

/* ---------- Topbar ---------- */
.topbar {
    background: linear-gradient(135deg, var(--red), var(--red-dark));
    color: #fff;
    position: sticky; top: 0; z-index: 50;
    box-shadow: var(--shadow);
    border-bottom: 3px solid var(--gold);
}
.topbar-inner {
    max-width: 1080px; margin: 0 auto;
    padding: .6rem 1rem;
    display: flex; align-items: center; justify-content: space-between; gap: .6rem;
    flex-wrap: wrap;
}
.topbar-brand { display: flex; align-items: center; gap: .6rem; }
.topbar-brand small { display: block; opacity: .85; font-size: .72rem; }
.topbar-nav { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.topbar-nav .btn-ghost { color: #fff; border-color: rgba(255,255,255,.45); padding: .45rem .7rem; font-size: .85rem; }
.topbar-nav .btn-ghost:hover { background: rgba(255,255,255,.18); }
.topbar-nav .btn-logout {
    background: rgba(255,255,255,.16); color: #fff; border-color: rgba(255,255,255,.5);
    padding: .45rem .8rem; font-size: .85rem;
    display: inline-flex; align-items: center; gap: .35rem;
}
.topbar-nav .btn-logout:hover { background: var(--gold); color: var(--red-dark); border-color: var(--gold); }
.user-chip {
    background: var(--gold); color: var(--red-dark);
    padding: .35rem .7rem; border-radius: 999px; font-size: .8rem; font-weight: 800;
    display: inline-flex; align-items: center; gap: .35rem; text-decoration: none;
}
.user-chip:hover { filter: brightness(1.05); }

/* ---------- Contenedor ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 1rem; }

/* ---------- Estadísticas ---------- */
.stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .6rem;
    margin-bottom: 1rem;
}
.stat {
    background: var(--card); border-radius: 12px; padding: .8rem;
    box-shadow: var(--shadow); text-align: center;
    border-left: 4px solid var(--red);
}
.stat.ok { border-left-color: var(--gold-dark); }
.stat.warn { border-left-color: #c98a3c; }
.stat-num { display: block; font-size: 1.5rem; font-weight: 800; color: var(--red-dark); }
.stat-lbl { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

/* ---------- Buscador ---------- */
.searchbox { position: sticky; top: 60px; z-index: 30; padding: .4rem 0 .6rem; background: var(--bg); }
.search-field { position: relative; }
.search-field input {
    padding-left: 2.6rem; padding-right: 2.4rem;
    font-size: 1.1rem; height: 56px;
    border-radius: 14px; box-shadow: var(--shadow);
}
.search-icon { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); font-size: 1.1rem; }
.clear-q {
    position: absolute; right: .6rem; top: 50%; transform: translateY(-50%);
    border: none; background: var(--border); color: var(--muted);
    width: 28px; height: 28px; border-radius: 50%; cursor: pointer; display: none;
    font-size: .8rem;
}
.clear-q.show { display: block; }

.filters { display: flex; gap: .5rem; margin-top: .6rem; flex-wrap: wrap; }
.chip {
    border: 1.5px solid var(--border); background: #fff; color: var(--muted);
    padding: .45rem .9rem; border-radius: 999px; font-size: .85rem; font-weight: 700;
    cursor: pointer; font-family: inherit;
}
.chip.active { background: var(--red); color: #fff; border-color: var(--red); }
.add-person { margin-left: auto; padding: .45rem .9rem; font-size: .85rem; }

/* ---------- Resultados ---------- */
.results { display: grid; gap: .7rem; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.persona {
    background: var(--card); border-radius: 12px; box-shadow: var(--shadow);
    padding: .9rem 1rem;
    display: flex; align-items: center; gap: .9rem;
    border-left: 5px solid var(--border);
    transition: box-shadow .15s;
    animation: fadeUp .28s ease both;
}
.persona:hover { box-shadow: 0 4px 16px rgba(168, 21, 27, .16); }
.persona.done { border-left-color: var(--gold-dark); background: #fffbe6; }
.persona-main { min-width: 0; flex: 1; }

/* Avatar con iniciales */
.persona-avatar {
    position: relative; flex: none;
    width: 46px; height: 46px; border-radius: 50%;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--red), var(--red-dark));
    color: #fff; font-weight: 800; font-size: 1rem; letter-spacing: .5px;
}
.persona.done .persona-avatar { background: linear-gradient(135deg, var(--gold), var(--gold-dark)); color: var(--red-dark); }
.avatar-check {
    position: absolute; bottom: -2px; right: -2px;
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--red); color: #fff;
    font-size: .68rem; font-weight: 900; line-height: 1;
    display: grid; place-items: center;
    border: 2px solid var(--card);
}
.persona-name { font-size: 1rem; font-weight: 700; margin: 0 0 .2rem; word-break: break-word; }
.persona-meta { margin: 0 0 .35rem; font-size: .85rem; color: var(--muted); }
.badges { display: flex; gap: .35rem; flex-wrap: wrap; }
.badge {
    font-size: .7rem; font-weight: 700; padding: .18rem .5rem; border-radius: 999px;
    background: var(--gold-light); color: #8a6d00;
}
.badge.red { background: var(--red-light); color: var(--red-dark); }
.badge.gray { background: #f0ebe6; color: var(--muted); }
.badge.orange { background: #fff0c2; color: #8a6d00; }

/* ---------- Loader / vacío ---------- */
.loader { text-align: center; color: var(--muted); padding: 1.5rem; }
.empty { text-align: center; color: var(--muted); padding: 3rem 1rem; }
.empty .big { font-size: 2.5rem; display: block; margin-bottom: .5rem; }

/* ---------- Skeleton de carga ---------- */
.skeleton { pointer-events: none; }
.sk-avatar { width: 46px; height: 46px; border-radius: 50%; flex: none; }
.sk-lines { flex: 1; display: grid; gap: .55rem; }
.sk-line { height: 12px; border-radius: 6px; }
.sk-line.w60 { width: 60%; } .sk-line.w40 { width: 40%; } .sk-line.w30 { width: 30%; }
.sk-avatar, .sk-line {
    background: linear-gradient(90deg, #eee7e0 25%, #f7f2ec 37%, #eee7e0 63%);
    background-size: 400% 100%;
    animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ---------- Modal ---------- */
.modal {
    position: fixed; inset: 0; z-index: 100;
    display: flex;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); }
.modal-card {
    position: relative; background: var(--card); width: 100%; max-width: 560px;
    margin: auto;
    border-radius: 18px; padding: 1.3rem;
    padding-bottom: calc(1.3rem + env(safe-area-inset-bottom, 0px));
    box-shadow: var(--shadow-lg);
    animation: slideUp .22s ease;
    border-top: 4px solid var(--gold);
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-close {
    position: absolute; top: .8rem; right: .8rem;
    border: none; background: #f0ebe6; width: 34px; height: 34px; border-radius: 50%;
    cursor: pointer; font-size: 1rem; color: var(--muted);
}
.m-name { padding-right: 2.2rem; }
.m-phone { color: var(--muted); margin: 0 0 1rem; }
.m-meta { font-size: .78rem; color: var(--muted); margin: 0; }
.modal-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: .4rem; }
.modal-actions .btn { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }

/* Interruptor (asistió) */
.switch { display: flex; align-items: center; gap: .7rem; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
    width: 50px; height: 28px; background: #d8cfc7; border-radius: 999px;
    position: relative; transition: background .2s; flex: none;
}
.switch-track::after {
    content: ""; position: absolute; top: 3px; left: 3px;
    width: 22px; height: 22px; background: #fff; border-radius: 50%;
    transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.switch input:checked + .switch-track { background: var(--red); }
.switch input:checked + .switch-track::after { transform: translateX(22px); }

/* Checkboxes contrato / kit */
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.check {
    display: flex; align-items: center; gap: .5rem;
    border: 1.5px solid var(--border); border-radius: 10px; padding: .7rem;
    cursor: pointer; font-weight: 700; background: #fff;
}
.check input { width: 20px; height: 20px; accent-color: var(--red); }
.check:has(input:checked) { border-color: var(--gold-dark); background: var(--gold-light); }

/* ---------- Toast ---------- */
.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
    background: var(--red-dark); color: #fff; padding: .8rem 1.2rem; border-radius: 999px;
    box-shadow: var(--shadow-lg); z-index: 200; font-weight: 600; font-size: .9rem;
    opacity: 0; transition: opacity .2s, transform .2s; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }

/* ---------- Tablas (import / export) ---------- */
.table-wrap { overflow-x: auto; background: var(--card); border-radius: 12px; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { padding: .55rem .7rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: var(--gold-light); color: #7a5c00; font-size: .75rem; text-transform: uppercase; }
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem; margin-bottom: 1rem; }

/* ---------- Escritorio ---------- */
@media (min-width: 640px) {
    .stats { grid-template-columns: repeat(5, 1fr); }
    .searchbox { top: 64px; }
    .modal-card { max-height: calc(100vh - 2rem); max-height: calc(100dvh - 2rem); overflow-y: auto; }
}
@media (min-width: 900px) {
    .persona-name { font-size: 1.05rem; }
}
