/* =====================================================
   DQWO Procurement & Materials Management System
   Core Stylesheet
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500&display=swap');

:root {
  /* --- Brand palette --- */
  --navy-900: #0B1F2E;
  --navy-800: #0F2A3D;
  --navy-700: #163C54;
  --navy-600: #1E4F6E;
  --steel-500: #4A6D85;
  --steel-300: #9DB4C4;

  --amber-600: #C9590E;
  --amber-500: #E8702A;
  --amber-400: #F2934F;
  --amber-100: #FCE6D5;

  --ink-900: #1A2127;
  --ink-700: #3D4750;
  --ink-500: #6B7680;
  --ink-300: #A4ADB5;

  --paper-0: #FFFFFF;
  --paper-50: #F7F8FA;
  --paper-100: #EEF1F4;
  --paper-200: #E2E7EC;

  --green-600: #1C7C4F;
  --green-100: #DCF3E6;
  --red-600: #C23B2E;
  --red-100: #FBE3E0;
  --blue-600: #1B5C8A;
  --blue-100: #DCEAF5;
  --gray-600: #5C6770;
  --gray-100: #E9ECEF;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(15, 42, 61, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 42, 61, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 42, 61, 0.14);

  --sidebar-w: 252px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper-50);
  color: var(--ink-900);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: 'JetBrains Mono', monospace; letter-spacing: -0.2px; }

a { color: var(--navy-600); text-decoration: none; }
a:hover { color: var(--amber-600); }

h1, h2, h3, h4, h5 {
  font-weight: 700;
  color: var(--navy-900);
  margin: 0 0 4px 0;
  letter-spacing: -0.01em;
}

::selection { background: var(--amber-100); color: var(--navy-900); }

/* Visible keyboard focus for accessibility */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--amber-500);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* =====================================================
   Layout shell: sidebar + topbar + content
   ===================================================== */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy-900) 0%, var(--navy-800) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
  transition: transform 0.2s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand .mark {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--amber-500), var(--amber-600));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; font-size: 15px;
  flex-shrink: 0;
}

.sidebar-brand .name { font-weight: 700; color: #fff; font-size: 14.5px; line-height: 1.25; }
.sidebar-brand .sub { font-size: 11px; color: var(--steel-300); letter-spacing: 0.04em; text-transform: uppercase; }

.sidebar-nav { flex: 1; padding: 14px 12px; overflow-y: auto; }

.nav-section-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--steel-300);
  padding: 14px 10px 6px 10px;
  font-weight: 600;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: #D7E1E9;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-link svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.85; }

.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }

.nav-link.active {
  background: rgba(232, 112, 42, 0.16);
  color: #fff;
  position: relative;
}
.nav-link.active::before {
  content: '';
  position: absolute; left: -12px; top: 6px; bottom: 6px; width: 3px;
  background: var(--amber-500); border-radius: 0 3px 3px 0;
}

.sidebar-footer {
  padding: 14px 16px 18px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
}
.sidebar-user .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--navy-600); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12.5px; flex-shrink: 0;
}
.sidebar-user .uname { font-size: 13px; font-weight: 600; color: #fff; }
.sidebar-user .urole { font-size: 11px; color: var(--steel-300); }

.main-area {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--topbar-h);
  background: var(--paper-0);
  border-bottom: 1px solid var(--paper-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar .page-title { font-size: 17px; font-weight: 700; color: var(--navy-900); }
.topbar .page-eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--amber-600); font-weight: 700; margin-bottom: 1px;
}

.menu-toggle { display: none; background: none; border: none; cursor: pointer; padding: 6px; }
.menu-toggle svg { width: 22px; height: 22px; color: var(--navy-800); }

.content {
  padding: 24px;
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
}

/* =====================================================
   Cards / KPI stat tiles
   ===================================================== */

.card {
  background: var(--paper-0);
  border: 1px solid var(--paper-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--paper-200);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 15px; margin: 0; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}

.stat-tile {
  background: var(--paper-0);
  border: 1px solid var(--paper-200);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.stat-tile::after {
  content: '';
  position: absolute;
  right: -22px; top: -22px;
  width: 84px; height: 84px;
  border-radius: 50%;
  background: var(--accent, var(--amber-100));
  opacity: 0.5;
}

.stat-tile .stat-label {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ink-500); font-weight: 600; margin-bottom: 8px;
}
.stat-tile .stat-value {
  font-size: 28px; font-weight: 800; color: var(--navy-900);
  font-family: 'JetBrains Mono', monospace;
  position: relative; z-index: 1;
}
.stat-tile .stat-sub { font-size: 12px; color: var(--ink-500); margin-top: 4px; position: relative; z-index: 1;}

.stat-tile.accent-amber { --accent: var(--amber-100); }
.stat-tile.accent-green { --accent: var(--green-100); }
.stat-tile.accent-blue  { --accent: var(--blue-100); }
.stat-tile.accent-red   { --accent: var(--red-100); }

/* =====================================================
   Buttons
   ===================================================== */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px;
  font-size: 13.5px; font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.12s ease;
  font-family: inherit;
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }

.btn-primary { background: var(--navy-800); color: #fff; }
.btn-primary:hover { background: var(--navy-700); color: #fff; }

.btn-accent { background: var(--amber-500); color: #fff; }
.btn-accent:hover { background: var(--amber-600); color: #fff; }

.btn-outline { background: var(--paper-0); color: var(--navy-800); border-color: var(--paper-200); }
.btn-outline:hover { background: var(--paper-100); color: var(--navy-800); }

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

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

.btn-ghost { background: transparent; color: var(--ink-700); }
.btn-ghost:hover { background: var(--paper-100); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* =====================================================
   Forms
   ===================================================== */

.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-700);
  margin-bottom: 6px;
}
label .req { color: var(--red-600); }

.form-control, select.form-control, textarea.form-control {
  width: 100%;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--ink-900);
  background: var(--paper-0);
  border: 1px solid var(--paper-200);
  border-radius: var(--radius-sm);
  transition: border-color 0.12s ease;
}
.form-control:focus {
  border-color: var(--navy-600);
  outline: none;
  box-shadow: 0 0 0 3px rgba(30, 79, 110, 0.12);
}
textarea.form-control { resize: vertical; min-height: 80px; }

.form-hint { font-size: 11.5px; color: var(--ink-500); margin-top: 4px; }
.form-error { font-size: 11.5px; color: var(--red-600); margin-top: 4px; }

/* =====================================================
   Tables
   ===================================================== */

.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-500);
  font-weight: 700;
  padding: 11px 16px;
  background: var(--paper-50);
  border-bottom: 1px solid var(--paper-200);
  white-space: nowrap;
}
.data-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--paper-100);
  color: var(--ink-900);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--paper-50); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .num { font-family: 'JetBrains Mono', monospace; text-align: right; }
.data-table a.row-link { color: var(--navy-800); font-weight: 600; }
.data-table a.row-link:hover { color: var(--amber-600); }

/* =====================================================
   Badges / status pills
   ===================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.badge-warning { background: #FCEFD9; color: #9A5B0A; }
.badge-info    { background: var(--blue-100); color: var(--blue-600); }
.badge-success { background: var(--green-100); color: var(--green-600); }
.badge-danger  { background: var(--red-100); color: var(--red-600); }
.badge-primary { background: #E4ECF3; color: var(--navy-700); }
.badge-secondary { background: var(--gray-100); color: var(--gray-600); }
.badge-dark    { background: var(--navy-900); color: #fff; }

/* =====================================================
   Status pipeline (the signature element)
   Horizontal stepper showing where a PR sits in the workflow
   ===================================================== */

.pipeline {
  display: flex;
  align-items: center;
  width: 100%;
  margin: 6px 0 4px 0;
}
.pipeline .step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  text-align: center;
}
.pipeline .step .dot {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--paper-100);
  border: 2px solid var(--paper-200);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: var(--ink-500);
  z-index: 2;
  transition: all 0.15s ease;
}
.pipeline .step .label {
  font-size: 10.5px; font-weight: 600; color: var(--ink-500);
  margin-top: 7px; text-transform: uppercase; letter-spacing: 0.02em;
  max-width: 90px;
}
.pipeline .step .line {
  position: absolute;
  top: 13px; left: -50%; width: 100%; height: 2px;
  background: var(--paper-200);
  z-index: 1;
}
.pipeline .step:first-child .line { display: none; }

.pipeline .step.done .dot { background: var(--green-600); border-color: var(--green-600); color: #fff; }
.pipeline .step.done .label { color: var(--green-600); }
.pipeline .step.done .line { background: var(--green-600); }

.pipeline .step.current .dot { background: var(--amber-500); border-color: var(--amber-500); color: #fff; box-shadow: 0 0 0 4px var(--amber-100); }
.pipeline .step.current .label { color: var(--amber-600); font-weight: 700; }

.pipeline .step.rejected .dot { background: var(--red-600); border-color: var(--red-600); color: #fff; }
.pipeline .step.rejected .label { color: var(--red-600); }
.pipeline .step.rejected .line { background: var(--red-600); }

/* =====================================================
   Misc utility
   ===================================================== */

.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-gap { display: flex; align-items: center; gap: 10px; }
.text-muted { color: var(--ink-500); }
.text-sm { font-size: 12px; }
.mb-0 { margin-bottom: 0 !important; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }

.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--ink-500);
}
.empty-state svg { width: 48px; height: 48px; color: var(--paper-200); margin-bottom: 12px; }
.empty-state h4 { color: var(--ink-700); margin-bottom: 4px; }

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
}
.alert-success { background: var(--green-100); color: #145C3B; border-color: #b9e5cc; }
.alert-danger  { background: var(--red-100); color: #8C2E23; border-color: #f3c4bd; }
.alert-info    { background: var(--blue-100); color: var(--blue-600); border-color: #c2dcef; }

.pagination { display: flex; gap: 6px; margin-top: 16px; justify-content: flex-end; }
.pagination a, .pagination span {
  padding: 6px 11px; border-radius: var(--radius-sm); font-size: 12.5px;
  border: 1px solid var(--paper-200); color: var(--ink-700);
}
.pagination a:hover { background: var(--paper-100); }
.pagination .active { background: var(--navy-800); color: #fff; border-color: var(--navy-800); }

/* Responsive */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 880px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-area { margin-left: 0; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .content { padding: 16px; }
  .pipeline .label { display: none; }
}

@media (max-width: 520px) {
  .stat-grid { grid-template-columns: 1fr; }
}

/* Product image upload + thumbnails */
.img-cell { display: flex; align-items: center; gap: 8px; }
.img-cell .img-input { padding: 6px; font-size: 12px; }
.img-preview {
  width: 44px; height: 44px; object-fit: cover; flex: none;
  border-radius: 6px; border: 1px solid var(--paper-200); background: var(--paper-50);
}
.item-thumb {
  width: 46px; height: 46px; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--paper-200); background: var(--paper-50);
  cursor: zoom-in; display: block;
}
.item-thumb-empty {
  width: 46px; height: 46px; border-radius: 6px;
  border: 1px dashed var(--paper-200); background: var(--paper-50);
  display: flex; align-items: center; justify-content: center;
  color: var(--paper-400, #9aa5ad); font-size: 18px;
}
