/* Fixtar custom styles */

/*
 * The theme's own .card rule sets --bs-card-height: calc(100% - gutter),
 * so any card placed inside a flex/stretch ancestor (e.g. a container-fluid
 * with d-flex flex-column, or a Bootstrap row) inflates to fill the full
 * height of that context instead of sizing to its own content. That's the
 * right behavior for a row of equal-height dashboard tiles, but wrong for
 * ordinary stacked content cards (forms, tables, etc.), where it produces
 * huge cards with mostly empty space.
 *
 * Default back to natural content height everywhere, and let pages that
 * genuinely want equal-height cards opt back in with .h-100 (which sets
 * height directly and isn't affected by this reset).
 */
.card {
  --bs-card-height: auto;
}

/*
 * On narrow screens, list-table cells otherwise wrap free text (client
 * names, descriptions) line-by-line inside cramped columns before the
 * .table-responsive scroll ever kicks in, which reads as broken/squished.
 * Force single-line cells so the wrapper's horizontal scroll is the only
 * thing that engages - one clean scrollable row beats several wrapped ones.
 * Cells holding inputs/selects (line-item builder tables) are unaffected
 * since those controls already have their own fixed widths.
 */
@media (max-width: 767.98px) {
  .table-responsive > table td,
  .table-responsive > table th {
    white-space: nowrap;
  }
}

/*
 * .app-toggler is the only control that opens the off-canvas sidebar on
 * mobile, but the theme ships it at a fixed 28x28px - fine for a mouse
 * click, too small for a reliable thumb tap (well under the ~44px minimum
 * touch target). Enlarge the tappable box on phones; the icon inside
 * keeps its own size and just gets more breathing room.
 */
@media (max-width: 767.98px) {
  .app-toggler {
    width: 44px;
    height: 44px;
    margin: 16px 10px;
  }
}

/*
 * .searchable-select (static/js/searchable_select.js) turns a plain <select>
 * into a live-search dropdown. The toggle reuses .form-select as-is, so this
 * only adds the layout the plain <select> didn't need: full-width menu,
 * a scrollable option list, and truncating long labels instead of wrapping.
 */
.searchable-select {
  position: relative;
}
.searchable-select-toggle {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.searchable-select-menu {
  width: 100%;
  min-width: 100%;
}
.searchable-select-list {
  max-height: 240px;
  overflow-y: auto;
}

/*
 * Multi-select mode (e.g. Site Crew) keeps the dropdown open across clicks
 * so each item needs its own persistent checked/unchecked indicator, since
 * there's no single "active" row like the single-select case has.
 */
.searchable-select-item-multi {
  display: flex;
  align-items: center;
  gap: 8px;
}
.searchable-select-check {
  font-size: 0.75rem;
  width: 1em;
  flex-shrink: 0;
}

/* Bootstrap only ships min-vh-0/25/50/75/100; the project picker page wants 80. */
.min-vh-80 {
  min-height: 80vh;
}

/*
 * The project picker's card grid (templates/projects/_picker_content.html)
 * is rendered both as a full page and, unchanged, as the body of the
 * sidebar's "Switch Project" modal. Bootstrap's .row/.col-* grid sizes
 * columns off the *viewport* width (e.g. col-xl-4 assumes a real xl-wide
 * viewport), not the width of whatever container it's actually in - inside
 * the much narrower modal this forced 3 columns into a box that only had
 * room for one, and .row's negative margins have no container padding to
 * cancel against in the modal body, so cards overflowed past the modal
 * edge and their status badges rendered on top of/outside the neighbouring
 * card. A real CSS grid sizes tracks off its own container instead, so it
 * looks right at any width without needing to know if it's on the page or
 * in a modal.
 */
.picker-cards-grid {
  display: grid;
  /*
   * minmax(0, 1fr), not a bare 1fr: grid tracks otherwise refuse to shrink
   * past each item's content-based minimum width (its longest unbreakable
   * word/box), so a track can end up wider than its fair share and overflow
   * the grid - which is what let long project names and their status badge
   * push past the card edge instead of the title truncating.
   */
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}
@media (min-width: 480px) {
  .picker-cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (min-width: 768px) {
  .picker-cards-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/*
 * Flex items default to min-width: auto, so a title next to a status badge
 * in a flex row won't actually shrink below its own text length - it just
 * pushes the row (and the badge) wider instead of truncating. min-width: 0
 * lifts that floor so text-truncate's overflow/ellipsis can take effect.
 */
.picker-card-title {
  min-width: 0;
  flex: 1 1 auto;
}
/* Same fix as above, for a flex child that *wraps* a title+subtitle pair
   instead of being the title itself - Bootstrap ships no min-w-0 utility
   in this build. */
.picker-card-title-wrap {
  min-width: 0;
  flex: 1 1 auto;
}

/*
 * The picker page (a full-screen "choose your workspace" landing page, not
 * just another list view) gets a very faint brand tint instead of flat
 * white, and its cards get a status-coloured top accent plus a hover lift
 * so the grid doesn't read as a wall of identical grey boxes.
 */
.picker-page {
  background: linear-gradient(180deg, rgba(var(--bs-primary-rgb), 0.05), transparent 280px), var(--bs-body-bg);
  min-height: 100vh;
}
.picker-header {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.picker-search-input {
  position: relative;
}
.picker-search-input > i {
  position: absolute;
  top: 50%;
  left: 0.9rem;
  transform: translateY(-50%);
  color: var(--bs-secondary-color);
  pointer-events: none;
}
.picker-search-input > input {
  padding-left: 2.3rem;
}

.picker-card {
  box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.05);
  border-top: 3px solid var(--bs-secondary-border-subtle);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.picker-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.1);
}
.picker-card--completed {
  border-top-color: var(--bs-success);
}
.picker-card--on_hold {
  border-top-color: var(--bs-warning);
}
.picker-card--in_progress {
  border-top-color: var(--bs-primary);
}
.picker-card-overall {
  border-top-color: var(--bs-primary);
}

.picker-overall-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--bs-border-radius);
  background: var(--bs-primary-bg-subtle);
  color: var(--bs-primary);
  font-size: 1rem;
}

/* A plain-coloured initial in place of an actual logo/photo - cheap visual
   anchor that also makes each card easier to tell apart at a glance. */
.picker-client-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bs-secondary-bg-subtle);
  color: var(--bs-secondary-color);
  font-weight: 600;
  font-size: 0.85rem;
}

.picker-progress {
  height: 6px;
}

/* An un-named project (still carrying its auto-generated "Project from
   FXT/QT/xxxx" fallback title) should read as a placeholder, not a typo. */
.picker-card-title--unnamed {
  font-style: italic;
  opacity: 0.75;
}

/*
 * "Install Fixstar" prompt (templates/base.html): a slim pill bar centred at the
 * bottom of the screen. It only covers its own area - the rest of the page stays
 * clickable and focusable (it is deliberately not a Bootstrap modal).
 */
.pwa-install-bar {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  z-index: 1040; /* below Bootstrap modals (1050+) so dialogs cover it */
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: max-content;
  max-width: calc(100vw - 2rem);
  padding: 0.6rem 0.75rem 0.6rem 1.1rem;
  background: var(--bs-body-bg, #fff);
  color: var(--bs-body-color);
  border: 1px solid var(--bs-border-color);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.12);
  animation: pwa-bar-in 0.25s ease-out;
}
.pwa-install-bar[hidden] {
  display: none !important;
}
.pwa-install-icon {
  color: var(--bs-primary);
  font-size: 1.05rem;
  line-height: 1;
}
.pwa-install-text {
  color: var(--bs-primary);
  font-size: 0.9rem;
}
.pwa-install-btn {
  white-space: nowrap;
  border-radius: 8px;
}
.pwa-install-close {
  font-size: 0.65rem;
  opacity: 0.5;
}
.pwa-install-close:hover {
  opacity: 0.9;
}
@keyframes pwa-bar-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
@media (max-width: 575.98px) {
  .pwa-install-bar {
    left: 1rem;
    right: 1rem;
    width: auto;
    transform: none;
    animation: none;
  }
  .pwa-install-text {
    font-size: 0.8rem;
  }
}

/*
 * bootstrap-select (.selectpicker) copies the original <select>'s classes
 * onto the *outer* .bootstrap-select wrapper it generates (not the toggle
 * button), so a field styled with our own .form-select ends up with two
 * carets: .form-select's native chevron (a background-image on that
 * wrapper) and bootstrap-select's own caret (the toggle button's
 * .dropdown-toggle::after triangle). Drop the background-image one and
 * keep bootstrap-select's, since it's the one actually wired to the
 * dropdown's open/closed state.
 */
.bootstrap-select.form-select {
  background-image: none;
}

/* Eye toggle added to every password field by static/js/app_enhance.js. */
.password-toggle-group .password-toggle-btn {
  border-color: var(--bs-border-color);
}

/* Search box injected above long lists by data-filter-list (app_enhance.js). */
.list-filter-input {
  max-width: 320px;
}

/* Segmented source toggle (Price list / Products / Custom) on line-item rows. */
.source-toggle .btn {
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
}

/* Removable chips under multi-select searchable dropdowns. */
.searchable-select-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.searchable-select-chips:empty {
  display: none;
}
.searchable-select-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px 2px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  background: var(--bs-primary-bg-subtle);
  color: var(--bs-primary-text-emphasis);
}
.searchable-select-chip .btn-close {
  font-size: 0.55rem;
}

/*
 * Printing any page: drop the app chrome and the sidebar gutter so the page
 * content uses the full sheet. Selectors are deliberately specific - the
 * theme's own .app-wrapper margin would otherwise win and squeeze documents
 * into a narrow column spread over several pages.
 */
@media print {
  @page { size: A4; margin: 10mm; }
  html body header.app-header,
  html body aside.app-menubar-tabs,
  html body .app-menubar,
  html body footer.footer-wrapper,
  html body #page-progress-bar,
  html body .modal,
  html body .modal-backdrop,
  html body #otherside-root,
  html body .no-print { display: none !important; }
  html, body { background: #fff !important; }
  html body .page-layout .app-wrapper,
  html body main.app-wrapper {
    margin: 0 !important;
    padding: 0 !important;
    min-height: 0 !important;
    width: auto !important;
  }
  html body .app-wrapper > .container-fluid { padding: 0 !important; max-width: none !important; }
  .alert { display: none !important; }
}

/* Files Gallery tiles (apps/common/templates/common/_gallery_grid.html). */
.gallery-tile {
  position: relative;
  border: 1px solid var(--bs-border-color);
  border-radius: 10px;
  background: var(--bs-body-bg);
  overflow: hidden;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.gallery-tile:hover {
  border-color: var(--bs-primary);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
}
.gallery-tile-body {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0 0 0.5rem;
  border: 0;
  background: none;
  text-align: left;
  color: inherit;
  text-decoration: none;
}
.gallery-thumb {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  background: var(--bs-tertiary-bg, #f4f5f7);
  color: var(--bs-secondary-color);
  font-size: 2rem;
  margin-bottom: 0.4rem;
}
.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.gallery-ext {
  position: absolute;
  bottom: 6px;
  right: 8px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.gallery-name,
.gallery-meta {
  padding: 0 0.6rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gallery-name {
  font-size: 0.8rem;
  font-weight: 600;
}
.gallery-meta {
  font-size: 0.7rem;
  color: var(--bs-secondary-color);
}
.gallery-remove-form {
  position: absolute;
  top: 6px;
  right: 6px;
}
.gallery-remove {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: var(--bs-danger);
  font-size: 0.7rem;
}

/* File field with gallery picker (templates/includes/file_picker.html). */
.file-picker-current {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.6rem;
  margin-bottom: 0.4rem;
  border: 1px dashed var(--bs-border-color);
  border-radius: 8px;
  font-size: 0.85rem;
}
.file-picker-current.d-none {
  display: none !important;
}

/* Webcam capture window (templates/base.html #cameraModal). */
.camera-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  background: #111;
  border-radius: 10px;
  overflow: hidden;
}
.camera-stage video,
.camera-stage img {
  width: 100%;
  max-height: 65vh;
  object-fit: contain;
}
.camera-message {
  padding: 2rem 1.5rem;
  color: #f1f5f9;
  text-align: center;
}

/* Multi-select in the Files Gallery picker, and picked-file chips. */
.gallery-tile.selected {
  border-color: var(--bs-success);
  box-shadow: 0 0 0 2px var(--bs-success);
}
.gallery-tile.selected::after {
  content: "\2713";
  position: absolute;
  top: 6px;
  left: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bs-success);
  color: #fff;
  font-size: 0.75rem;
  line-height: 22px;
  text-align: center;
}
.file-picker-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
}
.file-picker-list:empty {
  display: none;
}
.file-picker-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.6rem;
  border: 1px dashed var(--bs-border-color);
  border-radius: 8px;
  font-size: 0.85rem;
}

/* Toggle tiles: radio buttons shown as selectable cards (expense form, etc.). */
.option-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem;
}
.option-tiles-stacked {
  grid-template-columns: 1fr;
  gap: 0.5rem;
}
.option-tile {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.75rem;
  align-items: center;
  padding: 0.8rem 1rem;
  border: 1.5px solid var(--bs-border-color);
  border-radius: 12px;
  background: var(--bs-body-bg);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
  position: relative;
  margin: 0;
}
.option-tile > i {
  grid-row: span 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--bs-tertiary-bg);
  color: var(--bs-secondary-color);
  font-size: 1.1rem;
  line-height: 1;
}
.option-tile-title { font-weight: 600; line-height: 1.2; }
.option-tile-text { font-size: 0.78rem; color: var(--bs-secondary-color); line-height: 1.3; }
.option-tile:hover { border-color: rgba(var(--bs-primary-rgb), 0.5); }
.btn-check:checked + .option-tile {
  border-color: var(--bs-primary);
  background: rgba(var(--bs-primary-rgb), 0.06);
  box-shadow: 0 0 0 3px rgba(var(--bs-primary-rgb), 0.12);
}
.btn-check:checked + .option-tile > i { background: var(--bs-primary); color: #fff; }
.btn-check:checked + .option-tile::after {
  content: "\2713";
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--bs-primary);
}
.btn-check:focus-visible + .option-tile { outline: 2px solid var(--bs-primary); outline-offset: 2px; }

.step-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-right: 0.35rem;
  border-radius: 50%;
  background: rgba(var(--bs-primary-rgb), 0.12);
  color: var(--bs-primary);
  font-size: 0.75rem;
  font-weight: 700;
}
.approval-switch {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: var(--bs-tertiary-bg);
}
.approval-switch .form-switch .form-check-input { width: 2.5em; height: 1.3em; cursor: pointer; }
.approval-switch .form-check-label { padding-left: 0.35rem; padding-top: 0.1rem; cursor: pointer; }

/* Petty cash float cards. */
.stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  font-size: 1.15rem;
  flex-shrink: 0;
}
.float-card { transition: box-shadow 0.15s, transform 0.15s; }
.float-card:hover { box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08); transform: translateY(-1px); }
.float-card .progress { height: 6px; }
.float-card .min-w-0 { min-width: 0; }

/* Project dashboard (apps/projects/templates/projects/dashboard.html). */
.dash-hero { border: 0; }
.dash-hero-badge { background: rgba(var(--bs-primary-rgb), 0.1); color: var(--bs-primary); font-weight: 500; }
.dash-hero-muted { color: var(--bs-secondary-color); }
.dash-hero-big { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.dash-hero-progress { height: 6px; }
.dash-kpi .card-body { padding: 1rem; }
.dash-kpi .stat-icon { width: 36px; height: 36px; font-size: 1rem; border-radius: 10px; margin-bottom: 0.6rem; }
.dash-kpi-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--bs-secondary-color); }
.dash-kpi-value { font-size: 1rem; font-weight: 700; line-height: 1.3; word-break: break-word; }
.dash-kpi-sub { font-size: 0.75rem; color: var(--bs-secondary-color); margin-top: 0.2rem; }
.dash-tile {
  padding: 0.85rem;
  border-radius: 12px;
  background: var(--bs-tertiary-bg);
  height: 100%;
}
.dash-tile > i { font-size: 1.1rem; }
.dash-tile-value { font-size: 1.35rem; font-weight: 700; line-height: 1.2; margin-top: 0.3rem; }
.dash-tile-label { font-size: 0.75rem; color: var(--bs-secondary-color); }
.dash-actions .list-group-item { border-color: var(--bs-border-color-translucent); background: transparent; }
.dash-alert {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.5rem;
  border-left: 3px solid var(--bs-warning);
  border-radius: 8px;
  background: rgba(var(--bs-warning-rgb), 0.08);
}
.dash-alert > i { color: var(--bs-warning); margin-top: 0.15rem; }
.dash-timeline li {
  position: relative;
  padding: 0 0 0.85rem 1.1rem;
  border-left: 2px solid var(--bs-border-color);
  margin-left: 0.3rem;
}
.dash-timeline li:last-child { padding-bottom: 0; border-left-color: transparent; }
.dash-timeline li::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bs-body-bg);
  border: 2px solid var(--bs-primary);
}
.dash-timeline li.is-late::before { border-color: var(--bs-danger); }
.dash-timeline li:only-child { border-left-color: transparent; }
.dash-timeline li.dash-timeline-empty { border-left: 0; padding-left: 0; margin-left: 0; }
.dash-timeline li.dash-timeline-empty::before { display: none; }

/* Bill of Quantities page (quotations/boq_page.html). */
.boq-table .boq-section { cursor: pointer; background: var(--bs-tertiary-bg); }
.boq-table .boq-section.boq-depth-0 td { background: rgba(var(--bs-primary-rgb), 0.07); border-top: 2px solid rgba(var(--bs-primary-rgb), 0.25); }
.boq-table .boq-section:hover td { background: rgba(var(--bs-primary-rgb), 0.12); }
.boq-table .boq-section.boq-depth-1 td:nth-child(2) { padding-left: 1.5rem; }
.boq-table .boq-section.boq-depth-2 td:nth-child(2) { padding-left: 2.5rem; }
.boq-caret { display: inline-block; transition: transform 0.15s; vertical-align: middle; }
.boq-section.is-collapsed .boq-caret { transform: rotate(-90deg); }
@media print {
  .boq-table .boq-item[hidden] { display: table-row !important; }
}

/* Header back / refresh buttons (templates/includes/header.html). */
.header-nav-buttons { margin-left: 0.5rem; margin-right: 0.5rem; }
.header-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--bs-border-color);
  border-radius: 10px;
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  font-size: 1rem;
  line-height: 1;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.header-nav-btn:hover { border-color: var(--bs-primary); color: var(--bs-primary); background: rgba(var(--bs-primary-rgb), 0.06); }
.header-nav-btn:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 2px; }
.header-nav-btn i { display: inline-flex; }
.header-nav-btn.is-spinning i { animation: header-spin 0.8s linear infinite; }
@keyframes header-spin { to { transform: rotate(360deg); } }

/* WhatsApp brand button (quotation detail). */
.btn-whatsapp { background: #25d366; border-color: #25d366; color: #fff; }
.btn-whatsapp:hover, .btn-whatsapp:focus { background: #1ebe5b; border-color: #1ebe5b; color: #fff; }
