/* Service Builder — custom components on top of Tabler (vendored in /assets/tabler).
   Only things Tabler doesn't ship live here: dynamic stage colors, kanban, calendar,
   timeline, file/signature widgets, field-crew Today cards. */

/* ---- Stage colors (dynamic per pipeline stage via --stage) ---- */
.stage-badge { background: color-mix(in srgb, var(--stage, #6c757d) 15%, white); color: color-mix(in srgb, var(--stage, #6c757d) 75%, black); border: 1px solid color-mix(in srgb, var(--stage, #6c757d) 30%, white); }
.stage-bar { display: flex; flex-wrap: wrap; gap: .35rem; }
.stage { border-radius: 2rem; border-color: var(--tblr-border-color); }
.stage:hover { border-color: var(--stage); color: var(--stage); }
.stage.stage-active, .stage.stage-active:hover { background: var(--stage); border-color: var(--stage); color: #fff; font-weight: 600; }

/* ---- Sidebar brand (long company names) ---- */
.navbar-vertical .navbar-brand { white-space: normal; line-height: 1.2; }
.navbar-vertical .navbar-brand a { color: #fff; font-size: 1rem; }

/* ---- Row links ---- */
.row-link { cursor: pointer; }

/* ---- Relation picker ---- */
.rel-picker { position: relative; }
.rel-picker .rel-results { position: absolute; left: 0; right: 0; top: 100%; z-index: 1030; max-height: 240px; overflow-y: auto; }
.rel-picker .rel-results:not([hidden]) { display: block; }
.rel-picker .rel-results div { padding: .4rem .75rem; cursor: pointer; }
.rel-picker .rel-results div:hover { background: var(--tblr-active-bg, rgba(var(--tblr-primary-rgb), .08)); }

/* ---- Kanban ---- */
.kanban { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: .75rem; align-items: flex-start; }
.kcol { flex: 0 0 272px; background: var(--tblr-bg-surface-secondary); border: 2px solid transparent; }
.kcol.over { border-color: var(--stage, var(--tblr-primary)); }
.kcol .card-header { display: flex; align-items: center; border-top: 3px solid var(--stage, #6c757d); }
.kcards { display: flex; flex-direction: column; gap: .5rem; min-height: 60px; }
.kcard { cursor: grab; }
.kcard.dragging { opacity: .5; }

/* ---- Calendar ---- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--tblr-border-color); }
.cal-dow { background: var(--tblr-bg-surface-secondary); padding: .4rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--tblr-secondary); text-align: center; font-weight: 600; }
.cal-cell { background: var(--tblr-bg-surface); min-height: 104px; padding: .3rem; font-size: .8rem; }
.cal-empty { background: var(--tblr-bg-surface-tertiary, #fafbfc); }
.cal-today { background: rgba(var(--tblr-primary-rgb), .06); }
.cal-day { font-size: .75rem; color: var(--tblr-secondary); margin-bottom: .2rem; font-weight: 600; }
.cal-today .cal-day { color: var(--tblr-primary); }
.cal-item { display: block; padding: .1rem .4rem; margin-bottom: .15rem; border-radius: 3px; font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: color-mix(in srgb, var(--stage, #6c757d) 16%, white); color: color-mix(in srgb, var(--stage, #6c757d) 80%, black); border-left: 3px solid var(--stage, #6c757d); }
.cal-item:hover { filter: brightness(.95); text-decoration: none; }

/* ---- Timeline (Gantt) ---- */
.tl { overflow-x: auto; }
.tl-head, .tl-row { display: grid; grid-template-columns: 280px 1fr; min-width: 760px; border-bottom: 1px solid var(--tblr-border-color); }
.tl-head { background: var(--tblr-bg-surface-secondary); font-size: .7rem; color: var(--tblr-secondary); height: 28px; }
.tl-label { padding: .4rem .75rem; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: .4rem; align-items: center; }
.tl-track { position: relative; min-height: 34px; }
.tl-week { position: absolute; top: 6px; padding-left: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 1px solid var(--tblr-border-color); height: 100%; }
.tl-group { padding: .4rem .75rem; background: var(--tblr-bg-surface-tertiary, #f3f5f8); font-weight: 600; font-size: .85rem; border-bottom: 1px solid var(--tblr-border-color); }
.tl-bar { position: absolute; top: 7px; height: 20px; border-radius: 4px; background: var(--stage); color: #fff; font-size: .7rem; line-height: 20px; padding: 0 .4rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-bar:hover { filter: brightness(1.1); text-decoration: none; color: #fff; }
.tl-late { outline: 2px solid var(--tblr-danger); outline-offset: -2px; }
.tl-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--tblr-danger); opacity: .7; }

/* ---- Files, photos, signatures ---- */
.file-grid { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem; }
.file-item { position: relative; }
.file-item img { width: 104px; height: 104px; object-fit: cover; display: block; }
.file-remove { position: absolute; top: -8px; right: -8px; background: var(--tblr-bg-surface); border-radius: 50%; }
.sig-pad { width: 100%; max-width: 600px; height: 180px; touch-action: none; border-style: dashed !important; }
.sig-img { max-width: 320px; display: block; }

/* ---- Today (field crews) ---- */
.job .btn-list .btn { padding: .6rem 1rem; font-size: 1rem; }

/* ---- Priced documents ---- */
.doc-lines td { padding: .25rem .4rem; }
.doc-lines .form-control-sm, .doc-lines .form-select-sm { font-size: .8rem; }
.doc-totals { min-width: 260px; }
.doc-totals td { padding: .15rem .5rem; }
.doc-totals tr.fs-3 td { padding-top: .4rem; border-top: 1px solid var(--tblr-border-color); }
.pub-doc { max-width: 860px; margin: 0 auto; }
.pub-doc .doc-lines td { padding: .5rem .6rem; }

/* ---- Reports ---- */
.pnl td, .pnl th { white-space: nowrap; }
.pnl tbody tr.bg-light td { background: var(--tblr-bg-surface-secondary); }
.card-sm .subheader { font-size: .7rem; }

/* ---- Misc ---- */
.mail-preview { width: 100%; height: 460px; border: 0; }
.readonly-value { background: var(--tblr-bg-surface-secondary); border-radius: var(--tblr-border-radius); padding: .4rem .75rem !important; }
.font-monospace { font-family: var(--tblr-font-monospace); }
@media (max-width: 767px) {
  .kcol { flex-basis: 84vw; }
  .cal-cell { min-height: 64px; }
  .cal-item { font-size: .65rem; }
}

/* ---- Maps (sbmap.js: Leaflet or Google backend) ---- */
.sb-map { width: 100%; height: 420px; background: var(--tblr-bg-surface-secondary); border-radius: inherit; z-index: 0; }
.sb-map-tall { height: min(72vh, 760px); }
.sb-map-short { height: 260px; }
.sb-pin-wrap { background: none !important; border: 0 !important; filter: drop-shadow(0 1px 2px rgba(0,0,0,.35)); }
.sb-pin-wrap svg { display: block; }
.sb-dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; background: var(--c, #6c757d); border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.leaflet-container { font: inherit; }
.leaflet-container a { color: var(--tblr-primary); }
.leaflet-popup-content { margin: .7rem .9rem; line-height: 1.35; }
.leaflet-popup-content-wrapper { border-radius: .5rem; box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.sb-pop { min-width: 180px; font-size: .85rem; }
.gm-style .sb-pop { font-family: inherit; }

/* ---- Route planner ---- */
.rp-stops { list-style: none; margin: 0; padding: 0; }
.rp-stop { display: flex; align-items: flex-start; gap: .6rem; padding: .55rem .75rem; border-bottom: 1px solid var(--tblr-border-color); background: var(--tblr-bg-surface); cursor: grab; }
.rp-stop:last-child { border-bottom: 0; }
.rp-stop.dragging { opacity: .45; }
.rp-stop.over { box-shadow: inset 0 3px 0 var(--tblr-primary); }
.rp-stop .rp-n { flex: 0 0 26px; height: 26px; border-radius: 50%; background: var(--c, #6c757d); color: #fff; font-weight: 700; font-size: .78rem; display: inline-flex; align-items: center; justify-content: center; margin-top: 1px; }
.rp-stop .rp-body { flex: 1 1 auto; min-width: 0; }
.rp-stop .rp-title { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-stop .rp-meta { font-size: .78rem; color: var(--tblr-secondary); }
.rp-stop .rp-leg { font-size: .72rem; color: var(--tblr-secondary); white-space: nowrap; }
.rp-stop .rp-grip { color: var(--tblr-secondary); opacity: .6; margin-top: 3px; }
.rp-stop .rp-tools { display: flex; flex-direction: column; gap: 2px; }
.rp-stop .rp-tools .btn { padding: 0 .3rem; line-height: 1.1; }
.rp-stop.rp-nogeo { background: repeating-linear-gradient(-45deg, transparent 0 8px, rgba(var(--tblr-warning-rgb), .07) 8px 16px); }
.rp-side { position: sticky; top: 1rem; }
@media (max-width: 991px) { .rp-side { position: static; } .sb-map-tall { height: 50vh; } }
