/* =====================================================================
   Operadores TMEC · Capa de usabilidad y accesibilidad
   Se carga después de app.css. Letras más legibles, botones fáciles de
   tocar, navegación inferior en teléfono y tamaño de letra ajustable.
   ===================================================================== */

:root {
  --muted: #4d5a6e;           /* más contraste que el gris anterior */
  --ink: #111b2b;
  --focus: #ffb020;
  --bottom-nav-h: 68px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bs-secondary-color: #4d5a6e;
}

/* ---- Tamaño de letra elegido por la persona ------------------------- */
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
html[data-text-size="2"] { font-size: 18px; }
html[data-text-size="3"] { font-size: 20px; }
body { line-height: 1.6; }

/* Textos que antes eran demasiado pequeños */
.eyebrow { font-size: .75rem; letter-spacing: .1em; }
.nav-caption { font-size: .74rem; color: #8fb0d6; }
.table thead th { font-size: .78rem; }
.table:not(.document-matrix) thead th { color: #4d5a6e; }
.badge-soft { font-size: .8rem; }
.form-text, .small, small { font-size: max(.84em, 13px); }
.form-label { font-size: .95rem; color: var(--ink); }

/* ---- Botones y campos fáciles de tocar ------------------------------- */
.btn { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; }
.btn-sm { min-height: 38px; }
.btn-lg { min-height: 54px; font-size: 1.08rem; }
.btn-icon { width: 46px; height: 46px; }
.form-control, .form-select { min-height: 50px; font-size: 1rem; }
.form-control-lg { min-height: 56px; font-size: 1.1rem; }
.form-check-input { width: 1.25em; height: 1.25em; }
.dropdown-item { padding: .7rem 1rem; }

/* Foco visible para quien navega con teclado */
:focus-visible { outline: 3px solid var(--focus) !important; outline-offset: 2px; }
.btn:focus-visible, .form-control:focus-visible, .form-select:focus-visible { box-shadow: 0 0 0 .25rem rgba(255, 176, 32, .35) !important; }

.skip-link { position: absolute; left: 12px; top: -60px; z-index: 2000; padding: 10px 16px; border-radius: 10px; color: #fff; background: var(--navy-900); font-weight: 700; text-decoration: none; transition: top .2s; }
.skip-link:focus { top: 12px; color: #fff; }
main:focus { outline: none; }

/* ---- Barra lateral (PC) --------------------------------------------- */
.sidebar-nav .nav-link { font-size: .97rem; padding: 12px 14px; }
.sidebar-nav .nav-link i { font-size: 1.05rem; }

/* ---- Encabezado ------------------------------------------------------ */
.topbar h1 { color: var(--ink); }

/* ---- Selector de tamaño de letra ------------------------------------ */
.text-size-control { min-width: 220px; }
.text-size-label { display: block; margin-bottom: 8px; color: var(--muted); font-size: .85rem; font-weight: 700; }
.text-size-control .btn { min-height: 42px; border: 1px solid var(--line); color: var(--navy-900); background: #fff; font-weight: 800; }
.text-size-control .btn[data-text-size="1"] { font-size: .9rem; }
.text-size-control .btn[data-text-size="2"] { font-size: 1.05rem; }
.text-size-control .btn[data-text-size="3"] { font-size: 1.2rem; }
.text-size-control .btn.active { color: #fff; border-color: var(--blue-600); background: var(--blue-600); }
.text-size-control.is-dark .text-size-label { color: #a9c8ed; }
.text-size-control.is-dark .btn { border-color: rgba(255,255,255,.18); color: #fff; background: rgba(255,255,255,.06); }
.text-size-control.is-dark .btn.active { background: var(--blue-600); border-color: var(--blue-500); }

/* ---- Menú "Más" (teléfono) ------------------------------------------ */
.mobile-sidebar { width: min(86vw, 340px) !important; }
.mobile-sidebar .sidebar-nav .nav-link { color: #d5e3f3; font-size: 1.02rem; padding: 13px 14px; }
.mobile-user-card { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; padding: 12px; border-radius: 14px; background: rgba(255,255,255,.07); }
.mobile-user-card small { color: #a9c8ed; }
.mobile-text-size { margin-top: 18px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.12); }
.btn-logout { color: #ffd9d6; border: 1px solid rgba(255, 120, 110, .45); background: rgba(217, 45, 32, .18); }
.btn-logout:hover { color: #fff; background: #d92d20; }

/* ---- Barra de navegación inferior (teléfono y tableta) -------------- */
.bottom-nav { position: fixed; z-index: 1035; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); height: calc(var(--bottom-nav-h) + var(--safe-bottom)); padding: 6px 6px calc(6px + var(--safe-bottom)); border-top: 1px solid var(--line); background: rgba(255,255,255,.97); backdrop-filter: blur(10px); box-shadow: 0 -8px 24px rgba(13, 47, 85, .08); }
.bottom-nav-item { letter-spacing: -.01em; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0; margin: 0 1px; padding: 4px 0; border: 0; border-radius: 14px; color: #4d5a6e; background: transparent; font-size: 11.5px; font-weight: 700; line-height: 1.1; text-decoration: none; }
.bottom-nav-item i { font-size: 21px; }
.bottom-nav-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bottom-nav-item.active { color: var(--blue-600); background: var(--blue-100); }
.bottom-nav-item:active { transform: scale(.96); }

.back-to-top { position: fixed; z-index: 1030; right: 16px; bottom: 24px; display: grid; place-items: center; width: 50px; height: 50px; border: 0; border-radius: 50%; color: #fff; background: var(--navy-900); box-shadow: 0 10px 24px rgba(7, 27, 52, .3); font-size: 1.1rem; }
.back-to-top[hidden] { display: none; }

.caps-warning { margin-top: 8px; padding: 8px 12px; border-radius: 10px; color: #7a4b00; background: #fff3d6; font-size: .9rem; font-weight: 700; }

@media (max-width: 991.98px) {
  body.has-user { padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom)); }
  .back-to-top { bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 14px); }
  /* el botón de hamburguesa se reemplaza por "Más" en la barra inferior */
  .topbar > div > [data-bs-target="#mobileSidebar"] { display: none; }
  .topbar { min-height: 64px; padding: 10px 14px; }
  .topbar .eyebrow { display: none; }
  .topbar h1 { font-size: 1.25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .document-save-bar { bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 8px) !important; }
  .notification-toast-stack { top: 74px; }
  .footer { display: none; }
}

@media (max-width: 575.98px) {
  /* en teléfono solo se muestra el aviso más urgente; el resto está en la campana */
  .notification-toast-stack .notification-toast:nth-child(n+2) { display: none; }
  .notification-toast-stack { left: 12px; right: 12px; }
}

/* ---- Inicio: buscador y acciones grandes ---------------------------- */
.dashboard-welcome h2 { color: var(--ink); }
.home-start { display: grid; gap: 16px; }
.home-search { padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.home-search .form-label { font-size: 1.05rem; }
.home-search-row { display: flex; gap: 10px; }
.home-search .input-icon > i { font-size: 1.1rem; }
.home-search .input-icon .form-control { padding-left: 46px; }
.home-search .btn { flex: 0 0 auto; padding-inline: 22px; }
.home-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.home-action { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-height: 140px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: #fff; box-shadow: var(--shadow); text-decoration: none; transition: transform .18s ease, border-color .18s ease; }
.home-action:hover { color: var(--ink); border-color: #9cc5f3; transform: translateY(-2px); }
.home-action > span { display: grid; place-items: center; width: 50px; height: 50px; margin-bottom: auto; border-radius: 14px; color: var(--blue-600); background: var(--blue-100); font-size: 1.35rem; }
.home-action strong { margin-top: 12px; font-size: 1.08rem; line-height: 1.25; }
.home-action small { color: var(--muted); font-size: .88rem; }
.home-action.is-primary { color: #fff; border-color: transparent; background: linear-gradient(135deg, var(--blue-600), #0b4fa0); }
.home-action.is-primary:hover { color: #fff; }
.home-action.is-primary > span { color: #fff; background: rgba(255,255,255,.18); }
.home-action.is-primary small { color: #d5e7fd; }

@media (max-width: 991.98px) {
  .home-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .home-action { min-height: 128px; padding: 16px; }
}
@media (max-width: 575.98px) {
  .dashboard-welcome { padding: 18px !important; }
  .dashboard-welcome h2 { font-size: 1.45rem; }
  .home-search { padding: 16px; }
  .home-search .btn { width: 56px; padding: 0; }
}

/* Encabezados de tarjetas: en teléfono el botón de ayuda no queda suelto */
@media (max-width: 575.98px) {
  .panel-card > .card-header.d-flex { flex-wrap: wrap; }
  .panel-card > .card-header .section-heading { flex-wrap: nowrap; width: 100%; }
  .panel-card > .card-header .section-heading .btn-help { margin-left: auto; }
  .panel-card > .card-header > .btn, .panel-card > .card-header > a.btn { width: 100%; }
}

/* ---- Tablas como tarjetas en teléfono ------------------------------- */
@media (max-width: 767.98px) {
  .table-responsive:has(> .table-stack) { overflow: visible; }
  .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack { min-width: 0 !important; }
  .table-stack td, .letters-table.table-stack td { font-size: .95rem; }
  .table-stack td small { font-size: .85rem !important; }
  .table-stack tbody tr { margin: 0; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .table-stack tbody tr:hover { background: transparent; }
  .table-stack > :not(caption) > * > * { padding: 5px 0 !important; border: 0 !important; text-align: left !important; }
  .table-stack td[data-label]:not([data-label=""])::before { content: attr(data-label); display: block; margin-bottom: 1px; color: var(--muted); font-size: .76rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
  .table-stack td:first-child::before { display: none !important; }
  .table-stack td:first-child { font-size: 1.05rem; }
  .table-stack td:last-child .btn, .table-stack .letters-row-actions .btn { min-height: 46px; }
  .table-stack .letters-row-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: stretch; }
  .table-stack .letters-row-actions > * { flex: 1 1 140px; }
  .table-stack .d-flex.justify-content-end { justify-content: flex-start !important; flex-wrap: wrap; }
}

/* ---- Filtros de cartas: en teléfono solo el buscador ---------------- */
.filters-toggle { display: none; }
@media (max-width: 767.98px) {
  .filters-toggle { display: inline-flex; }
  .letters-filter-form:not(.filters-open) .filter-advanced { display: none; }
}

/* ---- Inicio de sesión ------------------------------------------------ */
.auth-card h1 { font-size: 2.1rem; color: var(--ink); }
.auth-card .form-control { min-height: 56px; font-size: 1.1rem; }
.auth-card .input-icon > i { font-size: 1.05rem; }
.password-field button { width: 46px; height: 46px; font-size: 1.1rem; }
.auth-help { margin-top: 22px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; color: var(--muted); background: var(--blue-50); font-size: .92rem; }
.auth-help strong { color: var(--ink); }
.auth-card .text-size-control { margin-top: 18px; }
.security-note { color: var(--muted); }
@media (max-width: 991.98px) {
  .auth-card { padding: 28px 0 40px; }
  .auth-brand { margin-bottom: 28px; }
}

/* ---- Impresión: no imprimir la navegación --------------------------- */
@media print {
  .bottom-nav, .back-to-top, .skip-link { display: none !important; }
  body.has-user { padding-bottom: 0; }
}
