/* GLOBALTOOLS - estilos de la aplicación (Bootstrap 5.3) */
:root {
    --gt-sidebar: #13243b;
    --gt-sidebar-hover: #1c3352;
    --gt-sidebar-active: #f39c12;
    --gt-sidebar-text: #c6d1e0;
    --gt-sidebar-w: 248px;
    --bs-primary: #1d5fa8;
    --bs-primary-rgb: 29, 95, 168;
    --bs-body-bg: #f3f5f8;
    --bs-body-font-size: .9rem;
}
.btn-primary { --bs-btn-bg: #1d5fa8; --bs-btn-border-color: #1d5fa8; --bs-btn-hover-bg: #174d89; --bs-btn-hover-border-color: #174d89; --bs-btn-active-bg: #133f70; }

body { background: var(--bs-body-bg); }

.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--gt-sidebar-w); flex-shrink: 0; background: var(--gt-sidebar); color: var(--gt-sidebar-text);
    position: fixed; inset: 0 auto 0 0; overflow-y: auto; z-index: 1030; transition: transform .2s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: .6rem; padding: 1rem 1.1rem; color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--gt-sidebar-active); color: #13243b; font-weight: 800; letter-spacing: .5px; }
.brand-mark-lg { width: 56px; height: 56px; font-size: 1.4rem; border-radius: 12px; }
.brand-text { font-weight: 700; letter-spacing: 1px; }
.sidebar-nav { padding: .6rem 0 2rem; }
.nav-item {
    display: flex; align-items: center; gap: .7rem; width: 100%; padding: .55rem 1.1rem; color: var(--gt-sidebar-text);
    text-decoration: none; background: none; border: 0; text-align: left; font-size: .9rem; border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--gt-sidebar-hover); color: #fff; }
.nav-item.active { background: var(--gt-sidebar-hover); color: #fff; border-left-color: var(--gt-sidebar-active); }
.nav-item .bi { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.nav-sub { padding-left: 2.2rem; font-size: .86rem; }
.nav-group .caret { margin-left: auto; font-size: .75rem; transition: transform .2s; }
.nav-group.collapsed .caret { transform: rotate(-90deg); }

/* ---------- Main ---------- */
.main { flex: 1; margin-left: var(--gt-sidebar-w); min-width: 0; transition: margin .2s ease; }
.topbar {
    position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; height: 56px; padding: 0 1.25rem;
    background: #fff; border-bottom: 1px solid #e3e7ee;
}
.topbar-title { font-size: 1.1rem; margin: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.content { padding: 1.25rem; }

body.sidebar-oculto .sidebar { transform: translateX(-100%); }
body.sidebar-oculto .main { margin-left: 0; }
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .main { margin-left: 0; }
    body.sidebar-oculto .sidebar { transform: translateX(0); }
}

/* ---------- Componentes ---------- */
.card { border: 1px solid #e3e7ee; border-radius: .6rem; }
.card-header { background: #fff; font-weight: 600; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.toolbar .filtros { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.table > :not(caption) > * > * { padding: .45rem .6rem; }
table.dataTable thead th { white-space: nowrap; font-size: .8rem; text-transform: uppercase; color: #5b6575; }
table.dataTable td.acciones { white-space: nowrap; text-align: right; width: 1%; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.btn-icon { padding: .2rem .45rem; }

.kpi { display: flex; gap: 1rem; align-items: center; }
.kpi .kpi-icon { width: 46px; height: 46px; border-radius: 10px; display: grid; place-items: center; font-size: 1.35rem; }
.kpi .kpi-valor { font-size: 1.35rem; font-weight: 700; line-height: 1.1; }
.kpi .kpi-label { font-size: .78rem; color: #6c757d; text-transform: uppercase; letter-spacing: .3px; }

/* ---------- Documentos (presupuesto/remisión/factura/compra) ---------- */
.doc-detalle th { font-size: .78rem; text-transform: uppercase; color: #5b6575; background: #f8f9fb; }
.doc-detalle td { vertical-align: middle; }
.doc-detalle input.form-control-sm { min-width: 70px; }
.doc-detalle .col-cant { width: 100px; }
.doc-detalle .col-precio { width: 150px; }
.doc-detalle .col-sub { width: 140px; }
.doc-totales { max-width: 380px; margin-left: auto; }
.doc-totales .row-total { font-size: 1.15rem; font-weight: 700; }
.stock-bajo { color: #dc3545; font-weight: 600; }
.doc-numero { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 600; letter-spacing: .5px; }

/* ---------- Tablas responsive ---------- */
/* Listados (DataTables Responsive): fila desplegable con las columnas ocultas */
table.dataTable > tbody > tr > td.dtr-control { cursor: pointer; }
table.dataTable > tbody > tr.child ul.dtr-details { width: 100%; }
table.dataTable > tbody > tr.child ul.dtr-details > li { display: flex; gap: .75rem; justify-content: space-between; padding: .35rem 0; }
table.dataTable > tbody > tr.child span.dtr-title { font-size: .75rem; text-transform: uppercase; color: #5b6575; font-weight: 600; min-width: 110px; }
table.dataTable > tbody > tr.child span.dtr-data { text-align: right; }
/* Informes: todas las columnas, con desplazamiento horizontal (la impresión/Excel salen completos) */
.dt-container:has(table.tabla-scroll) .dt-layout-table > .dt-layout-cell { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tabla-scroll td, table.tabla-scroll th { white-space: nowrap; }
/* Tablas de detalle y formularios: en pantallas chicas se desplazan horizontalmente en vez de aplastarse */
.table-responsive { -webkit-overflow-scrolling: touch; }
@media (max-width: 767.98px) {
    .table-responsive > .table:not(.tabla-chica) { min-width: 620px; }
    .table-responsive > .table.doc-detalle, .table-responsive > .table.tabla-ancha { min-width: 760px; }
    .content { padding: .75rem; }
    .card-body { padding: .85rem; }
    div.dt-container div.dt-layout-row { flex-wrap: wrap; gap: .5rem; }
    div.dt-container div.dt-search input { width: 100%; max-width: 220px; }
    .toolbar .filtros { width: 100%; margin-left: 0 !important; }
    .toolbar .filtros > * { flex: 1 1 140px; }
}
@media print {
    .table-responsive, .dt-layout-table > .dt-layout-cell { overflow: visible !important; }
    .table-responsive > .table { min-width: 0 !important; }
}

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #13243b 0%, #1d5fa8 100%); padding: 1rem; }
.login-card { width: 100%; max-width: 400px; border: 0; border-radius: 1rem; }

.select2-container--bootstrap-5 .select2-selection { font-size: .9rem; }
.swal2-popup { font-size: .9rem; }

/* Avisos (SweetAlert2): botón principal con el azul del sistema; los botones de anulación mantienen su rojo (estilo en línea) */
.swal2-styled.swal2-confirm { background-color: #1d5fa8; }
.swal2-styled.swal2-confirm:focus { box-shadow: 0 0 0 3px rgba(29, 95, 168, .4); }
