/* TF-08 Facturi: financial workspace and mobile-safe invoice composer. */

#invoices {
  --tf08-ink: #102b40;
  --tf08-muted: #65788b;
  --tf08-line: #d9e5ed;
  --tf08-teal: #087f8c;
  --tf08-teal-strong: #056470;
  --tf08-teal-soft: #e9f8f8;
  --tf08-surface: rgba(255, 255, 255, 0.97);
  --tf08-shadow: 0 18px 44px rgba(14, 53, 75, 0.08);
  padding-bottom: 32px;
}

#invoices .modulePageHeader {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background:
    radial-gradient(circle at 90% 50%, rgba(101, 226, 218, 0.16) 0 76px, transparent 77px),
    linear-gradient(115deg, #0b4f82 0%, #126ca2 56%, #298fc7 100%);
  box-shadow: 0 18px 42px rgba(15, 78, 138, 0.18);
}

#invoices .modulePageHeader::after {
  content: "";
  position: absolute;
  inset: auto -50px -90px auto;
  width: 235px;
  height: 235px;
  border: 30px solid rgba(255, 255, 255, 0.065);
  border-radius: 50%;
  pointer-events: none;
}

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

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

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

#invoices .businessKpiIcon {
  color: var(--tf08-teal-strong);
  background: linear-gradient(145deg, #f1ffff, #dff5f5);
  border-color: #c8e8e8;
}

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

#invoices .invoiceToolbar {
  display: grid !important;
  grid-template-columns: minmax(250px, 1.3fr) minmax(160px, 0.72fr) minmax(210px, 0.95fr) auto minmax(180px, 0.82fr) auto;
  align-items: end;
  gap: 10px;
  min-width: 0;
  padding: 14px;
  border-bottom: 1px solid var(--tf08-line);
  background: linear-gradient(180deg, #ffffff, #fbfdff);
}

#invoices .invoiceToolbar > * {
  min-width: 0;
}

#invoices #invoiceSearch,
#invoices #invoiceStatusFilter,
#invoices #invoiceClientFilter,
#invoices #refreshInvoicesBtn,
#invoices .invoiceToolbar select,
#invoices .invoiceToolbar .remoteSelect,
#invoices .invoiceToolbar .remoteSelectInput {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  box-sizing: border-box;
}

#invoices #invoiceSearch:focus,
#invoices #invoiceStatusFilter:focus,
#invoices .invoiceToolbar select:focus,
#invoices .invoiceToolbar .remoteSelectInput:focus {
  border-color: var(--tf08-teal);
  box-shadow: 0 0 0 3px rgba(8, 127, 140, 0.12);
  outline: none;
}

#invoices #refreshInvoicesBtn {
  min-width: 124px;
  justify-content: center;
  color: #075e68;
  background: linear-gradient(180deg, #eefcfc, #dff4f4);
  border-color: #c5e7e7;
}

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

#invoices .invoiceTable {
  min-width: 1030px;
}

#invoices .invoiceTable thead {
  color: #52677b;
  background: #f3f8fa;
}

#invoices .invoiceTable tbody tr:hover {
  background: #f3fbfb;
}

#invoices .businessTableState {
  min-height: 250px;
  color: var(--tf08-muted);
  background:
    radial-gradient(circle at 22% 55%, rgba(8, 127, 140, 0.07), transparent 30%),
    linear-gradient(180deg, #ffffff, #fbfdff);
}

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

#invoices .accountingNotice {
  border: 1px solid #c9e4e6;
  color: #315769;
  background:
    radial-gradient(circle at 96% 50%, rgba(8, 127, 140, 0.08), transparent 28%),
    linear-gradient(135deg, #f4fbfb, #eef8fa);
  box-shadow: 0 12px 30px rgba(8, 80, 92, 0.07);
}

#invoices .accountingNoticeIcon {
  color: var(--tf08-teal-strong);
  background: #ffffff;
  border-color: #c9e4e6;
}

#invoiceDialog {
  width: min(1280px, calc(100vw - 34px));
  max-width: none;
  max-height: min(860px, calc(100dvh - 32px));
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 30px 86px rgba(15, 43, 70, 0.32);
}

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

#invoices .invoiceDialog .dialogHeader {
  flex: 0 0 auto;
  border-bottom: 1px solid var(--tf08-line);
}

#invoices .invoiceDialogBody {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

#invoices .invoiceMetaSection,
#invoices .invoiceLinesSection,
#invoices .invoiceFinancialSection {
  min-width: 0;
}

#invoices .invoiceMetaSection .businessFormGrid {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 14px;
}

#invoices .invoiceMetaSection .businessFormGrid > label {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 6px;
  min-width: 0;
}

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

#invoices .invoiceMetaSection .dialogFullField {
  grid-column: span 2;
}

#invoices .invoiceLinesSection {
  border-top: 1px solid var(--tf08-line);
  border-bottom: 1px solid var(--tf08-line);
  background: #fbfdfe;
}

#invoices .invoiceLine {
  min-width: 0;
  border: 1px solid #dce7ed;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(15, 53, 75, 0.045);
}

#invoices .invoiceLineDescriptionWrap {
  min-width: 0;
}

#invoices .invoiceLine input,
#invoices .invoiceLine select,
#invoices .invoiceLine .remoteSelect,
#invoices .invoiceLine .remoteSelectInput {
  min-width: 0;
  box-sizing: border-box;
}

#invoices .invoiceTotals {
  margin-left: auto;
  border: 1px solid #c6e2e4;
  background: linear-gradient(145deg, #effafa, #e2f4f4);
}

#invoices .invoiceGrandTotal {
  color: #ffffff;
  background: linear-gradient(135deg, #075f6b, #0b7f8c);
}

#invoices .invoicePaymentComposer,
#invoices .invoiceCancelPanel {
  border-color: var(--tf08-line);
  background: #f8fbfc;
}

#invoices .invoiceDialogFooter {
  position: sticky;
  bottom: 0;
  z-index: 4;
  flex: 0 0 auto;
  border-top: 1px solid var(--tf08-line);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px);
}

#invoices .invoiceDialog .dialogPrimary {
  min-height: 44px;
  background: linear-gradient(135deg, var(--tf08-teal-strong), #0b8995);
  box-shadow: 0 10px 22px rgba(8, 127, 140, 0.22);
}

#invoices .invoiceDialog .dialogSecondary {
  min-height: 44px;
}

#invoices button:focus-visible,
#invoices input:focus-visible,
#invoices select:focus-visible,
#invoices textarea:focus-visible {
  outline: 3px solid rgba(8, 127, 140, 0.34);
  outline-offset: 2px;
}

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

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

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

  #invoices .invoiceMetaSection .businessFormGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

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

  #invoices .modulePageHeader,
  #invoices .invoiceKpis,
  #invoices .businessPanel,
  #invoices .accountingNotice {
    margin-left: 0;
    margin-right: 0;
  }

  #invoices .invoiceKpis,
  #invoices .invoiceToolbar {
    grid-template-columns: minmax(0, 1fr);
  }

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

  #invoices #refreshInvoicesBtn,
  #invoices .modulePrimaryAction {
    width: 100%;
    min-height: 46px;
    justify-content: center;
  }

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

  #invoiceDialog > form {
    width: 100%;
    height: 100%;
    max-height: 100dvh;
  }

  #invoices .invoiceMetaSection .businessFormGrid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 14px;
  }

  #invoices .invoiceMetaSection .dialogFullField {
    grid-column: auto;
  }

  #invoices .invoiceLineLabels {
    display: none;
  }

  #invoices .invoiceLine {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 10px;
    padding: 14px;
  }

  #invoices .invoiceLineDescriptionWrap {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 10px;
    width: 100%;
  }

  #invoices .invoiceLine input,
  #invoices .invoiceLine select,
  #invoices .invoiceLine .remoteSelect,
  #invoices .invoiceLine .remoteSelectInput,
  #invoices .invoiceLineTotal,
  #invoices .invoiceLineRemove {
    width: 100%;
    min-width: 0;
  }

  #invoices .invoiceLineTotal {
    padding: 10px 12px;
    border-radius: 10px;
    text-align: right;
    background: #f0f7f8;
  }

  #invoices .invoiceTotals {
    width: 100%;
    margin: 0;
  }

  #invoices .invoicePaymentForm,
  #invoices .invoiceFinancialMetrics {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
  }

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

  #invoices .invoiceDialogFooter > div {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    width: 100%;
  }

  #invoices .invoiceDialogFooter button,
  #invoices .invoicePaymentForm button {
    width: 100%;
  }
}

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