/* =========================================================
   GeoTrack Pro - Hoja de estilos principal
   Variables de diseño -> modifique aquí colores y tipografía
   ========================================================= */
:root {
  --gt-primary: #0b6bcb;
  --gt-primary-2: #13a89e;
  --gt-sidebar-bg: #0c1b2e;
  --gt-sidebar-fg: #b9c6d6;
  --gt-sidebar-active: #ffffff;
  --gt-sidebar-w: 264px;
  --gt-sidebar-w-collapsed: 76px;
  --gt-topbar-h: 62px;
  --gt-radius: 14px;
  --gt-bg: #f3f6fa;
  --gt-card: #ffffff;
  --gt-border: #e3e8ef;
  --gt-text: #1d2939;
  --gt-muted: #667085;
  --gt-shadow: 0 1px 2px rgba(16,24,40,.06), 0 2px 8px rgba(16,24,40,.05);
  --bs-primary: var(--gt-primary);
  --bs-body-font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
[data-bs-theme="dark"] {
  --gt-bg: #0b1220;
  --gt-card: #121b2b;
  --gt-border: #223047;
  --gt-text: #e6edf6;
  --gt-muted: #97a5b8;
  --gt-sidebar-bg: #070e19;
  --gt-shadow: 0 1px 2px rgba(0,0,0,.4);
  --bs-body-bg: #0b1220;
  --bs-body-color: #e6edf6;
  --bs-border-color: #223047;
}
html, body { height: 100%; }
body { background: var(--gt-bg); color: var(--gt-text); font-size: .94rem; -webkit-font-smoothing: antialiased; }
a { text-decoration: none; }
.btn-primary { --bs-btn-bg: var(--gt-primary); --bs-btn-border-color: var(--gt-primary); --bs-btn-hover-bg: #0957a6; --bs-btn-hover-border-color: #0957a6; }
.text-primary { color: var(--gt-primary) !important; }
.form-control, .form-select { border-radius: 10px; }
.form-control:focus, .form-select:focus { box-shadow: 0 0 0 .2rem rgba(11,107,203,.15); border-color: var(--gt-primary); }

/* ---------- Layout ---------- */
.gt-sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--gt-sidebar-w); background: var(--gt-sidebar-bg); color: var(--gt-sidebar-fg);
  display: flex; flex-direction: column; z-index: 1040; transition: width .25s ease, transform .25s ease;
}
.gt-brand { height: var(--gt-topbar-h); display: flex; align-items: center; gap: .7rem; padding: 0 1.1rem; color: #fff; font-weight: 700; font-size: 1.05rem; border-bottom: 1px solid rgba(255,255,255,.06); white-space: nowrap; overflow: hidden; }
.gt-brand .logo { width: 38px; height: 38px; border-radius: 11px; flex: 0 0 38px; display: grid; place-items: center; background: linear-gradient(135deg, var(--gt-primary), var(--gt-primary-2)); font-size: 1.15rem; overflow: hidden; }
.gt-brand .logo img { width: 100%; height: 100%; object-fit: cover; }
.gt-brand small { display: block; font-weight: 400; font-size: .72rem; color: var(--gt-sidebar-fg); overflow: hidden; text-overflow: ellipsis; }
.gt-nav { flex: 1; overflow-y: auto; padding: .7rem .6rem 1rem; scrollbar-width: thin; }
.gt-group { margin-bottom: .15rem; }
.gt-group-btn { width: 100%; display: flex; align-items: center; gap: .75rem; background: none; border: 0; color: var(--gt-sidebar-fg); padding: .62rem .75rem; border-radius: 10px; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; white-space: nowrap; }
.gt-group-btn:hover { background: rgba(255,255,255,.05); color: #fff; }
.gt-group-btn .bi:first-child { font-size: 1.1rem; flex: 0 0 22px; }
.gt-group-btn .chev { margin-left: auto; transition: transform .2s; font-size: .8rem; }
.gt-group.open .gt-group-btn { color: #fff; }
.gt-group.open .gt-group-btn .chev { transform: rotate(90deg); }
.gt-group-items { display: none; padding: .15rem 0 .35rem; }
.gt-group.open .gt-group-items { display: block; }
.gt-link { display: flex; align-items: center; gap: .75rem; color: var(--gt-sidebar-fg); padding: .55rem .75rem .55rem 1.05rem; border-radius: 10px; margin: 1px 0; white-space: nowrap; font-size: .9rem; position: relative; }
.gt-link .bi { font-size: 1.05rem; flex: 0 0 22px; }
.gt-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.gt-link.active { background: linear-gradient(90deg, rgba(11,107,203,.9), rgba(19,168,158,.75)); color: var(--gt-sidebar-active); box-shadow: 0 4px 14px rgba(11,107,203,.35); }
.gt-sidebar-foot { padding: .8rem 1rem; font-size: .75rem; border-top: 1px solid rgba(255,255,255,.06); white-space: nowrap; overflow: hidden; }

.gt-main { margin-left: var(--gt-sidebar-w); min-height: 100vh; transition: margin-left .25s ease; display: flex; flex-direction: column; }
.gt-topbar { height: var(--gt-topbar-h); position: sticky; top: 0; z-index: 1030; background: color-mix(in srgb, var(--gt-card) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--gt-border); display: flex; align-items: center; gap: .6rem; padding: 0 1rem; }
.gt-topbar .page-title { font-weight: 650; font-size: 1.05rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gt-icon-btn { width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--gt-border); background: var(--gt-card); color: var(--gt-text); display: inline-grid; place-items: center; position: relative; flex: 0 0 40px; }
.gt-icon-btn:hover { border-color: var(--gt-primary); color: var(--gt-primary); }
.gt-icon-btn .badge { position: absolute; top: -5px; right: -5px; font-size: .62rem; }
.gt-content { padding: 1.25rem; flex: 1; }
.gt-content.loading { opacity: .55; pointer-events: none; transition: opacity .15s; }

/* Sidebar colapsado (escritorio) */
body.sb-collapsed .gt-sidebar { width: var(--gt-sidebar-w-collapsed); }
body.sb-collapsed .gt-main { margin-left: var(--gt-sidebar-w-collapsed); }
body.sb-collapsed .gt-brand .txt, body.sb-collapsed .gt-group-btn span, body.sb-collapsed .gt-group-btn .chev, body.sb-collapsed .gt-link span, body.sb-collapsed .gt-sidebar-foot { display: none; }
body.sb-collapsed .gt-link { padding-left: .95rem; justify-content: center; }
body.sb-collapsed .gt-group-btn { justify-content: center; }
body.sb-collapsed .gt-group-items { display: none !important; }
body.sb-collapsed .gt-group.open .gt-group-items { display: block !important; }

/* Móvil: sidebar como panel deslizable */
.gt-backdrop { display: none; }
@media (max-width: 991.98px) {
  .gt-sidebar { transform: translateX(-100%); width: min(86vw, 300px); }
  .gt-main, body.sb-collapsed .gt-main { margin-left: 0; }
  body.sb-open .gt-sidebar { transform: none; }
  body.sb-open .gt-backdrop { display: block; position: fixed; inset: 0; background: rgba(5,12,24,.55); z-index: 1035; }
  body.sb-collapsed .gt-sidebar { width: min(86vw, 300px); }
  body.sb-collapsed .gt-brand .txt, body.sb-collapsed .gt-group-btn span, body.sb-collapsed .gt-group-btn .chev, body.sb-collapsed .gt-link span { display: initial; }
  .gt-content { padding: .9rem; }
}

/* ---------- Componentes ---------- */
.card, .gt-card { background: var(--gt-card); border: 1px solid var(--gt-border); border-radius: var(--gt-radius); box-shadow: var(--gt-shadow); }
.card-header { background: transparent; border-bottom: 1px solid var(--gt-border); font-weight: 600; padding: .85rem 1.1rem; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.section-head h4 { margin: 0; font-weight: 700; font-size: 1.25rem; }
.section-head .sub { color: var(--gt-muted); font-size: .85rem; }
.section-head .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }
.kpi { padding: 1rem 1.1rem; display: flex; flex-direction: row; gap: .9rem; align-items: center; height: 100%; }
.kpi .ico { width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center; font-size: 1.35rem; flex: 0 0 48px; }
.kpi .val { font-size: 1.45rem; font-weight: 750; line-height: 1.1; }
.kpi .lbl { font-size: .8rem; color: var(--gt-muted); }
.ico-blue { background: rgba(11,107,203,.12); color: #0b6bcb; } .ico-green { background: rgba(25,135,84,.13); color: #198754; }
.ico-orange { background: rgba(253,126,20,.14); color: #e8590c; } .ico-red { background: rgba(220,53,69,.13); color: #dc3545; }
.ico-purple { background: rgba(111,66,193,.13); color: #6f42c1; } .ico-teal { background: rgba(19,168,158,.14); color: #0f8f86; }

/* Listas responsivas (en lugar de tablas) */
.gt-list { display: flex; flex-direction: column; gap: .6rem; }
.gt-item { background: var(--gt-card); border: 1px solid var(--gt-border); border-radius: 12px; padding: .8rem 1rem; display: flex; gap: .9rem; align-items: center; flex-wrap: wrap; transition: border-color .15s, box-shadow .15s; }
.gt-item:hover { border-color: color-mix(in srgb, var(--gt-primary) 45%, var(--gt-border)); box-shadow: var(--gt-shadow); }
.gt-item .main { flex: 1 1 0; min-width: 140px; }
@media (min-width: 576px) { .gt-item { flex-wrap: nowrap; } .gt-item .main { min-width: 0; } }
.gt-item .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gt-item .meta { color: var(--gt-muted); font-size: .82rem; display: flex; flex-wrap: wrap; gap: .25rem .9rem; }
.gt-item .stat { text-align: center; min-width: 80px; } .gt-item .stat b { display: block; font-size: 1.02rem; } .gt-item .stat small { color: var(--gt-muted); font-size: .72rem; }
.gt-item .acts { display: flex; gap: .35rem; margin-left: auto; }
.avatar { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; flex: 0 0 46px; display: grid; place-items: center; color: #fff; font-weight: 700; background: var(--gt-primary); border: 2px solid var(--gt-card); box-shadow: 0 0 0 2px var(--gt-border); }
.avatar.sm { width: 34px; height: 34px; flex-basis: 34px; font-size: .8rem; }
.avatar.lg { width: 96px; height: 96px; flex-basis: 96px; font-size: 1.8rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: #98a2b3; }
.dot.on { background: #12b76a; box-shadow: 0 0 0 3px rgba(18,183,106,.2); } .dot.warn { background: #f79009; } .dot.off { background: #98a2b3; }
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: rgba(102,112,133,.12); color: var(--gt-muted); }
.chip.green { background: rgba(18,183,106,.13); color: #039855; } .chip.red { background: rgba(240,68,56,.12); color: #d92d20; }
.chip.orange { background: rgba(247,144,9,.14); color: #dc6803; } .chip.blue { background: rgba(11,107,203,.12); color: #0b6bcb; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--gt-muted); }
.empty-state .bi { font-size: 2.6rem; display: block; margin-bottom: .5rem; opacity: .6; }
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; }
.filters > * { flex: 1 1 180px; }
.filters .btn { flex: 0 0 auto; }

.map-wrap { position: relative; border-radius: var(--gt-radius); overflow: hidden; border: 1px solid var(--gt-border); }
.map-lg { height: calc(100vh - 210px); min-height: 420px; }
.map-md { height: 420px; } .map-sm { height: 280px; }
@media (max-width: 767.98px) { .map-lg { height: 60vh; min-height: 340px; } .map-md { height: 340px; } }
.leaflet-container { font-family: inherit; }
.gt-marker { width: 38px; height: 38px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35); background-size: cover; background-position: center; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: .78rem; }
.gt-marker.off { filter: grayscale(1); opacity: .75; }
.map-side { max-height: calc(100vh - 210px); overflow-y: auto; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .5rem; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; cursor: zoom-in; border: 1px solid var(--gt-border); }
.ai-output { line-height: 1.65; } .ai-output h3, .ai-output h4, .ai-output h5 { margin-top: 1rem; font-weight: 700; }
.chat-box { height: calc(100vh - 290px); min-height: 360px; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .7rem; }
.msg { max-width: 85%; padding: .7rem .95rem; border-radius: 14px; line-height: 1.55; }
.msg.user { align-self: flex-end; background: var(--gt-primary); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: color-mix(in srgb, var(--gt-primary) 7%, var(--gt-card)); border: 1px solid var(--gt-border); border-bottom-left-radius: 4px; }
.progress-thin { height: 6px; border-radius: 9px; }
.select2-container { width: 100% !important; }
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection, [data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown { background-color: #0f1726; color: #e6edf6; border-color: #223047; }
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered { color: #e6edf6; }
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option { color: #e6edf6; }
[data-bs-theme="dark"] .leaflet-tile-pane { filter: brightness(.75) contrast(1.1) saturate(.8); }
.modal-content { border-radius: 16px; border: 1px solid var(--gt-border); background: var(--gt-card); }
.tox-tinymce { border-radius: 10px !important; }
.swal2-popup { border-radius: 16px !important; }
[data-bs-theme="dark"] .swal2-popup { background: #121b2b; color: #e6edf6; }
.cursor-pointer { cursor: pointer; }
.timeline { border-left: 2px solid var(--gt-border); margin-left: .5rem; padding-left: 1rem; }
.timeline .t-item { position: relative; padding-bottom: .9rem; }
.timeline .t-item::before { content: ""; position: absolute; left: -1.42rem; top: .3rem; width: 11px; height: 11px; border-radius: 50%; background: var(--gt-primary); border: 2px solid var(--gt-card); }
.timeline .t-item.stop::before { background: #f79009; } .timeline .t-item.visit::before { background: #12b76a; }
.company-card .logo { width: 56px; height: 56px; border-radius: 14px; object-fit: cover; display: grid; place-items: center; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--gt-primary), var(--gt-primary-2)); flex: 0 0 56px; }
.help-body h5 { margin-top: 1.4rem; font-weight: 700; } .help-body img { max-width: 100%; }
