/*
 * GlobalWholesale Hub V11 final visual layer.
 * Loaded last by both public and portal layouts to normalize all responsive
 * dashboards, dedicated forms, alerts, tables, navigation and accessible focus.
 */

:root {
  --gwh-ink: #12233d;
  --gwh-muted: #64748b;
  --gwh-surface: #ffffff;
  --gwh-surface-soft: #f7f9fc;
  --gwh-line: #e2e8f0;
  --gwh-success: #128a59;
  --gwh-danger: #bf3156;
  --gwh-warning: #b7791f;
  --gwh-shadow: 0 18px 42px rgba(15, 35, 64, .08);
  --gwh-radius: 16px;
  --color-primary: var(--brand, #f67c00);
  --color-secondary: var(--accent, #ff9f28);
  --color-text: var(--gwh-ink);
  --color-surface: var(--gwh-surface);
  --color-border: var(--gwh-line);
}

* { min-width: 0; }

body.gwh-theme {
  background: var(--gwh-surface-soft);
  color: var(--color-text);
  line-height: 1.55;
}

a { text-underline-offset: .18em; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--color-primary) 34%, transparent);
  outline-offset: 2px;
}

.inline-svg-icon {
  flex: 0 0 auto;
  vertical-align: -.15em;
}

.btn,
button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .42rem;
  min-height: 42px;
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: .005em;
}

.btn.btn-sm { min-height: 34px; }
.btn-brand {
  background: var(--color-primary) !important;
  border-color: var(--color-primary) !important;
  color: #fff !important;
  box-shadow: 0 7px 18px color-mix(in srgb, var(--color-primary) 24%, transparent);
}
.btn-brand:hover { filter: brightness(.94); transform: translateY(-1px); }
.btn-light {
  background: #fff !important;
  color: var(--gwh-ink) !important;
  border: 1px solid var(--gwh-line) !important;
}
.btn-light:hover { background: #f8fafc !important; border-color: color-mix(in srgb, var(--color-primary) 36%, var(--gwh-line)) !important; }
.btn-danger { background: var(--gwh-danger) !important; border-color: var(--gwh-danger) !important; color: #fff !important; }

.page-heading {
  display: flex;
  gap: 1.15rem;
  justify-content: space-between;
  align-items: flex-start;
  margin: 0 0 1.5rem;
}
.page-heading h2, .page-heading h1 { color: var(--gwh-ink); margin-bottom: .25rem; }
.page-heading p { color: var(--gwh-muted); margin: 0; }
.eyebrow {
  color: color-mix(in srgb, var(--color-primary) 76%, #374151);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.back-link {
  display: inline-flex;
  gap: .4rem;
  align-items: center;
  font-size: .9rem;
  font-weight: 750;
  color: var(--gwh-muted);
  text-decoration: none;
  margin-bottom: .7rem;
}
.back-link:hover { color: var(--color-primary); }

.panel,
.form-card,
.detail-panel {
  border: 1px solid var(--gwh-line);
  border-radius: var(--gwh-radius);
  background: var(--gwh-surface);
  box-shadow: var(--gwh-shadow);
}
.panel { overflow: hidden; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .9rem;
  padding: 1.1rem 1.25rem;
  background: linear-gradient(130deg, #fff, color-mix(in srgb, var(--color-primary) 4%, #fff));
  border-bottom: 1px solid var(--gwh-line);
}
.panel-head h3 { margin: .1rem 0; color: var(--gwh-ink); font-size: 1.07rem; }
.panel-head p { color: var(--gwh-muted); }

.premium-form-card {
  padding: clamp(1rem, 3vw, 2rem);
  max-width: 980px;
  margin: 0 auto;
}
.narrow-form { max-width: 800px; }
.form-card-intro {
  display: flex;
  gap: .9rem;
  align-items: flex-start;
  padding-bottom: 1.25rem;
  margin-bottom: 1.35rem;
  border-bottom: 1px solid var(--gwh-line);
}
.form-card-intro h3 { margin: 0 0 .2rem; color: var(--gwh-ink); }
.form-card-intro p { color: var(--gwh-muted); margin: 0; }
.icon-orb {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 12%, #fff);
  border: 1px solid color-mix(in srgb, var(--color-primary) 18%, #fff);
}
.icon-orb-warning {
  color: var(--gwh-warning);
  background: #fff8e8;
  border-color: #f5d79e;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem 1.15rem;
}
.form-grid .span-2 { grid-column: 1 / -1; }
.form-group-premium { margin-bottom: 0; }
.form-group-premium label,
.form-grid > label,
.form-grid > div > label {
  font-size: .9rem;
  font-weight: 800;
  color: var(--gwh-ink);
}
.input-icon-wrapper input,
.input-icon-wrapper select,
.input-icon-wrapper textarea,
.inline-tat-form input,
.buy-form input {
  min-height: 44px;
  border: 1px solid #cbd5e1 !important;
  background: #fff !important;
  color: var(--gwh-ink) !important;
  border-radius: 10px !important;
}
.input-icon-wrapper textarea { min-height: 132px; padding-top: .8rem !important; }
.input-icon-wrapper input:focus,
.input-icon-wrapper select:focus,
.input-icon-wrapper textarea:focus,
.inline-tat-form input:focus,
.buy-form input:focus {
  border-color: var(--color-primary) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 18%, transparent) !important;
}
.form-hint {
  color: var(--gwh-muted);
  font-size: .82rem;
  margin: .45rem 0 0;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: .75rem;
  padding-top: .75rem;
}
.form-actions.align-end { align-self: end; }

.inline-actions,
.inline-form,
.inline-tat-form {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.inline-form { margin: 0; }
.inline-tat-form input {
  width: 78px;
  padding: .35rem .55rem !important;
  min-height: 34px;
}
.inline-tat-form .btn { min-height: 34px; }

.app-table { margin: 0; }
.app-table thead th {
  color: #526075;
  background: #f8fafc;
  white-space: nowrap;
  border-bottom: 1px solid var(--gwh-line);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.app-table tbody td { vertical-align: middle; color: #334155; }
.app-table tbody td small { display: block; margin-top: .25rem; color: var(--gwh-muted); }
.app-table tbody tr:hover { background: #fbfcfe; }

.detail-panel { padding: 1.25rem; }
.summary-row { display: flex; gap: .8rem; align-items: flex-start; justify-content: space-between; padding: .62rem 0; }
.summary-row small { display: block; color: var(--gwh-muted); }
.summary-row.total { color: var(--gwh-ink); font-size: 1.06rem; padding-top: .9rem; }
.tracking-box {
  display: flex;
  gap: .75rem;
  padding: .9rem;
  border: 1px solid color-mix(in srgb, var(--color-primary) 20%, var(--gwh-line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--color-primary) 5%, #fff);
  color: var(--color-primary);
}
.tracking-box div { color: var(--gwh-ink); }
.tracking-box b, .tracking-box small, .tracking-box a { display: block; }
.tracking-box a { margin-top: .25rem; font-weight: 750; color: var(--color-primary); }

.status {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: .18rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 800;
  line-height: 1;
  background: #edf2f7;
  color: #475569;
}
.status-paid, .status-approved, .status-published, .status-delivered, .status-delivery_confirmed, .status-qc_passed, .status-active, .status-completed, .status-released {
  background: #e8f8ef; color: #087648;
}
.status-pending, .status-pending_approval, .status-processing, .status-supplier_preparing, .status-ready_for_qc, .status-qc_scheduled, .status-in_transit, .status-under_review, .status-queued {
  background: #fff6dd; color: #946200;
}
.status-refunded, .status-cancelled, .status-rejected, .status-suspended, .status-qc_failed, .status-disputed, .status-failed {
  background: #ffedf2; color: #b32145;
}

.timeline > div,
.shipment-update-list > div {
  display: flex;
  gap: .75rem;
  padding: .9rem 1.2rem;
  border-bottom: 1px solid var(--gwh-line);
}
.timeline > div:last-child,
.shipment-update-list > div:last-child { border-bottom: 0; }
.timeline > div > svg { color: var(--gwh-success); margin-top: .15rem; }
.timeline b, .timeline small, .shipment-update-list b, .shipment-update-list small { display: block; }
.timeline small, .shipment-update-list small { margin-top: .3rem; color: var(--gwh-muted); }
.shipment-update-list p { margin: .25rem 0; color: #475569; }
.status-dot { width: 10px; height: 10px; margin-top: .45rem; border-radius: 50%; background: var(--color-primary); box-shadow: 0 0 0 5px color-mix(in srgb, var(--color-primary) 13%, transparent); }

.client-announcement {
  position: fixed;
  z-index: 5000;
  right: 1.25rem;
  bottom: 1.25rem;
  max-width: min(420px, calc(100vw - 2.5rem));
  padding: .9rem 1rem;
  border: 1px solid #fecaca;
  border-radius: 12px;
  background: #fff1f2;
  color: #9f1239;
  box-shadow: var(--gwh-shadow);
  font-size: .9rem;
  font-weight: 700;
}
.client-announcement:empty { display: none; }

.dashboard-body .dash-main,
.dashboard-body .dash-content { background: var(--gwh-surface-soft); }
.dash-content { padding: clamp(1rem, 3vw, 2rem); }
.dash-sidebar { box-shadow: 10px 0 30px rgba(8, 26, 49, .08); }
.dash-sidebar nav a { display: flex; align-items: center; gap: .7rem; }
.dash-sidebar nav a.active { color: #fff !important; }
.dash-topbar { position: sticky; top: 0; z-index: 30; }
.dash-user { min-width: 0; }
.dash-user strong { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 991.98px) {
  .page-heading { flex-direction: column; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .dash-topbar { position: relative; }
  .dash-content { padding: 1rem; }
  .table-responsive { border-radius: 0 0 var(--gwh-radius) var(--gwh-radius); }
}

@media (max-width: 767.98px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .form-actions { justify-content: stretch; flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
  .page-heading h2, .page-heading h1 { font-size: 1.45rem; }
  .inline-actions { align-items: stretch; }
  .inline-actions .btn, .inline-form .btn { flex: 1 1 auto; }
  .inline-tat-form { width: 100%; }
  .inline-tat-form input { flex: 1 1 70px; }
  .inline-tat-form .btn { flex: 1 1 auto; }
  .detail-panel { padding: 1rem; }
  .summary-row { font-size: .92rem; }
  .client-announcement { right: .75rem; bottom: .75rem; }
}

@media (max-width: 430px) {
  .btn, button.btn { width: 100%; }
  .inline-actions .btn, .inline-form .btn { width: 100%; }
  .panel-head { padding: 1rem; }
  .app-table { font-size: .87rem; }
}
