/* TF-07 Stocuri: inventory workspace and field-safe responsive dialogs. */

#inventory {
  --tf07-ink: #14283d;
  --tf07-muted: #66788a;
  --tf07-line: #dce5ee;
  --tf07-blue: #1769b0;
  --tf07-amber: #c67408;
  --tf07-amber-soft: #fff6df;
  --tf07-surface: rgba(255, 255, 255, 0.97);
  --tf07-shadow: 0 18px 44px rgba(20, 52, 80, 0.08);
  padding-bottom: 32px;
}

#inventory .modulePageHeader {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background:
    radial-gradient(circle at 89% 50%, rgba(255, 196, 83, 0.18) 0 72px, transparent 73px),
    linear-gradient(115deg, #0c4f86 0%, #1769b0 58%, #358bdc 100%);
  box-shadow: 0 18px 42px rgba(15, 78, 138, 0.18);
}

#inventory .modulePageHeader::after {
  content: "";
  position: absolute;
  inset: -75px -42px auto auto;
  width: 220px;
  height: 220px;
  border: 28px solid rgba(255, 255, 255, 0.065);
  border-radius: 50%;
  pointer-events: none;
}

#inventory .modulePageHeader > * {
  position: relative;
  z-index: 1;
}

#inventory .businessKpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

#inventory .businessKpis > * {
  min-width: 0;
  border: 1px solid var(--tf07-line);
  background:
    radial-gradient(circle at 100% 100%, var(--tf07-amber-soft) 0 48px, transparent 49px),
    var(--tf07-surface);
  box-shadow: var(--tf07-shadow);
}

#inventory .businessKpiIcon {
  color: #a65e03;
  background: linear-gradient(145deg, #fff9eb, #ffedbd);
  border-color: #f2ddb1;
}

#inventory .businessPanel {
  min-width: 0;
  min-height: 390px;
  overflow: hidden;
  border: 1px solid var(--tf07-line);
  background: var(--tf07-surface);
  box-shadow: var(--tf07-shadow);
}

#inventory .businessToolbar {
  display: grid !important;
  grid-template-columns: minmax(260px, 1.35fr) minmax(190px, 0.8fr) minmax(190px, 0.8fr) auto;
  align-items: end;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border-bottom: 1px solid var(--tf07-line);
  background: linear-gradient(180deg, #ffffff, #fbfdff);
}

#inventory .businessToolbar > * {
  min-width: 0;
}

#inventory #inventorySearch,
#inventory #inventoryStockFilter,
#inventory #inventoryVatFilter,
#inventory #refreshInventoryBtn {
  width: 100%;
  min-width: 0;
  min-height: 44px;
}

#inventory #inventorySearch,
#inventory #inventoryStockFilter,
#inventory #inventoryVatFilter {
  border-color: #cad7e4;
  background-color: #fbfdff;
}

#inventory #inventorySearch:focus,
#inventory #inventoryStockFilter:focus,
#inventory #inventoryVatFilter:focus {
  border-color: var(--tf07-blue);
  box-shadow: 0 0 0 3px rgba(23, 105, 176, 0.12);
  outline: none;
}

#inventory #refreshInventoryBtn {
  min-width: 126px;
  justify-content: center;
  color: #7b4602;
  background: linear-gradient(180deg, #fff7e6, #ffedc6);
  border-color: #f0d6a3;
}

#inventory .businessTableWrap {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

#inventory .inventoryTable {
  min-width: 1040px;
}

#inventory .inventoryTable thead {
  color: #53677b;
  background: #f4f8fc;
}

#inventory .inventoryTable tbody tr:hover {
  background: #fffaf0;
}

#inventory .businessTableState {
  min-height: 230px;
  color: var(--tf07-muted);
  background:
    radial-gradient(circle at 20% 50%, rgba(229, 147, 28, 0.07), transparent 28%),
    linear-gradient(180deg, #ffffff, #fbfdff);
}

#inventory .businessTableFooter {
  border-top: 1px solid var(--tf07-line);
  background: #fbfdff;
}

#inventoryItemDialog,
#stockMovementDialog {
  width: min(1120px, calc(100vw - 34px));
  max-width: none;
  max-height: min(820px, calc(100dvh - 32px));
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 28px 80px rgba(15, 43, 70, 0.3);
}

#inventoryItemDialog > form,
#stockMovementDialog > form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: inherit;
  overflow: hidden;
}

#inventory .businessDialog .dialogHeader {
  flex: 0 0 auto;
  border-bottom: 1px solid var(--tf07-line);
}

#inventory .businessDialog .businessFormGrid {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

#inventory .businessDialog .businessFormGrid > label {
  min-width: 0;
}

#inventory .businessDialog .businessFormGrid > label:not(.businessCheckbox) {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 6px;
}

#inventory .businessDialog .businessFormGrid input:not([type="hidden"]),
#inventory .businessDialog .businessFormGrid select:not(.remoteSelectNative),
#inventory .businessDialog .businessFormGrid textarea,
#inventory .businessDialog .businessFormGrid .remoteSelect,
#inventory .businessDialog .businessFormGrid .remoteSelectInput {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

#inventory .businessDialog .dialogFullField {
  grid-column: 1 / -1;
}

#inventory .businessHint {
  flex: 0 0 auto;
  margin: 0;
  border-color: #edd8aa;
  color: #7b5215;
  background: #fff8e8;
}

#inventory .businessDialog .dialogFooter {
  position: sticky;
  bottom: 0;
  z-index: 3;
  flex: 0 0 auto;
  border-top: 1px solid var(--tf07-line);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px);
}

#inventory .businessDialog .dialogPrimary {
  min-height: 44px;
  background: linear-gradient(135deg, #a95f03, #d68613);
  box-shadow: 0 10px 22px rgba(198, 116, 8, 0.22);
}

#inventory .businessDialog .dialogSecondary {
  min-height: 44px;
}

#inventory button:focus-visible,
#inventory input:focus-visible,
#inventory select:focus-visible,
#inventory textarea:focus-visible {
  outline: 3px solid rgba(23, 105, 176, 0.34);
  outline-offset: 2px;
}

@media (max-width: 1120px) {
  #inventory .businessKpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #inventory .businessToolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #inventory .businessSearch {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  #inventory {
    padding-bottom: 20px;
  }

  #inventory .modulePageHeader,
  #inventory .businessKpis,
  #inventory .businessPanel {
    margin-left: 0;
    margin-right: 0;
  }

  #inventory .businessHeaderActions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  #inventory .businessHeaderActions > button,
  #inventory .modulePrimaryAction,
  #inventory .moduleSecondaryAction {
    width: 100%;
    min-height: 46px;
    justify-content: center;
  }

  #inventory .businessKpis,
  #inventory .businessToolbar {
    grid-template-columns: minmax(0, 1fr);
  }

  #inventory .businessSearch {
    grid-column: auto;
  }

  #inventory #refreshInventoryBtn {
    width: 100%;
  }

  #inventoryItemDialog,
  #stockMovementDialog {
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  #inventoryItemDialog > form,
  #stockMovementDialog > form {
    width: 100%;
    height: 100%;
    max-height: 100dvh;
  }

  #inventory .businessDialog .businessFormGrid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    align-content: start;
    gap: 14px;
  }

  #inventory .businessDialog .businessFormGrid > label:not(.businessCheckbox) {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 6px;
    width: 100%;
  }

  #inventory .businessDialog .businessCheckbox {
    display: flex !important;
    width: 100%;
  }

  #inventory .businessDialog .dialogFooter {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }

  #inventory .businessDialog .dialogPrimary,
  #inventory .businessDialog .dialogSecondary {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  #inventory *,
  #inventory *::before,
  #inventory *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
