/* TrustMart shared UI layer
   Loaded after page-level styles so legacy screens gain one coherent,
   responsive and accessible visual system without changing their routes. */

:root {
  --gold: #c99a2e;
  --gold-strong: #a97912;
  --gold-pale: #fff8e6;
  --gold-light: #f1d994;
  --ink: #171b26;
  --ink2: #343a48;
  --ink3: #626b7a;
  --ink4: #8a93a2;
  --cream: #f6f7f9;
  --cream2: #eef0f4;
  --cream3: #dde1e8;
  --green: #167451;
  --green-bg: #e8f7f0;
  --red: #b43c35;
  --red-bg: #fff0ee;
  --blue: #2864a8;
  --blue-bg: #edf5ff;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --sidebar: #171b26;
  --sidebar-soft: #222837;
  --ring: rgba(201, 154, 46, 0.28);
  --r-sm: 9px;
  --r: 14px;
  --r-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(20, 26, 38, 0.04), 0 5px 18px rgba(20, 26, 38, 0.05);
  --shadow: 0 18px 48px rgba(20, 26, 38, 0.09);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

html {
  min-width: 280px;
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
[role="button"],
[role="tab"] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible,
[role="tab"]:focus-visible,
[tabindex="0"]:focus-visible {
  outline: 3px solid var(--ring) !important;
  outline-offset: 2px;
}

::selection {
  background: var(--gold-light);
  color: var(--ink);
}

.tm-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.tm-skip-link {
  position: fixed;
  top: 10px;
  left: 12px;
  z-index: 1000;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: #fff;
  text-decoration: none;
  box-shadow: var(--shadow);
  transform: translateY(-160%);
  transition: transform .2s var(--ease);
}

.tm-skip-link:focus {
  transform: translateY(0);
}

/* Application shell */
.shell {
  height: 100dvh;
  min-height: 560px;
  background: var(--cream);
}

.sidebar {
  width: 252px;
  padding: 24px 14px 18px;
  background:
    radial-gradient(circle at 20% 0%, rgba(201, 154, 46, .13), transparent 30%),
    linear-gradient(180deg, var(--sidebar) 0%, #111520 100%);
  border-right: 1px solid rgba(255, 255, 255, .06);
  box-shadow: 10px 0 32px rgba(17, 21, 32, .08);
  z-index: 40;
}

.logo-text {
  padding: 2px 10px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, .09);
  font-size: 25px;
  letter-spacing: -.35px;
}

.logo-text::after {
  content: 'UTHM Marketplace';
  display: block;
  margin-top: 3px;
  color: rgba(255, 255, 255, .42);
  font-family: 'DM Sans', sans-serif;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.35px;
  text-transform: uppercase;
}

.nav-section {
  padding: 22px 10px 8px;
  color: rgba(255, 255, 255, .43);
  font-size: 10px;
  font-weight: 600;
}

.nav-item {
  min-height: 43px;
  margin: 2px 0;
  padding: 10px 12px;
  border: 0 !important;
  border-radius: 10px;
  color: rgba(255, 255, 255, .67);
  font-size: 13px;
  font-weight: 500;
  transition: color .18s ease, background .18s ease, transform .18s ease;
}

.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, .075);
  transform: translateX(2px);
}

.nav-item.active,
.nav-item[aria-current="page"],
.nav-item[aria-selected="true"] {
  color: #fff;
  background: linear-gradient(135deg, rgba(201, 154, 46, .23), rgba(201, 154, 46, .11));
  box-shadow: inset 3px 0 0 var(--gold);
}

.nav-item svg {
  width: 17px;
  height: 17px;
  opacity: .75;
}

.nav-item.active svg {
  opacity: 1;
  stroke: var(--gold-light) !important;
}

.sidebar-footer {
  margin: auto -2px 0;
  padding: 17px 12px 0;
  border-top: 1px solid rgba(255, 255, 255, .09);
}

.sidebar-footer a {
  border-radius: 8px;
  transition: color .18s ease, background .18s ease;
}

.sidebar-footer a:hover {
  color: #fff !important;
}

.avatar {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28);
}

.main {
  min-width: 0;
  background:
    radial-gradient(circle at 95% -10%, rgba(201, 154, 46, .09), transparent 27%),
    var(--cream);
  scrollbar-gutter: stable;
}

.topbar {
  height: 72px;
  padding: 0 clamp(20px, 3vw, 36px);
  border-bottom: 1px solid rgba(221, 225, 232, .86);
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 1px 0 rgba(20, 26, 38, .02);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.topbar > :first-child:not(.tm-menu-toggle) {
  font-size: 17px !important;
}

.content {
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
  padding: clamp(22px, 3vw, 36px);
}

.tm-page-profile .content {
  max-width: 840px;
  margin-left: 0;
}

/* Surfaces, metrics and content groups */
.card-box,
.stat-card,
.tbl-wrap,
.prod-card,
.dispute-card {
  border-color: rgba(221, 225, 232, .9);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}

.card-box {
  border-radius: var(--r);
}

.stat-card {
  min-height: 126px;
  padding: 20px;
  border-radius: var(--r);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: #d0d5de;
  box-shadow: 0 12px 28px rgba(20, 26, 38, .08);
}

.stat-card::before {
  height: 4px;
}

.stats-grid {
  gap: 16px;
  margin-bottom: 30px;
}

.stat-label {
  margin-bottom: 10px;
  color: var(--ink3);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .75px;
}

.stat-val {
  font-size: clamp(25px, 2.5vw, 31px);
  letter-spacing: -.8px;
}

.stat-sub {
  margin-top: 7px;
  color: var(--ink3);
  font-size: 11.5px;
}

.section-hd {
  gap: 12px;
  margin-bottom: 17px;
}

.section-title,
.card-title {
  color: var(--ink);
  font-weight: 650;
  letter-spacing: -.15px;
}

.empty-state {
  border: 1px dashed var(--cream3);
  border-radius: var(--r);
  background: rgba(255, 255, 255, .48);
}

/* Tables */
.tbl-wrap {
  position: relative;
  overflow-x: auto !important;
  overflow-y: hidden;
  border-radius: var(--r);
  scrollbar-width: thin;
  scrollbar-color: var(--cream3) transparent;
}

.tbl {
  min-width: 720px;
}

.tbl th {
  padding: 12px 16px;
  background: #f6f7f9;
  color: var(--ink3);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .65px;
  white-space: nowrap;
}

.tbl td {
  padding: 14px 16px;
  border-color: var(--cream2);
  vertical-align: middle;
}

.tbl tbody tr {
  transition: background .15s ease;
}

.tbl tr:hover td {
  background: #fafbfc;
}

/* Controls */
.btn,
.btn-submit,
.filter-btn,
.page-btn {
  min-height: 38px;
  border-radius: var(--r-sm);
  font-weight: 600;
  transition: transform .16s ease, box-shadow .16s ease, color .16s ease, background .16s ease, border-color .16s ease;
}

.btn:hover:not(:disabled),
.btn-submit:hover:not(:disabled),
.page-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:active:not(:disabled),
.btn-submit:active:not(:disabled),
.page-btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary {
  border-color: var(--gold);
  background: linear-gradient(135deg, #d4a83f, #c39123);
  color: #171b26;
  box-shadow: 0 6px 16px rgba(169, 121, 18, .16);
}

.btn-primary:hover:not(:disabled) {
  border-color: var(--gold-strong);
  background: linear-gradient(135deg, #ddb54e, #c89525);
  color: #171b26;
  box-shadow: 0 9px 20px rgba(169, 121, 18, .22);
}

.btn-danger:hover:not(:disabled) {
  background: var(--red);
  color: #fff;
}

.btn-success:hover:not(:disabled) {
  background: var(--green);
  color: #fff;
}

.btn:disabled,
.btn-submit:disabled,
.page-btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.filter-btn {
  min-height: 36px;
  padding: 7px 13px;
  background: #fff;
  color: var(--ink3);
}

.filter-btn:hover,
.filter-btn.active,
.filter-btn[aria-pressed="true"] {
  border-color: rgba(201, 154, 46, .62);
  background: var(--gold-pale);
  color: var(--ink);
}

.form-label {
  color: var(--ink2);
  font-weight: 600;
}

.form-input,
.search-input,
.search-box,
textarea.inp {
  border-color: var(--cream3);
  border-radius: var(--r-sm);
  background: #fff;
  color: var(--ink);
  transition: border-color .17s ease, box-shadow .17s ease, background .17s ease;
}

.form-input {
  min-height: 43px;
}

.form-input:focus,
.search-input:focus,
.search-box:focus-within,
textarea.inp:focus {
  border-color: var(--gold) !important;
  box-shadow: 0 0 0 4px var(--ring) !important;
  outline: 0;
}

.form-input:disabled {
  border-color: var(--cream2);
  background: #f3f4f6;
}

.tm-password-wrap {
  position: relative;
}

.tm-password-wrap .form-input {
  padding-right: 70px;
}

.tm-password-toggle {
  position: absolute;
  top: 50%;
  right: 7px;
  min-width: 54px;
  min-height: 32px;
  padding: 4px 7px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink3);
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
}

.tm-password-toggle:hover {
  background: var(--cream2);
  color: var(--ink);
}

.badge,
.trust-pill,
.badge-ptu {
  border: 1px solid transparent;
  font-weight: 650;
}

.badge-green { border-color: rgba(22, 116, 81, .12); }
.badge-red { border-color: rgba(180, 60, 53, .12); }
.badge-blue { border-color: rgba(40, 100, 168, .12); }
.badge-gold { border-color: rgba(169, 121, 18, .13); }

/* Product cards and detail */
.prod-grid {
  gap: 18px;
}

.prod-card {
  overflow: hidden;
  border-radius: var(--r);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s ease;
}

.prod-card:hover {
  transform: translateY(-3px);
  border-color: rgba(201, 154, 46, .55);
  box-shadow: 0 14px 32px rgba(20, 26, 38, .10);
}

.prod-img {
  min-height: 140px;
  background: linear-gradient(145deg, #f7f8fa, #ebedf1);
}

.prod-img img {
  transition: transform .35s var(--ease);
}

.prod-card:hover .prod-img img {
  transform: scale(1.035);
}

.product-detail-card {
  border-color: rgba(221, 225, 232, .9) !important;
  border-radius: var(--r-lg) !important;
  background: #fff;
  box-shadow: var(--shadow);
}

/* Dialogs and notifications */
.modal-bg,
#forgot-modal {
  padding: 18px;
  background: rgba(17, 21, 32, .62) !important;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.modal,
#forgot-modal > div {
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: var(--r-lg) !important;
  box-shadow: 0 28px 80px rgba(17, 21, 32, .24);
  animation: tm-dialog-in .2s var(--ease);
}

@keyframes tm-dialog-in {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.toast {
  left: auto;
  right: 24px;
  bottom: 24px;
  min-width: min(320px, calc(100vw - 32px));
  padding: 13px 16px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(17, 21, 32, .22);
}

.alert {
  border-radius: 10px;
  line-height: 1.55;
}

.tm-nav-backdrop {
  display: none;
}

.tm-menu-toggle {
  display: none;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--cream3);
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.tm-menu-toggle svg {
  width: 20px;
  height: 20px;
}

.tm-offline-banner {
  position: fixed;
  top: 12px;
  left: 50%;
  z-index: 500;
  display: none;
  padding: 9px 14px;
  transform: translateX(-50%);
  border: 1px solid rgba(180, 60, 53, .25);
  border-radius: 999px;
  background: #fff;
  color: var(--red);
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 650;
}

.tm-offline .tm-offline-banner {
  display: block;
}

/* Public authentication screen */
.login-left {
  background:
    radial-gradient(circle at 23% 52%, rgba(201, 154, 46, .2), transparent 30%),
    radial-gradient(circle at 100% 0%, rgba(56, 101, 157, .15), transparent 35%),
    linear-gradient(145deg, #171b26, #111520);
}

.login-left::after {
  content: '';
  position: absolute;
  right: -130px;
  bottom: -180px;
  width: 430px;
  height: 430px;
  border: 1px solid rgba(255, 255, 255, .05);
  border-radius: 50%;
  box-shadow: 0 0 0 70px rgba(255, 255, 255, .018), 0 0 0 140px rgba(255, 255, 255, .012);
}

.login-left > * {
  z-index: 1;
}

.login-right {
  width: min(470px, 42vw);
  padding: clamp(42px, 5vw, 68px);
  box-shadow: -18px 0 50px rgba(17, 21, 32, .08);
}

.logo {
  font-size: clamp(42px, 5vw, 60px);
  letter-spacing: -1.3px;
}

.tagline {
  color: rgba(255, 255, 255, .64);
  font-size: 15px;
}

.feature {
  max-width: 430px;
  padding: 12px;
  margin: 0 0 8px -12px;
  border-radius: 12px;
  transition: background .2s ease;
}

.feature:hover {
  background: rgba(255, 255, 255, .045);
}

.feat-icon {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(201, 154, 46, .18);
  border-radius: 11px;
}

.feat-title { font-size: 13.5px; }
.feat-text { color: rgba(255, 255, 255, .58); }

.panel-title {
  font-size: 27px;
  font-weight: 650;
  letter-spacing: -.7px;
}

.tabs {
  padding: 4px;
  border: 1px solid var(--cream3);
  border-radius: 11px;
}

.tab {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.tab.active {
  box-shadow: var(--shadow-sm);
}

body > .card {
  border: 1px solid var(--cream3);
  border-radius: var(--r-lg) !important;
  box-shadow: var(--shadow) !important;
}

/* Mobile and tablet */
@media (max-width: 1100px) {
  .sidebar { width: 230px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .three-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  body.tm-nav-open { overflow: hidden; }

  .shell {
    height: 100dvh;
    min-height: 0;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    display: flex !important;
    width: min(290px, 86vw);
    height: 100dvh;
    padding-top: 22px;
    transform: translateX(-104%);
    visibility: hidden;
    box-shadow: 24px 0 70px rgba(17, 21, 32, .28);
    transition: transform .25s var(--ease), visibility .25s;
  }

  .sidebar.tm-open {
    transform: translateX(0);
    visibility: visible;
  }

  .tm-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    display: block;
    border: 0;
    background: rgba(17, 21, 32, .52);
    opacity: 0;
    visibility: hidden;
    cursor: pointer;
    backdrop-filter: blur(3px);
    transition: opacity .22s ease, visibility .22s;
  }

  .tm-nav-backdrop.tm-open {
    opacity: 1;
    visibility: visible;
  }

  .tm-menu-toggle {
    display: inline-flex;
  }

  .main {
    width: 100%;
  }

  .topbar {
    height: 64px;
    padding: 0 16px;
    gap: 12px;
  }

  .topbar > :last-child {
    overflow: hidden;
    max-width: 42vw;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* The buyer and seller consoles put a notification pill, the trust chip and
     the identity line in the same right-hand cluster as the page title, and
     they do not fit in 42vw: the badge and the score came out cut mid-word.
     Those consoles may therefore grow to a second row, which truncates nothing
     and hides nothing. Scoped to .console-topbar on purpose — on the public
     product page the same cap is what stops a long title from pushing the buy
     button off screen, and that behaviour must not change. */
  .console-topbar {
    height: auto;
    min-height: 64px;
    flex-wrap: wrap;
    padding: 8px 16px;
  }

  .console-topbar > :last-child {
    overflow: visible;
    max-width: 100%;
    flex-wrap: wrap;
    justify-content: flex-end;
    row-gap: 6px;
  }

  .content {
    padding: 22px 18px 32px;
  }

  .product-detail-card {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .product-detail-card > :first-child {
    min-height: 280px !important;
  }

  .tm-chat-layout {
    grid-template-columns: minmax(0, 1fr) !important;
    height: auto !important;
    min-height: 620px;
  }

  .tm-chat-layout > :first-child {
    max-height: 210px;
    overflow-y: auto;
    border-right: 0 !important;
    border-bottom: 1px solid var(--cream3);
  }

  .two-col,
  .three-col {
    grid-template-columns: minmax(0, 1fr);
  }

  .modal-footer {
    position: sticky;
    bottom: -28px;
    margin-inline: -28px;
    padding: 14px 28px 0;
    background: #fff;
  }
}

@media (max-width: 768px) {
  .login-left {
    min-height: auto;
    padding: 34px 26px 30px;
  }

  .login-left .feature {
    display: none;
  }

  .login-left .tagline {
    max-width: 540px;
    margin-bottom: 0;
  }

  .login-right {
    width: 100%;
    padding: 38px 26px 48px;
    box-shadow: none;
  }

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

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

  .filters {
    align-items: stretch;
  }

  .filters .search-input,
  .filters .search-box {
    width: 100%;
    max-width: none;
    margin-left: 0;
  }

  .pagination-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toast {
    right: 16px;
    bottom: 16px;
  }
}

@media (max-width: 540px) {
  .topbar > :first-child:not(.tm-menu-toggle) {
    font-size: 15px !important;
  }

  .content {
    padding-inline: 14px;
  }

  .stats-grid,
  .prod-grid,
  .form-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .stat-card {
    min-height: 112px;
  }

  .section-hd {
    align-items: flex-start;
    flex-direction: column;
  }

  .card-box {
    padding: 18px;
  }

  .modal,
  #forgot-modal > div {
    width: 100% !important;
    max-width: 100% !important;
    max-height: calc(100dvh - 24px) !important;
    padding: 22px !important;
  }

  .modal-footer {
    bottom: -22px;
    margin-inline: -22px;
    padding-inline: 22px;
    flex-direction: column-reverse;
  }

  .modal-footer .btn {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }

  .info-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .info-label {
    width: auto !important;
  }

  .product-detail-card > :first-child {
    min-height: 220px !important;
  }
}

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

@media print {
  .sidebar,
  .topbar,
  .tm-menu-toggle,
  .tm-nav-backdrop,
  .toast,
  .btn,
  button { display: none !important; }
  .shell,
  .main { height: auto; overflow: visible; background: #fff; }
  .content { max-width: none; padding: 0; }
  .card-box,
  .stat-card,
  .tbl-wrap { box-shadow: none; break-inside: avoid; }
}
