/* ==========================================================================
   Generador de credenciales · La Zarza
   ========================================================================== */
@font-face { font-family: "Poppins"; font-weight: 400; font-display: swap; src: url("../fonts/Poppins-Regular.ttf") format("truetype"); }
@font-face { font-family: "Poppins"; font-weight: 500; font-display: swap; src: url("../fonts/Poppins-Medium.ttf") format("truetype"); }
@font-face { font-family: "Poppins"; font-weight: 600; font-display: swap; src: url("../fonts/Poppins-SemiBold.ttf") format("truetype"); }
@font-face { font-family: "Poppins"; font-weight: 700; font-display: swap; src: url("../fonts/Poppins-Bold.ttf") format("truetype"); }
@font-face { font-family: "Poppins"; font-weight: 800; font-display: swap; src: url("../fonts/Poppins-ExtraBold.ttf") format("truetype"); }

:root {
  --z-indigo: #2E306C;
  --z-indigo-900: #1F2150;
  --z-indigo-700: #3D4A9E;
  --z-purple: #6B2E8F;
  --z-magenta: #E4007F;
  --z-magenta-700: #B5006E;
  --z-lavender: #F2EEF8;
  --z-bg: #F6F5FA;
  --z-line: #E4E1EE;
  --z-text: #23243F;
  --z-muted: #6C6B85;
  --z-ok: #12805C;
  --z-warn: #B26A00;
  --z-bad: #C62839;

  --bs-body-font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-body-color: var(--z-text);
  --bs-body-bg: var(--z-bg);
  --bs-primary: var(--z-magenta);
  --bs-primary-rgb: 228, 0, 127;
  --bs-link-color: var(--z-indigo-700);
  --bs-link-color-rgb: 61, 74, 158;
  --bs-link-hover-color: var(--z-magenta);
  --bs-border-color: var(--z-line);
  --bs-border-radius: .6rem;
  --bs-focus-ring-color: rgba(228, 0, 127, .22);
}

body { font-family: var(--bs-body-font-family); font-size: .925rem; background: var(--z-bg); color: var(--z-text); margin: 0; }
h1, h2, h3, h4, h5 { font-weight: 600; color: var(--z-indigo-900); letter-spacing: -.01em; }
.text-muted, .form-text { color: var(--z-muted) !important; }
.fw-semibold { font-weight: 600 !important; }
.small-caps { text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; font-weight: 600; color: var(--z-muted); }

/* ---------- Botones ---------- */
.btn { font-weight: 500; border-radius: .55rem; }
.btn-primary { --bs-btn-bg: var(--z-magenta); --bs-btn-border-color: var(--z-magenta); --bs-btn-hover-bg: var(--z-magenta-700); --bs-btn-hover-border-color: var(--z-magenta-700); --bs-btn-active-bg: var(--z-magenta-700); --bs-btn-active-border-color: var(--z-magenta-700); --bs-btn-disabled-bg: var(--z-magenta); --bs-btn-disabled-border-color: var(--z-magenta); }
.btn-indigo { --bs-btn-color: #fff; --bs-btn-bg: var(--z-indigo); --bs-btn-border-color: var(--z-indigo); --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--z-indigo-900); --bs-btn-hover-border-color: var(--z-indigo-900); --bs-btn-active-bg: var(--z-indigo-900); --bs-btn-active-color: #fff; }
.btn-outline-indigo { --bs-btn-color: var(--z-indigo); --bs-btn-border-color: #CFCDE3; --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--z-indigo); --bs-btn-hover-border-color: var(--z-indigo); --bs-btn-active-bg: var(--z-indigo); --bs-btn-active-color: #fff; --bs-btn-bg: #fff; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 2.1rem; height: 2.1rem; padding: 0; }
.form-control, .form-select { border-radius: .55rem; border-color: #DAD7E8; }
.form-control:focus, .form-select:focus { border-color: var(--z-magenta); box-shadow: 0 0 0 .2rem rgba(228, 0, 127, .15); }
.form-label { font-weight: 500; font-size: .85rem; margin-bottom: .3rem; color: var(--z-indigo-900); }
.form-check-input:checked { background-color: var(--z-magenta); border-color: var(--z-magenta); }

/* ---------- Estructura ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex: 0 0 250px;
  background: linear-gradient(180deg, var(--z-indigo-900) 0%, var(--z-indigo) 70%, #3A2A78 100%);
  color: #D9D8F0;
}
@media (min-width: 992px) {
  .sidebar { position: sticky; top: 0; height: 100vh; }
}
.sidebar .offcanvas-body { display: flex; flex-direction: column; padding: 1.25rem 1rem; height: 100%; }
.sidebar .marca { background: #fff; border-radius: .9rem; padding: .7rem .9rem; text-align: center; margin-bottom: 1.5rem; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.sidebar .marca img { max-width: 100%; height: 58px; object-fit: contain; }
.sidebar .marca small { display: block; color: var(--z-indigo); font-weight: 600; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; margin-top: .3rem; }
.sidebar .nav-link { color: #CFCDEB; border-radius: .6rem; padding: .6rem .8rem; display: flex; align-items: center; gap: .7rem; font-weight: 500; margin-bottom: .2rem; position: relative; }
.sidebar .nav-link i { font-size: 1.1rem; opacity: .9; }
.sidebar .nav-link:hover { color: #fff; background: rgba(255,255,255,.07); }
.sidebar .nav-link.active { color: #fff; background: rgba(255,255,255,.12); }
.sidebar .nav-link.active::before { content: ""; position: absolute; left: -1rem; top: .45rem; bottom: .45rem; width: 4px; border-radius: 0 4px 4px 0; background: var(--z-magenta); }
.sidebar .seccion { font-size: .66rem; letter-spacing: .14em; text-transform: uppercase; color: #8F8DB8; margin: 1.1rem .8rem .4rem; font-weight: 600; }
.sidebar .usuario { margin-top: auto; border-top: 1px solid rgba(255,255,255,.12); padding-top: 1rem; font-size: .82rem; }
.sidebar .usuario .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--z-magenta); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; }
.sidebar .usuario a { color: #CFCDEB; text-decoration: none; }
.sidebar .usuario a:hover { color: #fff; }

.contenido { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid var(--z-line); padding: .8rem 1.5rem; display: flex; align-items: center; gap: 1rem; position: sticky; top: 0; z-index: 20; }
.topbar h1 { font-size: 1.2rem; margin: 0; }
.pagina { padding: 1.5rem; max-width: 1400px; width: 100%; }
@media (max-width: 575.98px) { .pagina { padding: 1rem; } .topbar { padding: .7rem 1rem; } }

/* ---------- Tarjetas ---------- */
.card { border: 1px solid var(--z-line); border-radius: .9rem; box-shadow: 0 1px 2px rgba(31,33,80,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--z-line); font-weight: 600; color: var(--z-indigo-900); padding: .9rem 1.15rem; border-radius: .9rem .9rem 0 0 !important; }
.card-body { padding: 1.15rem; }
.stat { display: flex; gap: .9rem; align-items: center; }
.stat .ico { width: 46px; height: 46px; border-radius: .8rem; display: inline-flex; align-items: center; justify-content: center; font-size: 1.3rem; flex: 0 0 46px; }
.stat .num { font-size: 1.55rem; font-weight: 700; color: var(--z-indigo-900); line-height: 1.1; }
.stat .lbl { color: var(--z-muted); font-size: .8rem; }
.ico-indigo { background: #E9E9F6; color: var(--z-indigo); }
.ico-ok { background: #E3F4EE; color: var(--z-ok); }
.ico-bad { background: #FBE7EA; color: var(--z-bad); }
.ico-mag { background: #FDE6F2; color: var(--z-magenta); }
.ico-warn { background: #FCF1DE; color: var(--z-warn); }

/* ---------- Tablas ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--z-muted); font-weight: 600; border-bottom-width: 1px; background: #FBFAFD; white-space: nowrap; }
.table > tbody td { vertical-align: middle; border-color: #EFEDF5; }
.table-hover > tbody > tr:hover > * { --bs-table-hover-bg: #FAF8FD; }
.mini-foto { width: 38px; height: 50px; border-radius: .4rem; object-fit: cover; background: var(--z-lavender); display: inline-flex; align-items: center; justify-content: center; color: var(--z-indigo); font-weight: 600; font-size: .8rem; flex: 0 0 38px; }

/* ---------- Estatus ---------- */
.badge-estatus { display: inline-flex; align-items: center; gap: .35rem; font-weight: 600; font-size: .72rem; padding: .32rem .6rem; border-radius: 2rem; letter-spacing: .02em; }
.badge-estatus::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.estatus-activo { background: #E3F4EE; color: var(--z-ok); }
.estatus-inactivo { background: #FBE7EA; color: var(--z-bad); }
.estatus-vencida { background: #FCF1DE; color: var(--z-warn); }

/* ---------- Barra de lote ---------- */
.barra-lote { position: sticky; bottom: 0; z-index: 15; background: var(--z-indigo-900); color: #fff; border-radius: .9rem; padding: .7rem 1rem; display: none; align-items: center; gap: .75rem; flex-wrap: wrap; box-shadow: 0 10px 30px rgba(31,33,80,.35); margin-top: 1rem; }
.barra-lote.visible { display: flex; }
.barra-lote .form-select { width: auto; min-width: 140px; background-color: #fff; }

/* ---------- Credencial (render HTML) ---------- */
.credencial {
  --s: 6px; /* px por mm; lo ajusta JS */
  position: relative; width: calc(54 * var(--s)); height: calc(85.6 * var(--s));
  border-radius: calc(3.18 * var(--s)); overflow: hidden; background: #fff;
  box-shadow: 0 18px 40px rgba(31,33,80,.18), 0 2px 6px rgba(31,33,80,.08);
  user-select: none; flex: 0 0 auto;
}
.credencial .fondo { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.credencial .el { position: absolute; box-sizing: border-box; }
.credencial .el-texto { display: flex; align-items: center; line-height: 1.15; overflow: visible; }
.credencial .el-texto .t { display: block; width: 100%; white-space: nowrap; font-family: "Poppins", sans-serif; }
.credencial .el-texto.multi .t { white-space: normal; }
.credencial .el-foto { overflow: hidden; background: #ECE9F6; display: flex; align-items: center; justify-content: center; }
.credencial .el-foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.credencial .el-foto .ini { font-family: "Poppins", sans-serif; font-weight: 700; color: var(--z-indigo); }
.credencial .el-qr img { width: 100%; height: 100%; display: block; }
.credencial .el-qr { padding: calc(.9 * var(--s)); }
.credencial.sin-esquinas { border-radius: 0; }

.preview-wrap { display: flex; gap: 1.25rem; justify-content: center; flex-wrap: wrap; padding: 1rem 0; }
.preview-lado { text-align: center; }
.preview-lado .small-caps { display: block; margin-top: .7rem; }

/* ---------- Editor de plantillas ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1.25rem; align-items: start; }
@media (max-width: 1199.98px) { .editor { grid-template-columns: 1fr; } }
.lienzo { background: #ECEAF3; background-image: radial-gradient(#D9D6E6 1px, transparent 1px); background-size: 14px 14px; border-radius: .9rem; padding: 1.5rem; display: flex; justify-content: center; align-items: flex-start; min-height: 520px; position: relative; }
.editable .el { cursor: move; outline: 1px dashed rgba(46,48,108,.0); }
.editable .el:hover { outline-color: rgba(46,48,108,.45); }
.editable .el.sel { outline: 1.5px solid var(--z-magenta); z-index: 50; }
.editable .el .h { position: absolute; width: 10px; height: 10px; background: #fff; border: 1.5px solid var(--z-magenta); border-radius: 2px; right: -6px; bottom: -6px; cursor: nwse-resize; display: none; }
.editable .el.sel .h { display: block; }
.editable .el .tag { position: absolute; top: -18px; left: -1px; background: var(--z-magenta); color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 3px 3px 3px 0; white-space: nowrap; display: none; font-family: "Poppins", sans-serif; font-weight: 500; }
.editable .el.sel .tag { display: block; }
.guia-segura { position: absolute; border: 1px dashed rgba(228,0,127,.55); pointer-events: none; z-index: 40; }
.guia-centro { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px dashed rgba(46,48,108,.55); pointer-events: none; z-index: 41; display: none; }
.guia-centro.on { display: block; }
.panel-prop .lista-el { max-height: 240px; overflow: auto; }
.panel-prop .lista-el .list-group-item { cursor: pointer; font-size: .82rem; display: flex; gap: .5rem; align-items: center; padding: .45rem .7rem; }
.panel-prop .lista-el .list-group-item.active { background: var(--z-lavender); color: var(--z-indigo-900); border-color: var(--z-line); font-weight: 600; }
.panel-prop .lista-el .list-group-item .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-marcador { display: inline-block; font-size: .72rem; padding: .15rem .45rem; border-radius: 1rem; background: var(--z-lavender); color: var(--z-indigo); margin: 0 .25rem .3rem 0; cursor: pointer; border: 1px solid #E1DCEF; }
.chip-marcador:hover { background: var(--z-indigo); color: #fff; }
.form-control-sm, .form-select-sm { font-size: .8rem; }
.input-group-text { font-size: .75rem; background: #FBFAFD; }
.lado-tabs .btn { min-width: 110px; }

/* ---------- Foto / recorte ---------- */
.zona-foto { border: 2px dashed #D6D2E6; border-radius: .9rem; padding: 1rem; text-align: center; background: #FCFBFE; }
.zona-foto img.actual { width: 120px; height: 160px; object-fit: cover; border-radius: .6rem; box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.cropper-wrap { max-height: 420px; }
.cropper-wrap img { max-width: 100%; display: block; }

/* ---------- Plantillas ---------- */
.plantilla-card .thumbs { background: #ECEAF3; display: flex; justify-content: center; gap: .9rem; padding: 1.1rem; border-radius: .9rem .9rem 0 0; }
.plantilla-card .thumbs img { width: 96px; height: 152px; object-fit: cover; border-radius: 6px; box-shadow: 0 6px 16px rgba(31,33,80,.18); background: #fff; }
.check-dim { font-size: .8rem; margin-top: .4rem; }
.check-dim.ok { color: var(--z-ok); }
.check-dim.bad { color: var(--z-bad); }
.spec { background: linear-gradient(135deg, var(--z-indigo-900), var(--z-purple)); color: #E7E5F7; border: 0; }
.spec h5, .spec strong { color: #fff; }
.spec a { color: #FFB3DA; }
.spec .val { font-weight: 600; color: #fff; }

/* ---------- Login / instalación ---------- */
.pantalla-acceso { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background:
  radial-gradient(circle at 12% 18%, rgba(228,0,127,.18), transparent 38%),
  radial-gradient(circle at 88% 82%, rgba(61,74,158,.22), transparent 42%), var(--z-bg); }
.caja-acceso { width: 100%; max-width: 410px; background: #fff; border-radius: 1.2rem; padding: 2rem; box-shadow: 0 24px 60px rgba(31,33,80,.16); border: 1px solid var(--z-line); }
.caja-acceso.ancha { max-width: 640px; }
.caja-acceso .logo { display: block; margin: 0 auto 1.25rem; height: 84px; }
.req li { display: flex; gap: .5rem; align-items: center; padding: .25rem 0; }
.req .bi-check-circle-fill { color: var(--z-ok); }
.req .bi-x-circle-fill { color: var(--z-bad); }

.pagination { --bs-pagination-active-bg: var(--z-indigo); --bs-pagination-active-border-color: var(--z-indigo); --bs-pagination-color: var(--z-indigo); margin: 0; }
.alert { border-radius: .8rem; border: 0; }
.alert-success { background: #E3F4EE; color: #0D5E44; }
.alert-danger { background: #FBE7EA; color: #8E1D2A; }
.alert-warning { background: #FCF1DE; color: #7A4A00; }
.toast-guardado { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 2000; }

/* ---------- Página pública de verificación ---------- */
.verif { min-height: 100vh; background: var(--z-bg); display: flex; flex-direction: column; align-items: center; padding: 1.25rem 1rem 2rem; }
.verif .marca { width: 190px; margin: .5rem auto 1.2rem; display: block; }
.verif .tarjeta { width: 100%; max-width: 420px; background: #fff; border-radius: 1.3rem; overflow: hidden; box-shadow: 0 20px 50px rgba(31,33,80,.15); border: 1px solid var(--z-line); }
.verif .estado { padding: 1.4rem 1.2rem 4.6rem; text-align: center; color: #fff; }
.verif .estado.no_valida { padding-bottom: 1.4rem; }
.verif .estado i { font-size: 3rem; line-height: 1; display: block; margin-bottom: .35rem; }
.verif .estado .titulo { font-size: 1.45rem; font-weight: 700; letter-spacing: .02em; }
.verif .estado .sub { opacity: .92; font-size: .88rem; }
.verif .estado.activo { background: linear-gradient(135deg, #0E8A5F, #17A673); }
.verif .estado.inactivo, .verif .estado.no_valida { background: linear-gradient(135deg, #B01F31, #D63447); }
.verif .estado.vencida { background: linear-gradient(135deg, #A45F00, #D48A0E); }
.verif .persona { padding: 0 1.3rem 1.2rem; text-align: center; }
.verif .persona .foto { width: 132px; height: 176px; border-radius: .9rem; object-fit: cover; margin: -4.4rem auto .9rem; display: block; border: 4px solid #fff; box-shadow: 0 8px 24px rgba(31,33,80,.2); background: var(--z-lavender); }
.verif .persona .foto.ini { display: flex; align-items: center; justify-content: center; font-size: 2.6rem; font-weight: 700; color: var(--z-indigo); }
.verif .persona .nombre { font-size: 1.25rem; font-weight: 700; color: var(--z-indigo-900); line-height: 1.25; }
.verif .persona .puesto { color: var(--z-magenta); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; margin-top: .35rem; }
.verif dl { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin: 1.2rem 0 0; text-align: left; background: var(--z-bg); border-radius: .9rem; padding: .9rem 1rem; }
.verif dt { font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; color: var(--z-muted); font-weight: 600; }
.verif dd { margin: 0; font-weight: 600; color: var(--z-indigo-900); font-size: .92rem; }
.verif .pie { font-size: .75rem; color: var(--z-muted); text-align: center; margin-top: 1.2rem; max-width: 420px; }
.verif .franja { height: 6px; background: linear-gradient(90deg, var(--z-indigo), var(--z-purple), var(--z-magenta)); }
.btn-pulse { box-shadow: 0 0 0 0 rgba(228,0,127,.55); animation: pulso 1.6s infinite; }
@keyframes pulso { 0% { box-shadow: 0 0 0 0 rgba(228,0,127,.5); } 70% { box-shadow: 0 0 0 10px rgba(228,0,127,0); } 100% { box-shadow: 0 0 0 0 rgba(228,0,127,0); } }
