/* ============================================================
   Global Produce ERP — Portal CSS
   Mobile-first, responsive design system
   ============================================================ */

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --gpe-primary:       #1a7a4a;
  --gpe-primary-dark:  #145e38;
  --gpe-primary-light: #e8f5ee;
  --gpe-accent:        #f0a500;
  --gpe-accent-dark:   #c8880a;
  --gpe-danger:        #e53e3e;
  --gpe-warning:       #dd6b20;
  --gpe-info:          #3182ce;
  --gpe-success:       #38a169;
  --gpe-text:          #1a202c;
  --gpe-text-muted:    #718096;
  --gpe-border:        #e2e8f0;
  --gpe-bg:            #f7fafc;
  --gpe-card-bg:       #ffffff;
  --gpe-topbar-h:      56px;
  --gpe-bottomnav-h:   64px;
  --gpe-sidenav-w:     260px;
  --gpe-radius:        10px;
  --gpe-shadow:        0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --gpe-shadow-md:     0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --gpe-transition:    .2s ease;
}

/* ── Reset & Base ──────────────────────────────────────────── */
.gpe-portal *, .gpe-portal *::before, .gpe-portal *::after { box-sizing: border-box; }
.gpe-portal {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  color: var(--gpe-text);
  background: var(--gpe-bg);
  min-height: 100vh;
}

/* ── Top Bar ───────────────────────────────────────────────── */
.gpe-portal-topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  height: var(--gpe-topbar-h);
  background: var(--gpe-primary);
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  box-shadow: var(--gpe-shadow-md);
}
.gpe-portal-topbar__left { display: flex; align-items: center; gap: 12px; }
.gpe-portal-topbar__title { font-size: 17px; font-weight: 600; }
.gpe-portal-topbar__right { display: flex; align-items: center; gap: 14px; }

/* Hamburger */
.gpe-portal-menu-toggle {
  background: none; border: none; cursor: pointer; padding: 4px;
  display: flex; flex-direction: column; gap: 5px;
}
.gpe-portal-menu-toggle span {
  display: block; width: 22px; height: 2px; background: #fff; border-radius: 2px;
  transition: var(--gpe-transition);
}

/* Notification bell */
.gpe-portal-notif-btn {
  position: relative; color: #fff; display: flex; align-items: center;
}
.gpe-portal-notif-badge {
  position: absolute; top: -6px; right: -8px;
  background: var(--gpe-accent); color: #fff;
  font-size: 10px; font-weight: 700; border-radius: 10px;
  padding: 1px 5px; min-width: 18px; text-align: center;
}

/* Avatar */
.gpe-portal-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; color: #fff;
}

/* ── Side Nav ──────────────────────────────────────────────── */
.gpe-portal-sidenav {
  position: fixed; top: 0; left: -280px; bottom: 0; z-index: 300;
  width: var(--gpe-sidenav-w);
  background: #fff;
  display: flex; flex-direction: column;
  box-shadow: var(--gpe-shadow-md);
  transition: left var(--gpe-transition);
  overflow-y: auto;
}
.gpe-portal-sidenav.open { left: 0; }

.gpe-portal-sidenav__header {
  background: var(--gpe-primary);
  color: #fff;
  padding: 24px 20px 20px;
}
.gpe-portal-sidenav__logo { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.gpe-portal-sidenav__role { font-size: 12px; opacity: .8; text-transform: uppercase; letter-spacing: .05em; }
.gpe-portal-sidenav__user { font-size: 14px; font-weight: 600; margin-top: 4px; }

.gpe-portal-sidenav__list { list-style: none; margin: 8px 0; padding: 0; flex: 1; }
.gpe-portal-sidenav__item a {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  color: var(--gpe-text); text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: background var(--gpe-transition), color var(--gpe-transition);
  border-radius: 0;
}
.gpe-portal-sidenav__item a:hover { background: var(--gpe-primary-light); color: var(--gpe-primary); }
.gpe-portal-sidenav__item.active a {
  background: var(--gpe-primary-light); color: var(--gpe-primary);
  border-right: 3px solid var(--gpe-primary);
}
.gpe-portal-sidenav__icon { font-size: 18px; width: 24px; text-align: center; }
.gpe-portal-sidenav__badge {
  margin-left: auto; background: var(--gpe-danger); color: #fff;
  font-size: 11px; font-weight: 700; border-radius: 10px; padding: 1px 6px;
}

.gpe-portal-sidenav__footer { padding: 16px 20px; border-top: 1px solid var(--gpe-border); }
.gpe-portal-logout-btn {
  display: flex; align-items: center; gap: 8px;
  color: var(--gpe-text-muted); text-decoration: none; font-size: 14px;
  transition: color var(--gpe-transition);
}
.gpe-portal-logout-btn:hover { color: var(--gpe-danger); }

/* Overlay */
.gpe-portal-overlay {
  display: none; position: fixed; inset: 0; z-index: 250;
  background: rgba(0,0,0,.45);
}
.gpe-portal-overlay.show { display: block; }

/* ── Main Content ──────────────────────────────────────────── */
.gpe-portal-main {
  padding-top: calc(var(--gpe-topbar-h) + 16px);
  padding-bottom: calc(var(--gpe-bottomnav-h) + 16px);
  padding-left: 16px; padding-right: 16px;
  max-width: 1200px; margin: 0 auto;
}

/* ── Bottom Nav (mobile only) ──────────────────────────────── */
.gpe-portal-bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  height: var(--gpe-bottomnav-h);
  background: #fff;
  border-top: 1px solid var(--gpe-border);
  display: flex; align-items: stretch;
  box-shadow: 0 -2px 8px rgba(0,0,0,.08);
}
.gpe-portal-bottomnav__item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  color: var(--gpe-text-muted); text-decoration: none;
  font-size: 10px; font-weight: 500;
  transition: color var(--gpe-transition), background var(--gpe-transition);
  padding: 6px 4px;
}
.gpe-portal-bottomnav__item.active {
  color: var(--gpe-primary);
  background: var(--gpe-primary-light);
}
.gpe-portal-bottomnav__icon { font-size: 20px; line-height: 1; }
.gpe-portal-bottomnav__label { font-size: 10px; }

/* ── Cards ─────────────────────────────────────────────────── */
.gpe-card {
  background: var(--gpe-card-bg); border-radius: var(--gpe-radius);
  box-shadow: var(--gpe-shadow); padding: 20px; margin-bottom: 16px;
}
.gpe-card-title {
  font-size: 16px; font-weight: 700; margin: 0 0 14px;
  color: var(--gpe-text);
}
.gpe-card-subtitle {
  font-size: 13px; color: var(--gpe-text-muted); margin: -10px 0 14px;
}

/* ── Stat Grid ─────────────────────────────────────────────── */
.gpe-stat-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px;
}
.gpe-stat-card {
  background: var(--gpe-card-bg); border-radius: var(--gpe-radius);
  box-shadow: var(--gpe-shadow); padding: 16px 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.gpe-stat-card__label { font-size: 12px; color: var(--gpe-text-muted); font-weight: 500; }
.gpe-stat-card__value { font-size: 26px; font-weight: 800; color: var(--gpe-primary); line-height: 1; }
.gpe-stat-card__sub   { font-size: 12px; color: var(--gpe-text-muted); }
.gpe-stat-card.accent .gpe-stat-card__value { color: var(--gpe-accent-dark); }
.gpe-stat-card.danger .gpe-stat-card__value { color: var(--gpe-danger); }
.gpe-stat-card.info   .gpe-stat-card__value { color: var(--gpe-info); }

/* ── Tables ────────────────────────────────────────────────── */
.gpe-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.gpe-table {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
.gpe-table th {
  background: var(--gpe-bg); text-align: left;
  padding: 10px 12px; font-size: 12px; font-weight: 600;
  color: var(--gpe-text-muted); text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 2px solid var(--gpe-border);
}
.gpe-table td {
  padding: 12px; border-bottom: 1px solid var(--gpe-border);
  vertical-align: middle;
}
.gpe-table tr:last-child td { border-bottom: none; }
.gpe-table tr:hover td { background: var(--gpe-primary-light); }

/* ── Badges / Status ───────────────────────────────────────── */
.gpe-badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; text-transform: capitalize;
}
.gpe-badge-green  { background: #c6f6d5; color: #276749; }
.gpe-badge-yellow { background: #fefcbf; color: #975a16; }
.gpe-badge-red    { background: #fed7d7; color: #9b2c2c; }
.gpe-badge-blue   { background: #bee3f8; color: #2a69ac; }
.gpe-badge-gray   { background: #edf2f7; color: #4a5568; }
.gpe-badge-orange { background: #feebc8; color: #9c4221; }

/* ── Buttons ───────────────────────────────────────────────── */
.gpe-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; font-size: 14px; font-weight: 600;
  cursor: pointer; border: none; text-decoration: none;
  transition: background var(--gpe-transition), transform .1s;
}
.gpe-btn:active { transform: scale(.97); }
.gpe-btn-primary { background: var(--gpe-primary); color: #fff; }
.gpe-btn-primary:hover { background: var(--gpe-primary-dark); color: #fff; }
.gpe-btn-accent  { background: var(--gpe-accent); color: #fff; }
.gpe-btn-accent:hover { background: var(--gpe-accent-dark); }
.gpe-btn-outline {
  background: transparent; color: var(--gpe-primary);
  border: 2px solid var(--gpe-primary);
}
.gpe-btn-outline:hover { background: var(--gpe-primary-light); }
.gpe-btn-danger  { background: var(--gpe-danger); color: #fff; }
.gpe-btn-sm { padding: 6px 12px; font-size: 13px; }
.gpe-btn-block { width: 100%; justify-content: center; }

/* ── Forms ─────────────────────────────────────────────────── */
.gpe-form-group { margin-bottom: 16px; }
.gpe-form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--gpe-text); }
.gpe-form-control {
  width: 100%; padding: 10px 14px; border: 1px solid var(--gpe-border);
  border-radius: 8px; font-size: 14px; color: var(--gpe-text);
  background: #fff; transition: border-color var(--gpe-transition);
  -webkit-appearance: none;
}
.gpe-form-control:focus { outline: none; border-color: var(--gpe-primary); box-shadow: 0 0 0 3px rgba(26,122,74,.15); }
textarea.gpe-form-control { resize: vertical; min-height: 90px; }
select.gpe-form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23718096' d='M6 8L0 0h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

/* ── Chat / Negotiation Thread ─────────────────────────────── */
.gpe-thread { display: flex; flex-direction: column; gap: 12px; padding: 16px 0; }
.gpe-msg { display: flex; gap: 10px; max-width: 85%; }
.gpe-msg.mine { flex-direction: row-reverse; align-self: flex-end; }
.gpe-msg-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--gpe-primary-light); color: var(--gpe-primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.gpe-msg.mine .gpe-msg-avatar { background: var(--gpe-accent); color: #fff; }
.gpe-msg-bubble {
  background: #fff; border-radius: 12px; padding: 10px 14px;
  box-shadow: var(--gpe-shadow); font-size: 14px; line-height: 1.5;
}
.gpe-msg.mine .gpe-msg-bubble { background: var(--gpe-primary); color: #fff; }
.gpe-msg-meta { font-size: 11px; color: var(--gpe-text-muted); margin-top: 4px; }
.gpe-msg.mine .gpe-msg-meta { text-align: right; color: rgba(255,255,255,.7); }

.gpe-thread-input {
  position: sticky; bottom: calc(var(--gpe-bottomnav-h) + 8px);
  background: var(--gpe-bg); padding: 12px 0 4px;
  display: flex; gap: 8px;
}
.gpe-thread-input .gpe-form-control { flex: 1; }

/* ── List Items ────────────────────────────────────────────── */
.gpe-list { list-style: none; margin: 0; padding: 0; }
.gpe-list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 0; border-bottom: 1px solid var(--gpe-border);
  text-decoration: none; color: var(--gpe-text);
  transition: background var(--gpe-transition);
}
.gpe-list-item:last-child { border-bottom: none; }
.gpe-list-item:hover { background: var(--gpe-primary-light); margin: 0 -20px; padding-left: 20px; padding-right: 20px; }
.gpe-list-item__icon { font-size: 22px; width: 36px; text-align: center; flex-shrink: 0; }
.gpe-list-item__body { flex: 1; min-width: 0; }
.gpe-list-item__title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gpe-list-item__sub   { font-size: 12px; color: var(--gpe-text-muted); margin-top: 2px; }
.gpe-list-item__right { flex-shrink: 0; text-align: right; }
.gpe-list-item__arrow { color: var(--gpe-text-muted); font-size: 18px; }

/* ── Empty State ───────────────────────────────────────────── */
.gpe-empty {
  text-align: center; padding: 48px 20px; color: var(--gpe-text-muted);
}
.gpe-empty__icon { font-size: 48px; margin-bottom: 12px; }
.gpe-empty__title { font-size: 16px; font-weight: 600; margin-bottom: 6px; color: var(--gpe-text); }
.gpe-empty__text  { font-size: 14px; }

/* ── Alerts ────────────────────────────────────────────────── */
.gpe-alert {
  padding: 12px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 12px;
  display: flex; align-items: flex-start; gap: 10px;
}
.gpe-alert-success { background: #c6f6d5; color: #276749; }
.gpe-alert-warning { background: #fefcbf; color: #975a16; }
.gpe-alert-danger  { background: #fed7d7; color: #9b2c2c; }
.gpe-alert-info    { background: #bee3f8; color: #2a69ac; }

/* ── Section Header ────────────────────────────────────────── */
.gpe-section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.gpe-section-title { font-size: 15px; font-weight: 700; }

/* ── Login Page ────────────────────────────────────────────── */
.gpe-portal-login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--gpe-primary) 0%, var(--gpe-primary-dark) 100%);
  padding: 20px;
}
.gpe-portal-login-card {
  background: #fff; border-radius: 16px; padding: 36px 28px;
  width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.gpe-portal-login-logo { font-size: 48px; text-align: center; margin-bottom: 8px; }
.gpe-portal-login-title { font-size: 22px; font-weight: 800; text-align: center; margin: 0 0 6px; }
.gpe-portal-login-sub { font-size: 14px; color: var(--gpe-text-muted); text-align: center; margin: 0 0 24px; }
.gpe-portal-login-forgot { text-align: center; font-size: 13px; margin-top: 14px; }
.gpe-portal-login-card .login-submit .button-primary {
  width: 100%; padding: 12px; background: var(--gpe-primary); border: none;
  border-radius: 8px; font-size: 15px; font-weight: 700; color: #fff; cursor: pointer;
}
.gpe-portal-login-card input[type="text"],
.gpe-portal-login-card input[type="password"] {
  width: 100%; padding: 10px 14px; border: 1px solid var(--gpe-border);
  border-radius: 8px; font-size: 14px; margin-bottom: 12px;
}

/* ── Progress / Timeline ───────────────────────────────────── */
.gpe-timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.gpe-timeline::before { content: ''; position: absolute; left: 16px; top: 0; bottom: 0; width: 2px; background: var(--gpe-border); }
.gpe-timeline-item { display: flex; gap: 16px; padding: 0 0 20px 0; position: relative; }
.gpe-timeline-dot {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--gpe-primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; z-index: 1;
}
.gpe-timeline-dot.pending { background: var(--gpe-border); color: var(--gpe-text-muted); }
.gpe-timeline-body { flex: 1; padding-top: 4px; }
.gpe-timeline-title { font-weight: 600; font-size: 14px; }
.gpe-timeline-sub   { font-size: 12px; color: var(--gpe-text-muted); margin-top: 2px; }

/* ── Dual Thread (Trade Manager) ───────────────────────────── */
.gpe-dual-thread { display: grid; grid-template-columns: 1fr; gap: 16px; }
.gpe-thread-panel { background: var(--gpe-card-bg); border-radius: var(--gpe-radius); padding: 16px; box-shadow: var(--gpe-shadow); }
.gpe-thread-panel-title {
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 6px 10px; border-radius: 6px; margin-bottom: 12px;
}
.gpe-thread-panel-title.supplier { background: #e8f5ee; color: var(--gpe-primary); }
.gpe-thread-panel-title.customer { background: #ebf8ff; color: var(--gpe-info); }

/* ── Shipment Tracker ──────────────────────────────────────── */
.gpe-tracker {
  display: flex; align-items: center; gap: 0; margin: 16px 0;
  overflow-x: auto; padding-bottom: 8px;
}
.gpe-tracker-step {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-width: 80px; position: relative;
}
.gpe-tracker-step:not(:last-child)::after {
  content: ''; position: absolute; top: 16px; left: calc(50% + 16px);
  right: calc(-50% + 16px); height: 2px; background: var(--gpe-border); z-index: 0;
}
.gpe-tracker-step.done::after { background: var(--gpe-primary); }
.gpe-tracker-dot {
  width: 32px; height: 32px; border-radius: 50%; z-index: 1;
  background: var(--gpe-border); color: var(--gpe-text-muted);
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.gpe-tracker-step.done .gpe-tracker-dot { background: var(--gpe-primary); color: #fff; }
.gpe-tracker-step.current .gpe-tracker-dot { background: var(--gpe-accent); color: #fff; box-shadow: 0 0 0 4px rgba(240,165,0,.25); }
.gpe-tracker-label { font-size: 11px; color: var(--gpe-text-muted); text-align: center; }
.gpe-tracker-step.done .gpe-tracker-label,
.gpe-tracker-step.current .gpe-tracker-label { color: var(--gpe-text); font-weight: 600; }

/* ── Responsive: Tablet/Desktop ────────────────────────────── */
@media (min-width: 768px) {
  .gpe-portal-sidenav { left: 0; }
  .gpe-portal-menu-toggle { display: none; }
  .gpe-portal-main { padding-left: calc(var(--gpe-sidenav-w) + 24px); padding-right: 24px; }
  .gpe-portal-bottomnav { display: none; }
  .gpe-stat-grid { grid-template-columns: repeat(3, 1fr); }
  .gpe-dual-thread { grid-template-columns: 1fr 1fr; }
  .gpe-portal-main { padding-bottom: 24px; }
}

@media (min-width: 1024px) {
  .gpe-stat-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ── Utility ───────────────────────────────────────────────── */
.gpe-mt-0 { margin-top: 0 !important; }
.gpe-mb-0 { margin-bottom: 0 !important; }
.gpe-text-muted { color: var(--gpe-text-muted); }
.gpe-text-right { text-align: right; }
.gpe-text-center { text-align: center; }
.gpe-fw-bold { font-weight: 700; }
.gpe-d-flex { display: flex; }
.gpe-align-center { align-items: center; }
.gpe-gap-8 { gap: 8px; }
.gpe-w-100 { width: 100%; }
.gpe-hidden { display: none !important; }
