﻿/* ---------------- Tools (Werkzeugverleih) ---------------- */
.table--tools .table__head,
.table--tools .table__row{
  grid-template-columns:
    minmax(260px, 4fr)   /* Werkzeug */
    minmax(90px, 1fr)    /* Seriennr. */
    minmax(120px, 1.6fr) /* Benutzer */
    minmax(90px, 0.9fr)  /* Status */
    minmax(120px, 1.2fr) /* Von */
    minmax(120px, 1.2fr) /* Bis */
    130px;               /* Aktion */
}

/* kleine Spalten nicht umbrechen */
.table--tools .table__row > div:nth-child(2),
.table--tools .table__row > div:nth-child(4),
.table--tools .table__row > div:nth-child(5),
.table--tools .table__row > div:nth-child(6){
  white-space: nowrap;
}

.table--tools .table__head > div:last-child,
.table--tools .table__row > div:last-child{
  justify-self: end;
}

.table--tools-admin .table__head,
.table--tools-admin .table__row{
  grid-template-columns:
    minmax(220px, 3.8fr) /* Name */
    minmax(110px, 1.3fr) /* Seriennr. */
    minmax(110px, .9fr)  /* Status */
    minmax(220px, 1.8fr);/* Aktion */
}

.table--tools-admin{
  overflow: visible;
}


.table--loans-admin .table__head,
.table--loans-admin .table__row{
  grid-template-columns:
    minmax(220px, 3.1fr)  /* Werkzeug */
    minmax(110px, 1.1fr)  /* User */
    minmax(145px, 1.25fr) /* Von */
    minmax(145px, 1.25fr) /* Bis */
    minmax(120px, 1.15fr) /* Notiz */
    minmax(80px, .8fr)    /* Status */
    minmax(170px, 1.15fr);/* Aktion */
}


.table--vacation-overview .table__head,
.table--vacation-overview .table__row{
  grid-template-columns:
    minmax(180px, 1.6fr)
    90px
    90px
    90px
    90px
    minmax(110px, 1fr);
}
.table--vacation-overview .table__row > div:nth-child(2),
.table--vacation-overview .table__row > div:nth-child(3),
.table--vacation-overview .table__row > div:nth-child(4),
.table--vacation-overview .table__row > div:nth-child(5),
.table--vacation-overview .table__row > div:nth-child(6){ white-space: nowrap; }


/* Admin Tools/Loans: kleine Spalten nicht umbrechen */
.table--tools-admin .table__row > div:nth-child(2),
.table--tools-admin .table__row > div:nth-child(3){
  white-space: nowrap;
}

.table--loans-admin .table__row > div:nth-child(3),
.table--loans-admin .table__row > div:nth-child(4),
.table--loans-admin .table__row > div:nth-child(6){
  white-space: nowrap;
}

.table--tools-admin .table__head > div:last-child,
.table--tools-admin .table__row > div:last-child,
.table--loans-admin .table__head > div:last-child,
.table--loans-admin .table__row > div:last-child{
  justify-self: end;
}

/* Notiz-Pill in Admin Tabellen: Text nicht unendlich breit */
.pill-note.pill-note-text{
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loan--done{ opacity: .65; }

@media (max-width: 760px) {
  .table--tools{ border: none; background: transparent; }
  .table--tools .table__body{ display:flex; flex-direction:column; gap: 10px; padding: 2px; }
  .table--tools .table__row{
    display:grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px;
    border: 1px solid rgba(226,232,240,.9);
    border-radius: 14px;
    background: rgba(255,255,255,.9);
  }
  .table--tools .table__row > div{ border-bottom: 1px dashed rgba(226,232,240,.9); padding-bottom: 8px; }
  .table--tools .table__row > div:last-child{ border-bottom: none; padding-bottom: 0; }
  .table--tools .table__row > div::before{ font-weight: 900; }
  .table--tools .table__row > div:nth-child(1)::before{ content: "Werkzeug"; }
  .table--tools .table__row > div:nth-child(2)::before{ content: "Seriennr."; }
  .table--tools .table__row > div:nth-child(3)::before{ content: "Benutzer"; }
  .table--tools .table__row > div:nth-child(4)::before{ content: "Status"; }
  .table--tools .table__row > div:nth-child(5)::before{ content: "Von"; }
  .table--tools .table__row > div:nth-child(6)::before{ content: "Bis"; }
  .table--tools .table__row > div:nth-child(7)::before{ content: "Notiz"; }
  .table--tools .table__row > div:nth-child(8)::before{ content: "Aktion"; }
}

/* Tools: "Meine Werkzeuge" auf iPhone sauber ausrichten */
@media (max-width: 520px){
  .tools-my .list__item{ flex-direction: column; align-items: stretch; }
  .tools-my .list__item .row.row-gap{ justify-content: flex-end; }

  /* Global .btn ist auf 520px oft 100% - fuer Tabellenaktionen lieber auto */
  .table--orders .btn,
  .table--tools .btn,
  .table--tools-admin .btn,
  .table--loans-admin .btn{ width: auto; }
}
/* iPhone / sehr schmale Displays */
@media (max-width: 520px){
  :root{ --tap: 48px; }

  /* Safe-Area (Notch/Home Indicator) + Platz fuer Actionbar */
  .container{
    padding-left: calc(14px + env(safe-area-inset-left));
    padding-right: calc(14px + env(safe-area-inset-right));
    padding-top: 14px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
  .topbar{
    padding-left: calc(12px + env(safe-area-inset-left));
    padding-right: calc(12px + env(safe-area-inset-right));
  }

  /* bessere Lesbarkeit */
  .h1{ font-size: 20px; }
  .h2{ font-size: 17px; }
  .h3{ font-size: 15px; }

  /* iOS Zoom vermeiden (Inputs >=16px) */
  .input, .select{ font-size: 16px; }

  /* iOS Safari: Date/Time sind manchmal breiter als ihr Container */
  input.input[type="date"],
  input.input[type="time"]{
    -webkit-appearance: none;
    appearance: none;
  }

  .card{ padding: 14px; }
  .grid{ gap: 12px; }

  /* Buttons: im Content duerfen sie voll breit, in der Actionbar steuert das Grid */
  .btn{ width: 100%; }
  .row.row-gap.row-wrap .btn,
  .row.row-gap.row-wrap .navlink{ width: auto; }
  .field{ min-width: 0; width: 100%; }

  /* -------- Header-Ãœbersicht: Monatsauswahl + SOLL/IST/Î” -------- */
  .card .row.row-between.row-wrap.mt-12{
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    align-items: stretch;
  }
  .card .row.row-between.row-wrap.mt-12 > .row.row-gap{
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: var(--tap) minmax(0, 1fr) var(--tap);
    gap: 10px;
    align-items: stretch;
  }
  .card .row.row-between.row-wrap.mt-12 > .row.row-gap > .btn{
    width: var(--tap);
    padding: 0;
    font-size: 20px;
    line-height: 1;
  }
  .card .row.row-between.row-wrap.mt-12 > .row.row-gap > .kpi{
    width: 100%;
    min-width: 0;
    text-align: center;
  }
  .card .row.row-between.row-wrap.mt-12 > .kpi{
    width: 100%;
    min-width: 0;
    padding: 12px 12px;
  }
  .card .row.row-between.row-wrap.mt-12 > .kpi .kpi__value{ font-size: 16px; }
}

.toolsFilters{
  align-items: end;
}

.toolsFilters .field{
  min-width: 0;
}

.toolsFilters--admin{
  margin-top: 12px;
  margin-bottom: 24px;
}

.cell-tool{
  display: grid;
  gap: 6px;
}

.toolHistory{
  margin-top: 4px;
}

.toolHistory summary{
  cursor: pointer;
  color: var(--gray);
  font-size: 12px;
  font-weight: 700;
  list-style: none;
}

.toolHistory summary::-webkit-details-marker{
  display: none;
}

.toolHistory__list{
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.toolHistory__item{
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid rgba(226,232,240,.95);
  border-radius: 10px;
  background: rgba(248,250,252,.92);
  font-size: 12px;
}

.toolHistory__line{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toolHistory--admin-inline{
  margin-top: 8px;
  position: relative;
  z-index: 1;
}

.toolHistory--admin-inline summary{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid rgba(191,219,254,.9);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(239,246,255,.98), rgba(248,250,252,.98));
  color: #1d4ed8;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.toolHistory--admin-inline[open] summary{
  border-color: rgba(59,130,246,.42);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
  background: #eff6ff;
}

.toolHistory__count{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(37,99,235,.12);
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 800;
}

.toolHistory__popover{
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: min(420px, calc(100vw - 72px));
  max-height: 340px;
  overflow: auto;
  padding: 10px;
  border: 1px solid rgba(226,232,240,.96);
  border-radius: 16px;
  background: rgba(255,255,255,.99);
  box-shadow: 0 18px 40px rgba(15,23,42,.16);
  z-index: 5;
}

.toolHistory--open-up .toolHistory__popover{
  top: auto;
  bottom: calc(100% + 10px);
}

.toolHistory--align-right .toolHistory__popover{
  left: auto;
  right: 0;
}

.toolHistory__item--admin{
  gap: 4px;
  background: rgba(248,250,252,.98);
}

.toolAdminHistoryInline__empty{
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.toolAdminNameCell{
  position: relative;
  display: grid;
  gap: 6px;
}

.table--tools-admin .table__row{
  position: relative;
  z-index: 0;
}

.table--tools-admin .table__row.table__row--history-open{
  z-index: 30;
}

#admToolFormWrap:empty{
  display: none;
}

#admToolFormWrap:empty + .divider{
  display: none;
}

#admToolFormWrap:not(:empty){
  position: relative;
  z-index: 1;
  margin-top: 28px;
}

.toolAdminHistoryGrid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.toolAdminHistoryCard{
  padding: 14px;
  border: 1px solid rgba(226,232,240,.95);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(248,250,252,.96));
  box-shadow: 0 10px 24px rgba(15,23,42,.06);
}

.toolAdminHistoryCard__head{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.toolAdminHistoryCard__head .h3{
  margin: 0;
}

.toolAdminHistoryTimeline{
  display: grid;
  gap: 10px;
}

.toolAdminHistoryTimeline__item{
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(241,245,249,.88);
  border: 1px solid rgba(226,232,240,.9);
}

.toolAdminHistoryTimeline__line{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

@media (max-width: 760px) {
  .toolsFilters{
    display: grid;
    grid-template-columns: 1fr;
  }

  .toolAdminHistoryGrid{
    grid-template-columns: 1fr;
  }

  .toolHistory__popover{
    width: min(340px, calc(100vw - 52px));
  }
}
