/* TradeInvoice V9.4.14 — usability and accessibility refinements.
   Shared app-wide layer. Kept separate from invoice print/layout rules. */

:root {
  --ux-focus: #1d70c9;
  --ux-control-height: 44px;
  --ux-radius: 12px;
  --ux-surface: #fffefa;
  --ux-soft: #f1f6f0;
}

/* Comfortable reading width and consistent page rhythm. */
body[data-authenticated="1"] .app-page-container {
  width: 100% !important;
  max-width: 1840px !important;
  margin-inline: auto !important;
  padding: clamp(16px, 2vw, 30px) clamp(14px, 2.2vw, 34px) 42px !important;
}
.app-page-container > h1,
.app-page-container > h2 {
  margin: 3px 0 8px !important;
  line-height: 1.2 !important;
}
.app-page-container > p:first-of-type {
  color: #66766c;
}
.app-page-container .text-secondary,
.app-page-container .text-muted {
  line-height: 1.5;
}
.app-page-container .card,
.app-page-container .panel-card {
  min-width: 0;
}

/* Navigation and app header. */
.global-header {
  gap: clamp(8px, 1.2vw, 18px) !important;
}
.sidebar-nav .nav-link {
  min-height: 46px !important;
  padding-block: 9px !important;
}
.sidebar-section {
  margin-top: 22px !important;
  margin-bottom: 9px !important;
}
.sidebar-nav .nav-link:focus-visible,
.global-header a:focus-visible,
.global-header button:focus-visible,
.header-user-dropdown a:focus-visible {
  outline: 3px solid #f2b75f !important;
  outline-offset: 2px !important;
}
.admin-support-banner {
  position: relative;
  z-index: 1101;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 9px clamp(14px, 2vw, 28px);
  border-bottom: 1px solid #efd59a;
  background: #fff4d9;
  color: #68460a;
  font-size: 13px;
}
.admin-support-banner form { margin: 0; }

/* Clear, consistent interactive controls. */
.form-label {
  display: inline-block;
  margin-bottom: 6px !important;
  color: #405348 !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  line-height: 1.35;
}
.form-control:not(.form-control-sm):not([type="checkbox"]):not([type="radio"]),
.form-select:not(.form-select-sm) {
  min-height: var(--ux-control-height) !important;
  padding: 9px 12px !important;
  border: 1px solid #d5ded5 !important;
  border-radius: 10px !important;
  background-color: #fff !important;
  color: #23352c !important;
  font-size: 14px !important;
  line-height: 1.4 !important;
  box-shadow: inset 0 1px 1px rgba(20, 45, 31, .025);
}
textarea.form-control:not(.form-control-sm) {
  min-height: 104px !important;
  resize: vertical;
}
.form-control::placeholder,
.form-select:invalid {
  color: #89968e !important;
  opacity: 1;
}
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: #4f9b78 !important;
  outline: 0 !important;
  box-shadow: 0 0 0 3px rgba(42, 128, 86, .16) !important;
}
.form-text,
.form-hint,
.field-hint {
  display: block;
  margin-top: 5px;
  color: #728078 !important;
  font-size: 12px !important;
  line-height: 1.45;
}
.input-group-text {
  border-color: #d5ded5 !important;
  background: #f1f5f0 !important;
  color: #4d6054 !important;
  font-weight: 650;
}
.form-check {
  min-height: 1.5rem;
  padding-top: 2px;
  padding-bottom: 2px;
}
.form-check-input {
  width: 1.1rem;
  height: 1.1rem;
  margin-top: .17rem;
  cursor: pointer;
}
.form-check-label {
  padding-left: 3px;
  color: #425349;
  line-height: 1.4;
  cursor: pointer;
}
input[type="file"].form-control {
  min-height: auto !important;
  padding: 7px 9px !important;
}
input[type="date"],
input[type="datetime-local"],
input[type="time"] {
  min-height: var(--ux-control-height) !important;
}
.was-validated .form-control:invalid,
.form-control.is-invalid,
.form-select.is-invalid {
  border-color: #c84d43 !important;
  box-shadow: 0 0 0 3px rgba(200, 77, 67, .10) !important;
}
.invalid-feedback,
.valid-feedback {
  font-size: 12px;
  line-height: 1.45;
}

/* Buttons are easier to tap; keep compact actions compact. */
.btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: normal;
  line-height: 1.25;
}
.btn-sm {
  min-height: 34px;
  padding: 6px 10px !important;
  font-size: 12px !important;
}
.btn:focus-visible,
button:focus-visible,
a.btn:focus-visible,
input[type="submit"]:focus-visible {
  outline: 3px solid rgba(29, 112, 201, .8) !important;
  outline-offset: 2px !important;
  box-shadow: none !important;
}
.btn:disabled,
button:disabled {
  opacity: .58 !important;
  cursor: not-allowed !important;
  transform: none !important;
}
.btn-group,
.d-flex.gap-2,
.d-flex.flex-wrap.gap-2 {
  min-width: 0;
}
.btn-group > .btn {
  white-space: nowrap;
}

/* Better cards, sections and alerts. */
.card,
.panel-card {
  overflow-wrap: anywhere;
}
.card-header {
  padding: 13px 17px !important;
  font-weight: 750;
}
.card-body {
  min-width: 0;
}
.alert {
  padding: 12px 15px !important;
  line-height: 1.5;
  border: 1px solid transparent !important;
}
.alert-success { border-color: #c7e4d0 !important; }
.alert-danger { border-color: #f0c8c5 !important; }
.alert-warning { border-color: #eddbac !important; }
.alert-info { border-color: #c8dfe8 !important; }
hr {
  border-color: #e3e9e2 !important;
  opacity: 1;
}

/* Tables remain readable and scroll inside their own container on narrow screens. */
.table-responsive {
  max-width: 100%;
  overflow-x: auto !important;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
.table {
  color: #2c3b32;
}
.table thead th {
  vertical-align: middle !important;
}
.table tbody td {
  line-height: 1.45;
}
.table tbody tr:last-child td {
  border-bottom-color: transparent;
}
.table a:not(.btn) {
  font-weight: 650;
}
.table .btn {
  margin: 1px 0;
}
.table tfoot th,
.table tfoot td {
  background: #f5f8f3;
  font-weight: 750;
}

/* Menus and overlays. */
.dropdown-menu,
.header-user-dropdown {
  border: 1px solid #e0e7df !important;
  border-radius: 13px !important;
  box-shadow: 0 16px 42px rgba(20, 46, 32, .16) !important;
}
.dropdown-item {
  min-height: 40px;
  display: flex;
  align-items: center;
}
.modal-content {
  border: 1px solid #e3e9e1 !important;
  border-radius: 16px !important;
  box-shadow: 0 18px 60px rgba(20, 46, 32, .18) !important;
}
.modal-header,
.modal-footer {
  border-color: #e8ece6 !important;
}

/* More discoverable keyboard navigation. */
.skip-to-content {
  position: fixed;
  z-index: 2000;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  transform: translateY(-150%);
  border-radius: 8px;
  background: #fff;
  color: #123c2d;
  box-shadow: 0 6px 20px rgba(0,0,0,.18);
  font-weight: 750;
}
.skip-to-content:focus {
  transform: translateY(0);
  outline: 3px solid #f2b75f;
}

/* Dashboard analytics: protect chart cards from flex/grid overflow. */
.top-products-row > [class*="col-"] {
  display: flex;
  min-width: 0;
}
.top-products-row .top-products-panel {
  width: 100%;
  min-width: 0;
}
.top-products-panel .tp-chart-layout {
  min-width: 0;
}
.top-products-panel .tp-legend-item {
  min-width: 0;
}
.dashboard-metrics > [class*="col-"] {
  min-width: 0;
}

/* Public login and registration screens. */
.public-main .app-page-container {
  max-width: 980px !important;
}
.public-main .auth-card,
.public-main .card.auth-card {
  width: 100%;
  max-width: 680px;
  margin-inline: auto;
  padding: clamp(20px, 3vw, 34px) !important;
  border-radius: 18px !important;
}
.public-main .auth-card h1,
.public-main .auth-card h2 {
  margin-bottom: 10px;
}
.public-main .auth-card > p {
  line-height: 1.55;
}
.public-main .auth-card .btn[type="submit"] {
  min-height: 48px;
  font-size: 15px;
}

/* Mobile-first refinements. */
@media (max-width: 900px) {
  body[data-authenticated="1"] .app-page-container {
    padding: 16px 14px 32px !important;
  }
  .admin-support-banner {
    padding: 8px 12px;
    font-size: 12px;
  }
  .admin-support-banner .btn {
    min-height: 34px;
  }
  .app-sidebar {
    padding-top: 13px !important;
  }
  .sidebar-nav .nav-link {
    min-height: 46px !important;
  }
  .form-control:not(.form-control-sm):not([type="checkbox"]):not([type="radio"]),
  .form-select:not(.form-select-sm) {
    min-height: 44px !important;
    font-size: 16px !important; /* prevent unwanted browser zoom on iOS */
  }
  textarea.form-control:not(.form-control-sm) {
    min-height: 110px !important;
  }
  .btn:not(.btn-sm) {
    min-height: 44px;
  }
  .card,
  .panel-card {
    border-radius: 14px !important;
  }
  .table-responsive {
    margin-bottom: 2px;
  }
  .table td,
  .table th {
    padding: 10px 11px !important;
  }
  .top-products-row {
    row-gap: 14px !important;
  }
}
@media (max-width: 575px) {
  body[data-authenticated="1"] .app-page-container {
    padding: 13px 11px 28px !important;
  }
  .public-main .app-page-container {
    padding: 18px 12px 28px !important;
  }
  .public-main .auth-card,
  .public-main .card.auth-card {
    padding: 20px 16px !important;
    border-radius: 15px !important;
  }
  .app-page-container > h1,
  .app-page-container > h2 {
    font-size: 1.35rem !important;
  }
  .app-page-container .d-flex.flex-wrap.justify-content-between {
    align-items: flex-start !important;
  }
  .top-products-panel .panel-heading {
    align-items: flex-start;
  }
  .top-products-panel .panel-heading select {
    min-width: 0;
  }
  .table-responsive {
    border-radius: 9px !important;
  }
  .admin-support-banner {
    align-items: flex-start;
  }
  .admin-support-banner strong {
    flex: 1 1 100%;
  }
}

/* Reduce motion for users who request it in their operating system. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* V9.4.14 accessibility finishing touches. */
#mainContent { scroll-margin-top: 82px; }
.skip-to-content:focus { z-index: 3000; }
.table-responsive {
  scrollbar-width: thin;
  scrollbar-color: #9bb4a1 #edf2ec;
}
.table-responsive::-webkit-scrollbar { height: 8px; }
.table-responsive::-webkit-scrollbar-track { background: #edf2ec; border-radius: 8px; }
.table-responsive::-webkit-scrollbar-thumb { background: #9bb4a1; border-radius: 8px; }
@media (hover: none) {
  .sidebar-nav .nav-link:hover,
  .btn:hover { transform: none !important; }
}
