/* ==========================================================================
   BS2 → BS5 Compatibility Layer
   --------------------------------------------------------------------------
   Mapea las clases de Bootstrap 2 a sus equivalentes funcionales de BS5
   para que las vistas existentes (151 archivos) funcionen sin reescribirlas.
   Cargar DESPUÉS de bootstrap 5 y ANTES de vp-theme.css.
   ========================================================================== */

/* --- Grid: row-fluid / span-N ----------------------------------------- */
/* BS2 usaba .row-fluid con .span1..span12. BS5 usa .row > .col-N.
   Mapeamos las clases viejas para que hereden el comportamiento de grid BS5. */
.row-fluid { display: flex; flex-wrap: wrap; margin-left: -0.75rem; margin-right: -0.75rem; }
.row-fluid > [class*="span"] { box-sizing: border-box; padding-left: 0.75rem; padding-right: 0.75rem; }
.span12 { flex: 0 0 auto; width: 100%; }
.span11 { flex: 0 0 auto; width: 91.6667%; }
.span10 { flex: 0 0 auto; width: 83.3333%; }
.span9  { flex: 0 0 auto; width: 75%; }
.span8  { flex: 0 0 auto; width: 66.6667%; }
.span7  { flex: 0 0 auto; width: 58.3333%; }
.span6  { flex: 0 0 auto; width: 50%; }
.span5  { flex: 0 0 auto; width: 41.6667%; }
.span4  { flex: 0 0 auto; width: 33.3333%; }
.span3  { flex: 0 0 auto; width: 25%; }
.span2  { flex: 0 0 auto; width: 16.6667%; }
.span1  { flex: 0 0 auto; width: 8.3333%; }
.row-fluid > .offset12 { margin-left: 100%; }
.row-fluid > .offset11 { margin-left: 91.6667%; }
.row-fluid > .offset10 { margin-left: 83.3333%; }
.row-fluid > .offset9  { margin-left: 75%; }
.row-fluid > .offset8  { margin-left: 66.6667%; }
.row-fluid > .offset7  { margin-left: 58.3333%; }
.row-fluid > .offset6  { margin-left: 50%; }
.row-fluid > .offset5  { margin-left: 41.6667%; }
.row-fluid > .offset4  { margin-left: 33.3333%; }
.row-fluid > .offset3  { margin-left: 25%; }
.row-fluid > .offset2  { margin-left: 16.6667%; }
.row-fluid > .offset1  { margin-left: 8.3333%; }

/* BS2 .row (fijo) — que también sea flex */
.row { display: flex; flex-wrap: wrap; margin-left: -0.75rem; margin-right: -0.75rem; }

/* --- Navbar vieja → BS5 navbar ----------------------------------------- */
.navbar { position: relative; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 0.5rem 1rem; border: none !important; margin: 0 !important; }
.navbar-inner { display: flex; flex-wrap: wrap; align-items: center; width: 100%; border: none !important; }
.navbar .nav { display: flex; flex-direction: row; list-style: none; margin: 0; padding-left: 0; border: none !important; }
.navbar .nav > li > a { display: block; padding: 0.5rem 1rem; text-decoration: none; border: none !important; }
.navbar .brand { display: inline-block; padding: 0.5rem 1rem; margin-right: 1rem; font-size: 1.1rem; font-weight: 600; text-decoration: none; border: none !important; }
.navbar .btn-navbar { display: none; }
.navbar .pull-right { margin-left: auto; }
.navbar .nav .dropdown-toggle::after { content: " ▾"; font-size: 0.7em; opacity: 0.5; }
.icon-bar { display: block; width: 18px; height: 2px; background: var(--vp-ink, #5a5a5a); margin-bottom: 3px; border: none !important; }

/* --- Dropdown menu BS2 → BS5 ------------------------------------------ */
.dropdown-menu { display: none; position: absolute; top: 100%; left: 0; z-index: 1000; min-width: 12rem; padding: 0.5rem 0; list-style: none; background: #fff; border: 1px solid rgba(0,0,0,0.15); }
.open > .dropdown-menu,
.show > .dropdown-menu { display: block; }
.dropdown-menu > li > a { display: block; padding: 0.5rem 1rem; text-decoration: none; color: inherit; }
.dropdown-menu > li > a:hover { background: #f8f9fa; }

/* --- Alerts BS2 → BS5 -------------------------------------------------- */
.alert-error { /* BS2 usaba .alert-error, BS5 usa .alert-danger */
  color: #842029; background: #f8d7da; border: 1px solid #f5c2c7;
}
.alert-information { /* BS2 usaba .alert-information, BS5 usa .alert-info */
  color: #055160; background: #cff4fc; border: 1px solid #b6effb;
}

/* --- Labels BS2 → BS5 Badges ----------------------------------------- */
/* BS2 .label = etiqueta inline, BS5 .label ya no existe (es .badge) */
.label { display: inline-block; padding: 0.25em 0.6em; font-size: 75%; font-weight: 600; line-height: 1; text-align: center; white-space: nowrap; border-radius: 0.375rem; }
.label-important { background: #dc3545; color: #fff; }
.label-warning { background: #ffc107; color: #000; }
.label-success { background: #198754; color: #fff; }
.label-info { background: #0dcaf0; color: #000; }
.label-inverse { background: #212529; color: #fff; }
.label-primary { background: #0d6efd; color: #fff; }

/* --- Badges BS2 → BS5 -------------------------------------------------- */
.badge { display: inline-block; padding: 0.35em 0.65em; font-size: 75%; font-weight: 600; line-height: 1; text-align: center; white-space: nowrap; border-radius: 0.375rem; background: #6c757d; color: #fff; }
.badge-success { background: #198754; color: #fff; }
.badge-important { background: #dc3545; color: #fff; }
.badge-warning { background: #ffc107; color: #000; }
.badge-info { background: #0dcaf0; color: #000; }
.badge-inverse { background: #212529; color: #fff; }

/* --- Botones BS2 → BS5 -------------------------------------------------- */
.btn-inverse { color: #fff; background: #212529; border-color: #212529; }
.btn-flat { /* BS2 flat button — no special styling needed in BS5 */ }
.btn-flat.danger { color: #dc3545; border-color: #dc3545; }
.btn-flat.success { color: #198754; border-color: #198754; }

/* --- Utilities BS2 → BS5 ---------------------------------------------- */
.visible-phone { display: none; }
.visible-tablet { display: none; }
.hidden-phone { display: block; }
.hidden-tablet { display: block; }
.visible-desktop { display: block; }
.hidden-desktop { display: none; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.align-center { text-align: center; }

/* BS2 .hidden equivale a BS5 .d-none */
.hidden { display: none !important; }

/* --- Form BS2 → BS5 -------------------------------------------------- */
.control-group { margin-bottom: 1rem; }
.control-label { display: block; margin-bottom: 0.375rem; font-weight: 500; }
.controls { margin-left: 0; }
.form-horizontal .control-label { float: none; width: auto; text-align: left; }
.form-horizontal .controls { margin-left: 0; }
.help-block, .help-inline { color: #6c757d; font-size: 0.875rem; }
.input-xlarge { width: 100%; }
.span12 { /* usada como input full width en BS2 */ }


/* --- Modal BS2 → BS5 ---------------------------------------------- */
/* BS2: <div class="modal hide fade" style="width:640px">
   Sin .modal-dialog/.modal-content. Los hijos directos forman el card.
   El polyfill JS añade .show y display:flex para centrar. */
.modal { position: fixed; top: 0; left: 0; z-index: 1055; width: 100%; height: 100%; overflow-x: hidden; overflow-y: auto; outline: 0; }
.modal.hide { display: none !important; }
.modal.show { display: flex !important; flex-direction: column; align-items: center; padding-top: 5vh; opacity: 1 !important; }
.modal.fade { transition: opacity 0.15s linear; }
.modal[style*="margin-left"] { margin-left: 0 !important; }
.modal[style*="margin-right"] { margin-right: 0 !important; }
/* Hijos del modal (o descendientes, BS2 envuelve form alrededor de body+footer) = el card visual */
.modal .modal-header,
.modal .modal-body,
.modal .modal-footer { position: relative; background: #fff; box-sizing: border-box; margin-left: auto; margin-right: auto; }
.modal .modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.5rem; border: 1px solid #dee2e6; border-radius: 0.5rem 0.5rem 0 0; }
.modal .modal-header .close { padding: 0; background: transparent; border: 0; font-size: 1.5rem; font-weight: 600; color: #000; opacity: 0.5; }
.modal .modal-body { padding: 1.5rem; border-left: 1px solid #dee2e6; border-right: 1px solid #dee2e6; }
.modal .modal-footer { display: flex; gap: 0.5rem; align-items: center; justify-content: flex-end; padding: 1rem 1.5rem; border: 1px solid #dee2e6; border-top: none; border-radius: 0 0 0.5rem 0.5rem; }
/* Ancho del card: el .modal tiene style="width:640px" — los hijos toman ese ancho */
.modal[style*="width"] { width: 640px !important; max-width: 90vw; margin-left: auto !important; margin-right: auto !important; }
.modal[style*="width"] .modal-header,
.modal[style*="width"] .modal-body,
.modal[style*="width"] .modal-footer { width: 100%; }
/* Modales sin ancho inline (abren con data-toggle) — card de 560px centrado */
.modal:not([style*="width"]) { width: 560px !important; max-width: 90vw; margin-left: auto !important; margin-right: auto !important; }
.modal:not([style*="width"]) .modal-header,
.modal:not([style*="width"]) .modal-body,
.modal:not([style*="width"]) .modal-footer { width: 100%; }
/* El form puede envolver body+footer; que no rompa el layout */
.modal form { margin: 0; }
.modal-backdrop { position: fixed; top: 0; left: 0; z-index: 1050; width: 100vw; height: 100vh; background: #000; opacity: 0.5; }
.modal-backdrop.show { opacity: 0.5; }


/* --- Nav tabs BS2 → BS5 ---------------------------------------------- */
.nav-tabs { border-bottom: 1px solid #dee2e6; }
.nav-tabs > li { margin-bottom: -1px; }
.nav-tabs > li > a { display: block; padding: 0.5rem 1rem; text-decoration: none; border: 1px solid transparent; border-radius: 0.375rem 0.375rem 0 0; }
.nav-tabs > li > a:hover { border-color: #e9ecef #e9ecef #dee2e6; }
.nav-tabs > .active > a,
.nav-tabs > .active > a:hover { color: #495057; background: #fff; border: 1px solid #dee2e6; border-bottom-color: transparent; }
.tab-content > .tab-pane { display: none; }
.tab-content > .active { display: block; }

/* --- Tables BS2 → BS5 ---------------------------------------------- */
.table-bordered { border: 1px solid #dee2e6; }
.table-bordered th, .table-bordered td { border: 1px solid #dee2e6; }
.table-striped tbody tr:nth-of-type(odd) { background: rgba(0,0,0,0.03); }
.table-hover tbody tr:hover { background: rgba(0,0,0,0.05); }

/* --- btn-glow / btn-flat (login theme) --------------------------------- */
.btn-glow { border-radius: 0.375rem; }

/* --- Sidebar BS2 → BS5 ---------------------------------------------- */
#sidebar-nav { padding-top: 0 !important; float: none !important; }

/* --- Section (layout viejo) ------------------------------------------- */
.section { padding: 1.5rem; margin-bottom: 1.5rem; }

/* --- Head / sitemap --------------------------------------------------- */
.head { margin-bottom: 1rem; }
.sitemap { padding: 0.5rem 0; }

/* --- big-icon / icon-big ---------------------------------------------- */
.big-icon, .icon-big { font-size: 1.25rem; }
