/* Global density tweaks: keep font sizes, tighten vertical rhythm. */

:root {
  /* Bootstrap uses this for body line-height. Default is ~1.5. */
  --bs-body-line-height: 1.25;

  /* Table cell paddings (default: .5rem .5rem). */
  --bs-table-cell-padding-y: 0.25rem;
  --bs-table-cell-padding-x: 0.5rem;
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Reduce default vertical spacing in common text blocks. */
p {
  margin-bottom: 0.5rem;
}

/* Slightly tighter labels and help text spacing. */
.form-label {
  margin-bottom: 0.25rem;
}

/* Tighten list spacing a bit without affecting indentation. */
ul,
ol {
  margin-bottom: 0.5rem;
}

/* Cards and alerts feel less tall. */
.card-body {
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
}

/* Slightly more modern “surface” look (Bootstrap vars only). */
.card {
  border-color: rgba(var(--bs-body-color-rgb), 0.12);
  box-shadow: var(--bs-box-shadow-sm);
}

.card-header {
  font-weight: 600;
  border-bottom-color: rgba(var(--bs-body-color-rgb), 0.12);
}

.alert {
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
  margin-bottom: 0.75rem;
}

/* Make compact tables/forms consistently compact even when not using -sm classes. */
.table > :not(caption) > * > * {
  padding-top: var(--bs-table-cell-padding-y);
  padding-bottom: var(--bs-table-cell-padding-y);
}

/* Reduce row gaps slightly when using Bootstrap gutters utilities. */
.row.g-3 {
  --bs-gutter-y: 0.75rem;
}

/* Tables: clearer header separation without changing layout. */
.table thead th {
  background-color: var(--bs-tertiary-bg);
  font-weight: 600;
  border-bottom-color: rgba(var(--bs-body-color-rgb), 0.16);
}

/* table-dark thead peab jääma tumedaks — ülemine üldreegel surub muidu heleda
   tausta + valge kiri = nähtamatu (nt aruannete tabelid). */
.table thead.table-dark th,
.table > thead.table-dark th {
  background-color: #1B2D4F;
  color: #fff;
  border-bottom-color: #1B2D4F;
}

/* Buttons: slightly stronger hierarchy. */
.btn {
  font-weight: 500;
}

/* Links: modern underline that doesn’t fight the text. */
a {
  text-decoration-thickness: from-font;
  text-underline-offset: 0.14em;
}

/* Lists: subtle modern hover/focus, consistent separators. */
.list-group-item {
  border-color: rgba(var(--bs-body-color-rgb), 0.12);
}

.list-group-item-action {
  transition: background-color 120ms ease, color 120ms ease;
}

.list-group-item-action:hover {
  background-color: rgba(var(--bs-primary-rgb), 0.06);
}

.list-group-item-action:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 var(--bs-focus-ring-width) var(--bs-focus-ring-color);
}

/* Autocomplete list (daily plan): keep active row readable (not full primary). */
#planWorkOrderSuggest .list-group-item.active {
  background-color: rgba(var(--bs-primary-rgb), 0.14);
  color: var(--bs-body-color);
  border-color: rgba(var(--bs-body-color-rgb), 0.12);
}

#planWorkOrderSuggest .list-group-item.active .text-muted {
  color: rgba(var(--bs-body-color-rgb), 0.72) !important;
}

/* ── Mobile improvements ─────────────────────────────────────────────────── */

/* Minimum touch target size (WCAG 2.5.5) */
@media (max-width: 767.98px) {
  .btn {
    min-height: 2.5rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }

  /* Full-width buttons in action bars on mobile */
  .d-flex.gap-2 > .btn,
  .btn-group-mobile > .btn {
    flex: 1 1 auto;
  }

  /* Looser table cell padding on small screens for readability */
  :root {
    --bs-table-cell-padding-y: 0.5rem;
  }

  /* Page header: stack title + action button on mobile */
  .page-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.5rem;
  }

  /* Hide less critical table columns on mobile */
  .col-hide-mobile {
    display: none;
  }

  /* Filter forms: full-width selects on mobile */
  .filter-form .col-md-2,
  .filter-form .col-md-4 {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* Sticky table header for long lists */
.table-sticky-header thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background-color: var(--bs-tertiary-bg);
}

/* Export button subtle style */
.btn-export {
  font-size: 0.8125rem;
}

/* Global search in navbar */
.navbar-search {
  width: 200px;
  transition: width 200ms ease;
}

.navbar-search:focus {
  width: 280px;
}

@media (max-width: 991.98px) {
  .navbar-search {
    width: 100%;
  }
  .navbar-search:focus {
    width: 100%;
  }

  /* Navbar püsib nähtaval kerimisel — menüü/otsing alati käeulatuses */
  .app-navbar {
    position: sticky;
    top: 0;
    z-index: 1030;
  }
  /* Pikk kokkupandud menüü kerib, ei lükka sisu ekraanilt välja */
  .app-navbar .navbar-collapse {
    max-height: 82vh;
    overflow-y: auto;
  }
  /* Suuremad puutealad lahtikäivas menüüs (WCAG 2.5.5) */
  .app-navbar .nav-link,
  .app-navbar .dropdown-item {
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
  }
  /* Otsing telefonis veidi õhulisem */
  .navbar-search {
    min-height: 2.5rem;
  }
}

/* PWA: arvesta iOS turvaala (sälk/koduriba) ujuva nupu ja sisu juures */
@supports (padding: max(0px)) {
  #pwaInstallBtn {
    bottom: max(16px, env(safe-area-inset-bottom));
  }
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* Notification bell */
.notif-bell {
  position: relative;
}

.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 1rem;
  height: 1rem;
  font-size: 0.65rem;
  line-height: 1rem;
  padding: 0 0.25rem;
  border-radius: 0.5rem;
  background: #dc3545;
  color: #fff;
  pointer-events: none;
}

/* User management role badges */
.role-admin { background-color: #dc3545; }
.role-master { background-color: #0d6efd; }
.role-worker { background-color: #6c757d; }
.role-viewer { background-color: #198754; }

/* ── Navbar: clearer contrast + active item highlight ────────────────────── */
/* Navbar: clearer contrast + active item highlight (Bootstrap variables only). */
.app-navbar {
  --bs-navbar-color: rgba(var(--bs-body-color-rgb), 0.9);
  --bs-navbar-hover-color: rgba(var(--bs-body-color-rgb), 1);
  --bs-navbar-active-color: rgba(var(--bs-body-color-rgb), 1);
  --bs-navbar-brand-color: rgba(var(--bs-body-color-rgb), 1);
  --bs-navbar-brand-hover-color: rgba(var(--bs-body-color-rgb), 1);
}

.app-navbar .nav-link {
  border-radius: var(--bs-border-radius);
  transition: background-color 120ms ease, color 120ms ease;
}

.app-navbar .nav-link:hover {
  background-color: rgba(var(--bs-primary-rgb), 0.12);
}

.app-navbar .nav-link.active,
.app-navbar .nav-link[aria-current='page'] {
  background-color: rgba(var(--bs-primary-rgb), 0.22);
  font-weight: 600;
}

/* ── Kompaktsem UI (2026-07): vähem tühja pinda elementide VAHEL ──────────
   Kirjasuurusi ei muudeta — ainult marginid/paddingud. Bootstrapi
   utiliidiklasse (.mb-4 jt) EI kirjutata üle; tihendus käib komponentide
   kaudu. */

/* Pealkirjad: Bootstrapi vaikimisi .5rem margin-bottom on liiga õhuline. */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  margin-bottom: 0.3rem;
}

/* Kaardid: kitsam sise-padding ka külgedelt + madalam päis/jalus.
   (card-body vertikaal on juba ülal .65rem.) */
.card {
  --bs-card-spacer-x: 0.75rem;
  --bs-card-cap-padding-y: 0.45rem;
  --bs-card-cap-padding-x: 0.75rem;
}

/* Loendid (list-group): read veidi madalamad. */
.list-group {
  --bs-list-group-item-padding-y: 0.4rem;
}

/* Definitsiooniloendid (detailvaadete võti-väärtus plokid). */
dd {
  margin-bottom: 0.25rem;
}

/* Eraldusjooned ei pea võtma tervet rida õhku. */
hr {
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
}
