/* Sistema AIP — estilos propios sobre Bootstrap 5 */
:root {
  --aip: #1f4e8c; --aip-dark: #163a69; --aip-soft: #e8eff8; --aip-rgb: 31, 78, 140;
  --fondo: #f3f5f9; --borde: #e2e6ee; --texto: #1d2433; --suave: #6b7487;
  --sidebar-w: 264px;
  --bs-body-bg: var(--fondo); --bs-body-color: var(--texto);
  --bs-primary: var(--aip); --bs-primary-rgb: var(--aip-rgb); --bs-link-color: var(--aip); --bs-link-hover-color: var(--aip-dark);
  --bs-border-color: var(--borde);
  --bs-body-font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --bs-border-radius: .6rem;
}
body { background: var(--fondo); color: var(--texto); font-size: .94rem; }
a { text-decoration: none; }
h1, h2, h3, h4, h5 { letter-spacing: -.01em; }

.btn-primary { --bs-btn-bg: var(--aip); --bs-btn-border-color: var(--aip); --bs-btn-hover-bg: var(--aip-dark); --bs-btn-hover-border-color: var(--aip-dark); --bs-btn-active-bg: var(--aip-dark); --bs-btn-active-border-color: var(--aip-dark); --bs-btn-disabled-bg: var(--aip); --bs-btn-disabled-border-color: var(--aip); }
.btn-outline-primary { --bs-btn-color: var(--aip); --bs-btn-border-color: var(--aip); --bs-btn-hover-bg: var(--aip); --bs-btn-hover-border-color: var(--aip); --bs-btn-active-bg: var(--aip); --bs-btn-active-border-color: var(--aip); }
.text-primary { color: var(--aip) !important; }
.bg-primary { background-color: var(--aip) !important; }
.text-bg-primary { background-color: var(--aip) !important; color: #fff !important; }
.form-control:focus, .form-select:focus { border-color: var(--aip); box-shadow: 0 0 0 .2rem rgba(var(--aip-rgb), .15); }
.form-check-input:checked { background-color: var(--aip); border-color: var(--aip); }
.page-item.active .page-link { background: var(--aip); border-color: var(--aip); }
.page-link { color: var(--aip); }
.nav-pills .nav-link.active { background: var(--aip); }
.nav-tabs .nav-link.active { color: var(--aip); font-weight: 600; }

/* ---------- Estructura ---------- */
.app-sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: linear-gradient(180deg, var(--aip-dark), #0f2747); color: #cfd8e8; overflow-y: auto; z-index: 1030; display: flex; flex-direction: column; }
.app-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.app-topbar { background: #fff; border-bottom: 1px solid var(--borde); padding: .55rem 1.25rem; display: flex; align-items: center; gap: .75rem; position: sticky; top: 0; z-index: 1020; }
.app-content { padding: 1.5rem 1.5rem 2.5rem; flex: 1; max-width: 1500px; width: 100%; }
.app-footer { padding: 1rem 1.5rem; color: var(--suave); font-size: .8rem; border-top: 1px solid var(--borde); background: #fff; }

.brand { display: flex; align-items: center; gap: .75rem; padding: 1.1rem 1.1rem .9rem; color: #fff; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.brand img { width: 42px; height: 42px; object-fit: contain; background: #fff; border-radius: 10px; padding: 3px; }
.brand .brand-ico { width: 42px; height: 42px; border-radius: 10px; background: rgba(255, 255, 255, .14); display: grid; place-items: center; font-size: 1.4rem; }
.brand .brand-nombre { font-weight: 700; font-size: .98rem; line-height: 1.15; }
.brand .brand-sub { font-size: .72rem; opacity: .7; }
.menu-seccion { font-size: .68rem; letter-spacing: .09em; text-transform: uppercase; color: rgba(255, 255, 255, .45); padding: 1rem 1.25rem .35rem; }
.menu-link { display: flex; align-items: center; gap: .7rem; padding: .55rem 1.25rem; color: #cfd8e8; border-left: 3px solid transparent; font-size: .92rem; }
.menu-link i { font-size: 1.05rem; width: 1.25rem; text-align: center; opacity: .9; }
.menu-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.menu-link.activo { background: rgba(255, 255, 255, .12); color: #fff; border-left-color: #7fb2ff; font-weight: 600; }
.menu-link .badge { margin-left: auto; font-size: .68rem; }
.sidebar-pie { margin-top: auto; padding: 1rem 1.25rem; font-size: .72rem; color: rgba(255, 255, 255, .4); }

@media (max-width: 991.98px) {
  .app-main { margin-left: 0; }
  .app-sidebar { transform: translateX(-100%); transition: transform .2s; }
  .app-sidebar.abierto { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
  .sidebar-velo { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 1025; display: none; }
  .sidebar-velo.abierto { display: block; }
  .app-content { padding: 1rem .85rem 2rem; }
}

/* ---------- Componentes ---------- */
.card { border: 1px solid var(--borde); border-radius: .8rem; box-shadow: 0 1px 2px rgba(20, 30, 60, .04); }
.card-header { background: #fff; border-bottom: 1px solid var(--borde); font-weight: 600; padding: .8rem 1.1rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.45rem; margin: 0; font-weight: 700; }
.page-head .sub { color: var(--suave); font-size: .88rem; }

.stat { display: flex; align-items: center; gap: .9rem; padding: 1rem 1.1rem; }
.stat .ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.35rem; background: var(--aip-soft); color: var(--aip); flex: none; }
.stat .num { font-size: 1.55rem; font-weight: 700; line-height: 1.1; }
.stat .lbl { color: var(--suave); font-size: .82rem; }
.stat.ok .ico { background: #e3f6ec; color: #198754; }
.stat.warn .ico { background: #fff4d9; color: #b7791f; }
.stat.bad .ico { background: #fde8e8; color: #c0392b; }

.table > :not(caption) > * > * { padding: .6rem .75rem; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--suave); font-weight: 600; background: #f8f9fc; border-bottom: 1px solid var(--borde); white-space: nowrap; }
.table-hover tbody tr:hover { background: #f8faff; }
.tabla-scroll { overflow-x: auto; }
.vacio { text-align: center; color: var(--suave); padding: 2.2rem 1rem; }
.vacio i { font-size: 2rem; display: block; margin-bottom: .4rem; opacity: .5; }

.filtros { background: #fff; border: 1px solid var(--borde); border-radius: .8rem; padding: .85rem 1rem; margin-bottom: 1rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--aip-soft); color: var(--aip); font-weight: 700; display: inline-grid; place-items: center; font-size: .8rem; flex: none; }
.chip { display: inline-block; padding: .15rem .55rem; border-radius: 99px; background: var(--aip-soft); color: var(--aip-dark); font-size: .78rem; font-weight: 600; }
.req::after { content: " *"; color: #c0392b; }
.demo-banner { background: #fff3cd; color: #7a5b00; border-bottom: 1px solid #ffe69c; padding: .35rem 1rem; font-size: .82rem; text-align: center; }

/* ---------- Horario semanal ---------- */
.grilla { width: 100%; border-collapse: separate; border-spacing: 4px; table-layout: fixed; min-width: 760px; }
.grilla th { text-align: center; font-size: .78rem; color: var(--suave); text-transform: uppercase; letter-spacing: .04em; padding: .35rem; }
.grilla th.hora { width: 110px; text-align: left; }
.grilla td { vertical-align: top; height: 64px; border-radius: .5rem; background: #fff; border: 1px dashed var(--borde); padding: .3rem .4rem; font-size: .8rem; }
.grilla td.recreo { background: repeating-linear-gradient(45deg, #f3f5f9, #f3f5f9 6px, #eceff5 6px, #eceff5 12px); text-align: center; color: var(--suave); vertical-align: middle; border-style: solid; height: 34px; }
.grilla td.hora-lbl { background: transparent; border: 0; font-weight: 600; color: var(--texto); font-size: .8rem; }
.grilla td.hora-lbl small { display: block; font-weight: 400; color: var(--suave); }
.celda { border-radius: .45rem; padding: .3rem .45rem; cursor: pointer; height: 100%; min-height: 50px; border-left: 4px solid var(--aip); background: var(--aip-soft); }
.celda.aip { border-left-color: #7c3aed; background: #f1eafe; }
.celda.pend { border-left-color: #f59e0b; background: #fff6e0; }
.celda.libre { border: 0; background: transparent; color: #b6bdcc; text-align: center; display: grid; place-items: center; }
.celda.libre:hover { color: var(--aip); background: var(--aip-soft); }
.celda .t { font-weight: 700; line-height: 1.15; }
.celda .s { color: var(--suave); font-size: .74rem; }
.celda.hoy-sel { box-shadow: 0 0 0 2px var(--aip); }

/* ---------- Asistencia ---------- */
.asis-fila { display: flex; align-items: center; gap: .75rem; padding: .55rem .9rem; border-bottom: 1px solid var(--borde); flex-wrap: wrap; }
.asis-fila:last-child { border-bottom: 0; }
.asis-fila .nom { flex: 1 1 220px; min-width: 0; font-weight: 600; }
.asis-fila .nom small { display: block; font-weight: 400; color: var(--suave); }
.asis-opc { display: flex; gap: .3rem; flex-wrap: wrap; }
.asis-opc input { position: absolute; opacity: 0; pointer-events: none; }
.asis-opc label { cursor: pointer; padding: .35rem .7rem; border: 1px solid var(--borde); border-radius: 99px; font-size: .8rem; font-weight: 600; background: #fff; color: var(--suave); user-select: none; min-width: 2.6rem; text-align: center; }
.asis-opc input:checked + label.P { background: #198754; border-color: #198754; color: #fff; }
.asis-opc input:checked + label.T { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.asis-opc input:checked + label.F { background: #dc3545; border-color: #dc3545; color: #fff; }
.asis-opc input:checked + label.FJ, .asis-opc input:checked + label.TJ { background: #0dcaf0; border-color: #0dcaf0; color: #04323b; }
.asis-opc input:checked + label.PE { background: #6c757d; border-color: #6c757d; color: #fff; }
.asis-opc input:focus-visible + label { outline: 2px solid var(--aip); outline-offset: 2px; }
.asis-barra { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--borde); padding: .75rem 1rem; display: flex; gap: .75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; z-index: 5; }

/* ---------- Monitoreo ---------- */
.pc-card { border: 1px solid var(--borde); border-radius: .8rem; background: #fff; padding: .85rem .95rem; transition: box-shadow .15s; height: 100%; }
.pc-card:hover { box-shadow: 0 4px 14px rgba(20, 30, 60, .09); }
.pc-card.on { border-top: 4px solid #198754; }
.pc-card.off { border-top: 4px solid #adb5bd; opacity: .82; }
.pc-card.sin { border-top: 4px dashed #ced4da; opacity: .7; }
.pc-card .nombre { font-weight: 700; }
.pc-card .meta { color: var(--suave); font-size: .76rem; }
.punto { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #adb5bd; margin-right: .35rem; }
.punto.on { background: #22c55e; box-shadow: 0 0 0 0 rgba(34, 197, 94, .6); animation: pulso 1.8s infinite; }
@keyframes pulso { 70% { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); } }
.barra-mini { height: 6px; border-radius: 99px; background: #e9edf4; overflow: hidden; }
.barra-mini > span { display: block; height: 100%; background: var(--aip); border-radius: 99px; transition: width .5s; }
.barra-mini > span.alta { background: #dc3545; }
.barra-mini > span.media { background: #f59e0b; }

/* ---------- QR / etiquetas ---------- */
.qr-box canvas, .qr-box img, .qr-box svg { max-width: 100%; height: auto; }
.etiqueta { border: 1px dashed #9aa3b5; border-radius: 6px; padding: 6px 8px; display: flex; gap: 8px; align-items: center; break-inside: avoid; background: #fff; }
.etiqueta .qr { width: 78px; height: 78px; flex: none; }
.etiqueta .qr img { width: 100%; height: 100%; }
.etiqueta .t { font-weight: 800; font-size: 14px; line-height: 1.1; }
.etiqueta .d { font-size: 10px; color: #444; line-height: 1.25; }
.etiquetas-hoja { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
#visor { width: 100%; max-width: 440px; aspect-ratio: 1; background: #111; border-radius: .8rem; overflow: hidden; position: relative; }
#visor video { width: 100%; height: 100%; object-fit: cover; }
#visor .marco { position: absolute; inset: 18%; border: 3px solid rgba(255, 255, 255, .85); border-radius: 14px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.login-lado { background: linear-gradient(150deg, var(--aip-dark), var(--aip) 60%, #3b82c4); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.login-lado::after { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; right: -180px; bottom: -200px; background: rgba(255, 255, 255, .07); }
.login-lado::before { content: ""; position: absolute; width: 300px; height: 300px; border-radius: 50%; left: -120px; top: -100px; background: rgba(255, 255, 255, .06); }
.login-lado h1 { font-weight: 800; font-size: 2.1rem; letter-spacing: -.02em; }
.login-lado .ptos { list-style: none; padding: 0; margin: 2rem 0 0; }
.login-lado .ptos li { display: flex; gap: .7rem; align-items: center; margin-bottom: .8rem; opacity: .92; }
.login-lado .ptos i { background: rgba(255, 255, 255, .16); width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; }
.login-form { display: grid; place-items: center; padding: 2rem; background: #fff; }
.login-form .caja { width: 100%; max-width: 380px; }
@media (max-width: 860px) { .login-wrap { grid-template-columns: 1fr; } .login-lado { display: none; } }

/* ---------- Impresión ---------- */
.solo-imprimir { display: none; }
@media print {
  .app-sidebar, .app-topbar, .app-footer, .no-imprimir, .btn, .filtros, .sidebar-velo, .demo-banner { display: none !important; }
  .app-main { margin: 0 !important; }
  .app-content { padding: 0 !important; max-width: none; }
  body { background: #fff !important; font-size: 11pt; }
  .card { border: 0; box-shadow: none; }
  .solo-imprimir { display: block; }
  .table thead th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: inherit !important; }
  .etiquetas-hoja { gap: 4mm; }
  .etiqueta { border: 1px dashed #999; }
}

/* Grilla de horario docente (celdas de tabla) */
.horario-grid td.celda-libre { background: #fafbfd; color: #b6bdcc; }
.horario-grid td.celda-aula { background: var(--aip-soft); border-left: 4px solid var(--aip); }
.horario-grid td.celda-aip { background: #f1eafe; border-left: 4px solid #7c3aed; }
.horario-grid td[role=button]:hover { outline: 2px solid var(--aip); outline-offset: -2px; }
.horario-grid td { min-width: 110px; height: 62px; }
