/* DKS App specific styles. Load after theme.css. */

#sidebarPanel {
  width: 300px;
}

/* In an iOS home screen app, the fixed bottom menu sits above the home
   indicator until the document scrolls. Together with the safe-area margins,
   this makes every page slightly taller than the screen so the menu always
   sits at the screen edge. */
#appCapsule {
  min-height: 100vh;
}

/* Android resizes the page for the keyboard (interactive-widget in base.html),
   which would put the bottom menu right above the keyboard. */
body:has(input:not([type=checkbox], [type=radio], [type=button], [type=submit]):focus, textarea:focus) .appBottomMenu {
  display: none;
}

@media only screen and (max-width: 576px) {
  .small-table .table td,
  .small-table .table th {
    padding: 2px;
    font-size: 13px;
  }
}
@media only screen and (max-width: 576px) {
  /* Force table to not be like tables anymore */
  .stack-table table,
  .stack-table thead,
  .stack-table tbody,
  .stack-table th,
  .stack-table td,
  .stack-table tr {
    display: block;
  }
  /* Hide table headers (but not display: none;, for accessibility) */
  .stack-table thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }
  .stack-table tr {
    border: 1px solid #ccc;
  }
  .stack-table td {
    /* Behave  like a "row" */
    border: none;
    border-bottom: 1px solid #eee;
    position: relative;
    padding-left: 50%;
    white-space: normal;
    text-align: left;
  }
  .stack-table td:before {
    /* Now like a table header */
    position: absolute;
    /* Top/left values mimic padding */
    top: 6px;
    left: 6px;
    width: 45%;
    padding-right: 10px;
    white-space: nowrap;
    text-align: left;
    font-weight: bold;
  }
  /*
  Label the data
  */
  .stack-table td:before {
    content: attr(data-title);
  }
}
.dks-chart {
  min-height: 350px;
}

/* Bootstrap 5.3 paints color/background on every cell via --bs-table-* vars,
   so map the theme colors onto those instead of setting them on table/tr. */
.table {
  --bs-table-color: var(--color-text);
  --bs-table-bg: transparent;
  --bs-table-striped-color: var(--color-text);
  --bs-table-striped-bg: rgba(225, 225, 225, 0.1);
}
body.dark-mode-active .table {
  --bs-table-color: var(--dark-mode-color-text);
  --bs-table-striped-color: var(--dark-mode-color-text);
  --bs-table-striped-bg: rgba(27, 40, 59, 0.5);
}

.status-ascertained {
  --bs-table-bg-state: rgba(255, 238, 127, 0.3);
  --bs-table-color-state: #333;
}

.status-ok {
  --bs-table-bg-state: rgba(43, 167, 0, 0.3);
  --bs-table-color-state: #333;
}

.dks-coach-header-icons {
  font-size: 34px;
}

.dks-coach-holder {
  min-height: 80vh;
  height: auto;
}

.dks-coach-table td.day {
  font-size: 2vh;
  position: relative;
  padding-bottom: 50px;
}

.dks-coach-current {
  font-size: 13px;
}

.dks-coach-add {
  position: absolute;
  bottom: 8px;
  right: 8px;
  font-size: 3vh;
}

/* Clear button for search fields. Wrapper carries both .form-group and
   .input-wrapper, so the theme's nested .form-group .input-wrapper rules
   don't apply. */
.search-clearable {
  position: relative;
}
.searchbox .form-control,
.search-clearable .form-control {
  padding-right: 36px;
}

.searchbox .clear-input,
.search-clearable .clear-input {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  z-index: 2;
  width: 36px;
  height: auto;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--color-text);
  opacity: 0.5;
  cursor: pointer;
}
.searchbox .clear-input:hover,
.search-clearable .clear-input:hover {
  opacity: 0.8;
}
.input-wrapper.not-empty > .clear-input {
  display: flex;
}
.searchbox .clear-input i.bi,
.search-clearable .clear-input i.bi,
.searchbox .input-icon i.bi {
  font-size: 18px;
}

/* Full-width search header: clear button sits left of the close link */
#search .searchbox .form-control {
  padding-right: 90px;
}
#search .searchbox .clear-input {
  right: 54px;
}

.input-wrapper input[type=search]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.table.table-borderless td,
.table.table-borderless th {
  border: none;
}

/* Dark backdrop for carousel arrows. Not using .bg-dark: the theme defines it
   with the `background` shorthand, which wipes Bootstrap's SVG arrow image. */
.carousel-control-prev-icon,
.carousel-control-next-icon {
  background-color: #222;
}

/* PDF preview: the page scrolls vertically like every other page (iOS only moves
   its fixed bottom menu to the screen edge once the document scrolls); the viewer
   itself only scrolls sideways when zoomed. Pinch zoom is handled in JS. */
.document-pdf {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  min-height: calc(100vh - 112px);
  padding: 8px;
  background: #e9ecef;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
}
.document-pages {
  margin: 0 auto;
}
.document-page {
  background: #fff;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.document-page canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Page loader overlay for slow pages */
.dks-page-loader {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.6);
  animation: dks-page-loader-in 0.2s ease-in;
}
.dks-page-loader[hidden] {
  display: none;
}
body.dark-mode-active .dks-page-loader {
  background: rgba(12, 22, 36, 0.6);
}
@keyframes dks-page-loader-in {
  from {
    opacity: 0;
  }
}

/* Extra header with one row of underlined tabs that scrolls sideways when the
   labels don't fit. Tabs fill the width when there is room. */
.extraHeader.dks-scroll-tabs {
  padding: 0;
}
.dks-scroll-tabs .nav-tabs.lined {
  position: relative;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.dks-scroll-tabs .nav-tabs.lined::-webkit-scrollbar {
  display: none;
}
.dks-scroll-tabs .nav-tabs.lined .nav-item {
  flex: 1 0 auto;
  width: auto;
}
.dks-scroll-tabs .nav-tabs.lined .nav-item .nav-link {
  padding: 0 14px;
  white-space: nowrap;
}

/* Article product description (plain text from MGM, formatted by the
   product_description template filter) */
.product-description {
  line-height: 1.6;
}
.product-description p,
.product-description ul {
  margin-bottom: 0.75rem;
}
.product-description > :last-child {
  margin-bottom: 0;
}
.product-description h4 {
  margin: 1rem 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
}
.product-description > h4:first-child {
  margin-top: 0;
}
.product-description ul {
  padding-left: 1.25rem;
}
.product-description li + li {
  margin-top: 0.15rem;
}

/* Spare part tiles: same size, square image, max. 2 lines of name */
.spare-part {
  height: 100%;
  border: 1px solid var(--color-line);
  border-radius: 6px;
  overflow: hidden;
}
.spare-part-image {
  display: block;
  aspect-ratio: 1 / 1;
  padding: 6px;
  background: #fff;
}
.spare-part-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.spare-part-caption {
  padding: 4px 6px 6px;
  border-top: 1px solid var(--color-line);
  font-size: 0.85rem;
  line-height: 1.3;
  text-align: center;
}
.spare-part-number {
  font-weight: 600;
}
.spare-part-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
  color: var(--bs-secondary-color, #6c757d);
  overflow-wrap: break-word;
  hyphens: auto;
}

/* Long document titles should wrap instead of being cut off */
.document-listview .in {
  white-space: normal;
  word-break: break-word;
}

/* Article stock tiles (Lagerstand / Bestellt / Vorgemerkt) */
.stock-stat {
  padding: 10px 4px;
  border: 1px solid var(--color-line);
  border-radius: 8px;
}
.stock-stat .value {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--color-heading);
}
.stock-stat .value.text-danger {
  color: var(--color-danger) !important;
}
.stock-stat .label {
  font-size: 0.85rem;
  font-weight: 500;
}
.order-listview .badge {
  height: auto;
  font-size: 0.75rem;
}
.section-meta {
  padding: 6px 16px 0;
  font-size: 0.8rem;
  color: var(--color-light);
}

/* Article detail: price badges vertically centered next to the price,
   wrapping onto the next line when they don't fit */
.product-detail-header .detail-footer .price .current-price {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

/* Article detail on desktop: limit the width so blocks and tiles are not
   stretched over the whole screen */
@media (min-width: 992px) {
  .item-detail {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 16px 16px;
  }
  .item-detail .wide-block {
    border-left: 1px solid var(--color-line);
    border-right: 1px solid var(--color-line);
  }
}

/* Article list: number + name, prices and stock tiles (Lager / Bestellt /
   Vorgemerkt). On desktop one compact row per article with fixed columns
   (image | number + name | prices | stock), so values line up across rows */
.item-listview > li a.item {
  padding-top: 10px;
  padding-bottom: 10px;
}
.item-listview .item-prices {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 0 0;
}
.item-listview .item-stock {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  clear: both;
  margin-top: 8px;
  text-align: center;
}
.item-listview .item-stock > div:not(.list-meta) {
  padding: 4px 2px;
  border: 1px solid var(--color-line);
  border-radius: 8px;
}
.item-listview .item-stock .value {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-heading);
}
.item-listview .item-stock .value.text-danger {
  color: var(--color-danger) !important;
}
.item-listview .item-stock .label {
  font-size: 0.8rem;
  line-height: 1.3;
  color: var(--color-light);
}
.item-listview .item-stock .list-meta {
  grid-column: 1 / -1;
  margin-top: 0;
  text-align: left;
}
body.dark-mode-active .item-listview .item-stock > div:not(.list-meta) {
  border-color: var(--dark-mode-color-line);
}
body.dark-mode-active .item-listview .item-stock .value {
  color: #fff;
}
body.dark-mode-active .item-listview .item-stock .label {
  color: var(--dark-mode-color-light);
}
@media (min-width: 992px) {
  #search-results:has(.item-listview) {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 16px;
  }
  .item-listview .item-row {
    display: grid;
    grid-template-columns: 3.5rem minmax(0, 1fr) 20rem 19rem;
    column-gap: 1rem;
    align-items: center;
  }
  .item-listview .item-thumb {
    grid-column: 1;
    grid-row: 1;
    float: none !important;
    margin: 0 !important;
  }
  .item-listview .item-main {
    grid-column: 2;
    grid-row: 1;
  }
  .item-listview .item-prices {
    grid-column: 3;
    grid-row: 1;
    margin: 0;
  }
  .item-listview .item-stock {
    grid-column: 4;
    grid-row: 1;
    margin: 0;
  }
  .item-listview .item-stock .list-meta {
    text-align: center;
  }
}

/* Shared list item text styles (customer and article list): small number
   line, bold title, muted meta lines and status chips */
.list-number {
  font-size: 0.85rem;
  color: var(--color-light);
}
.list-number .badge {
  margin-left: 4px;
  vertical-align: 1px;
}
.list-title {
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-heading);
}
.list-text {
  font-size: 0.9rem;
  line-height: 1.35;
  color: var(--color-text);
}
.list-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.list-meta {
  margin-top: 4px;
  font-size: 0.8rem;
  line-height: 1.3;
  color: var(--color-light);
}
body.dark-mode-active .list-title {
  color: #fff;
}
body.dark-mode-active .list-text {
  color: var(--dark-mode-color-text);
}
body.dark-mode-active .list-number,
body.dark-mode-active .list-meta {
  color: var(--dark-mode-color-light);
}

.list-body {
  width: 100%;
}
.list-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.list-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border: 1px solid var(--color-line);
  border-radius: 400px;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--color-light);
}
.list-chip.chip-todo {
  border-color: var(--color-warning);
  background: rgba(254, 149, 0, 0.12);
  color: #c46f00;
}
.list-chip.chip-offer {
  border-color: var(--color-info);
  background: rgba(89, 43, 202, 0.1);
  color: var(--color-info);
}
body.dark-mode-active .list-chip {
  border-color: var(--dark-mode-color-line);
  color: var(--dark-mode-color-light);
}
body.dark-mode-active .list-chip.chip-todo {
  border-color: var(--color-warning);
  background: rgba(254, 149, 0, 0.15);
  color: #ffb547;
}
body.dark-mode-active .list-chip.chip-offer {
  border-color: #9b7be8;
  background: rgba(89, 43, 202, 0.25);
  color: #b9a1f2;
}

/* Customer list and detail: open reports (orange) and offers (purple) are
   highlighted with colored chips/tiles and a colored bar on the list item */
.customer-listview > li {
  border-left: 4px solid transparent;
}
.customer-listview > li.has-todos {
  border-left-color: var(--color-warning);
}
.customer-listview > li.has-offers {
  border-left-color: var(--color-info);
}
.customer-listview > li a.item {
  padding-top: 10px;
  padding-bottom: 10px;
  padding-left: 12px;
}
.customer-stat {
  display: block;
  height: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-line);
  border-radius: 8px;
  background: #fff;
  color: var(--color-light);
}
.customer-stat .bi {
  font-size: 1.25rem;
}
.customer-stat .value {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-heading);
}
a.customer-stat .value {
  font-size: 1.6rem;
}
.customer-stat .label {
  font-size: 0.85rem;
  font-weight: 500;
}
.customer-stat.stat-todo {
  border-color: var(--color-warning);
  background: rgba(254, 149, 0, 0.12);
  color: #c46f00;
}
.customer-stat.stat-offer {
  border-color: var(--color-info);
  background: rgba(89, 43, 202, 0.1);
  color: var(--color-info);
}
.customer-stat.stat-todo .value,
.customer-stat.stat-offer .value {
  color: inherit;
}
body.dark-mode-active .customer-stat {
  border-color: var(--dark-mode-color-line);
  background: var(--dark-mode-content-background);
  color: var(--dark-mode-color-light);
}
body.dark-mode-active .customer-stat .value {
  color: #fff;
}
body.dark-mode-active .customer-stat.stat-todo {
  border-color: var(--color-warning);
  background: rgba(254, 149, 0, 0.15);
  color: #ffb547;
}
body.dark-mode-active .customer-stat.stat-offer {
  border-color: #9b7be8;
  background: rgba(89, 43, 202, 0.25);
  color: #b9a1f2;
}
body.dark-mode-active .customer-stat.stat-todo .value,
body.dark-mode-active .customer-stat.stat-offer .value {
  color: inherit;
}
.customer-contact small {
  display: block;
  font-size: 0.8rem;
  line-height: 1.2;
  color: var(--color-light);
}
