/* =========================================================
   IBH PLATFORM — SHARED DESIGN SYSTEM
   Matches the navy / blue / gold / green palette and
   Segoe UI system font from the IBH Platform demo.
   ========================================================= */

:root {
  --ink:        #1A1A2E;
  --ink-soft:   #1E3A5F;
  --muted:      #6B7280;
  --line:       #E2E8F0;
  --line-soft:  #EEF2F7;
  --bg:         #EEF2F7;
  --surface:    #FFFFFF;
  --navy:       #1E3A5F;
  --accent:     #2E75B6;
  --accent-ink: #1D5FA0;
  --accent-soft:#DBEAFE;
  --gold:       #C8A045;
  --gold-soft:  #FEF9C3;
  --green:      #16A34A;
  --green-soft: #DCFCE7;
  --red:        #DC2626;
  --red-soft:   #FEE2E2;

  --radius: 9px;
  --radius-lg: 13px;
  --shadow-sm: 0 1px 2px rgba(26,26,46,0.06);
  --shadow-md: 0 8px 24px rgba(26,26,46,0.12);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: 'Segoe UI', Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .display {
  font-family: 'Segoe UI', Arial, sans-serif;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

::selection { background: var(--accent-soft); color: var(--accent-ink); }

/* ---------- Layout shell (sidebar + main) ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--ink);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  font-family: 'Segoe UI', Arial, sans-serif;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
  padding: 0 10px 24px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar .brand small {
  display: block;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 11px;
  color: #9CA3AF;
  letter-spacing: 0.02em;
}
.sidebar nav { flex: 1; display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.sidebar nav a, .sidebar nav button.navlink {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 8px;
  color: #C9D1D9;
  font-size: 14px;
  font-weight: 500;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
}
.sidebar nav a:hover, .sidebar nav button.navlink:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar nav a.active { background: var(--accent); color: #fff; }
.sidebar .user-box {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 14px;
  font-size: 13px;
  color: #9CA3AF;
}
.sidebar .user-box strong { color: #fff; display: block; font-size: 14px; margin-bottom: 2px; }
.sidebar .logout-btn {
  margin-top: 10px;
  width: 100%;
  padding: 9px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  background: transparent;
  color: #C9D1D9;
  font-size: 13px;
  font-weight: 500;
}
.sidebar .logout-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }

.main { flex: 1; min-width: 0; padding: 32px 40px; max-width: 1400px; }
.main-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 28px; flex-wrap: wrap; gap: 12px;
}
.main-header h1 { font-size: 26px; }
.main-header p { color: var(--muted); font-size: 14px; margin-top: 6px; }

/* ---------- Cards / stats ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.stat-card .label { overflow-wrap: anywhere; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .value { overflow-wrap: anywhere; font-family: 'Segoe UI', Arial, sans-serif; font-size: clamp(22px, 2.4vw, 30px); font-weight: 800; margin-top: 6px; }
.stat-card .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 24px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; flex-wrap: wrap; gap: 10px;
}
.card-header h2 { font-size: 18px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all .15s ease;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: var(--bg); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { opacity: 0.9; }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-danger:hover { background: #ffd7d5; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------- Filter selects (reused across catalogue/order filter bars) ---------- */
select {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  background: var(--surface);
  color: var(--ink);
}
select:focus { outline: none; border-color: var(--accent); }

/* ---------- Volume tracker ---------- */
.volume-track { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.volume-chip {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font-size: 12px; min-width: 150px; background: var(--surface);
}
.volume-chip .vnum { font-weight: 700; font-family: 'Segoe UI', Arial, sans-serif; margin-bottom: 4px; }
.volume-chip .vdate { color: var(--muted); font-size: 11px; }
.volume-progress { height: 6px; border-radius: 100px; background: var(--line-soft); overflow: hidden; margin-top: 6px; }
.volume-progress > div { height: 100%; background: var(--green); }

/* ---------- Order tracking stepper ---------- */
.steps { display: flex; gap: 0; margin-bottom: 18px; }
.sti { flex: 1; display: flex; flex-direction: column; align-items: center; position: relative; }
.sti::after { content: ''; position: absolute; top: 13px; left: 50%; width: 100%; height: 2px; background: var(--line); z-index: 0; }
.sti:last-child::after { display: none; }
.stc { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; position: relative; z-index: 1; }
.stc.dn { background: var(--green); color: #fff; }
.stc.ac { background: var(--accent); color: #fff; }
.stc.pd { background: var(--line); color: var(--muted); }
.stc.rj { background: var(--red); color: #fff; }
.stl { font-size: 9px; color: var(--muted); margin-top: 4px; text-align: center; font-weight: 600; }

/* ---------- Chat ---------- */
.chat-box { display: flex; flex-direction: column; gap: 10px; max-height: 360px; overflow-y: auto; padding: 14px; background: var(--bg); border-radius: 9px; margin-bottom: 12px; }
.msg { max-width: 75%; padding: 9px 13px; border-radius: 10px; font-size: 12.5px; line-height: 1.5; }
.msg.out { background: var(--accent); color: #fff; margin-left: auto; border-bottom-right-radius: 3px; }
.msg.in { background: #fff; color: var(--ink); border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.msg .mt { font-size: 10px; opacity: 0.7; margin-top: 4px; }
.chat-input-row { display: flex; gap: 8px; }
.chat-input-row input { flex: 1; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 7px; font-size: 13px; outline: none; }
.chat-input-row input:focus { border-color: var(--accent); }
.chat-thread-item { display: flex; align-items: center; gap: 9px; padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.chat-thread-item:hover { background: var(--bg); }
.chat-thread-item.active { background: var(--accent-soft); }

/* ---------- Task card ---------- */
.tc { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 13px; margin-bottom: 9px; display: flex; gap: 11px; }
.tb { width: 4px; border-radius: 4px; align-self: stretch; flex-shrink: 0; }
.tb.high { background: var(--red); }
.tb.medium { background: var(--gold); }
.tb.low { background: var(--green); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; padding: 10px 12px; color: var(--muted);
  font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
tbody td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:hover { background: var(--bg); }
tbody tr:last-child td { border-bottom: none; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 100px;
  font-size: 11.5px; font-weight: 700; text-transform: capitalize; letter-spacing: 0.01em;
}
.badge-pending, .badge-quote_requested { background: var(--gold-soft); color: var(--gold); }
.badge-approved, .badge-accepted, .badge-delivered, .badge-quote_sent { background: var(--green-soft); color: var(--green); }
.badge-rejected, .badge-cancelled { background: var(--red-soft); color: var(--red); }
.badge-processing, .badge-dispatched { background: var(--accent-soft); color: var(--accent-ink); }
.badge-paid { background: var(--green-soft); color: var(--green); }
.badge-unpaid { background: var(--red-soft); color: var(--red); }
.badge-high { background: var(--red-soft); color: var(--red); }
.badge-medium { background: var(--gold-soft); color: #92400E; }
.badge-low { background: var(--green-soft); color: var(--green); }
.badge-in_progress { background: var(--accent-soft); color: var(--accent-ink); }
.badge-completed { background: var(--green-soft); color: var(--green); }

/* ---------- Book grid (college catalogue) ---------- */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}
.book-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column;
}
.book-cover {
  height: 150px; background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); font-family: 'Segoe UI', Arial, sans-serif; font-weight: 800; font-size: 13px;
  background-size: cover; background-position: center;
}
.book-body { padding: 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.book-title { font-weight: 700; font-size: 14.5px; line-height: 1.3; }
.book-author { font-size: 12.5px; color: var(--muted); }
.book-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.book-price { font-family: 'Segoe UI', Arial, sans-serif; font-weight: 800; font-size: 17px; margin-top: 6px; }
.book-footer { padding: 12px 14px; border-top: 1px solid var(--line-soft); display: flex; gap: 8px; align-items: center; }
.qty-input { width: 56px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; text-align: center; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(13,17,23,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  padding: 26px; box-shadow: var(--shadow-md);
}
.modal.modal-lg { max-width: 720px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-header h3 { font-size: 18px; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--ink); color: #fff;
  padding: 13px 18px; border-radius: 10px; font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-md); z-index: 2000;
  display: flex; align-items: center; gap: 10px;
  animation: toastIn .2s ease;
  max-width: 360px;
}
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- Cart drawer ---------- */
.cart-drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 380px;
  background: var(--surface); box-shadow: -8px 0 24px rgba(13,17,23,0.1);
  z-index: 900; transform: translateX(100%); transition: transform .25s ease;
  display: flex; flex-direction: column;
}
.cart-drawer.open { transform: translateX(0); }
.cart-header { padding: 20px; border-bottom: 1px solid var(--line-soft); display: flex; justify-content: space-between; align-items: center; }
.cart-items { flex: 1; overflow-y: auto; padding: 12px 20px; }
.cart-item { display: flex; justify-content: space-between; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line-soft); gap: 8px; }
.cart-footer { padding: 20px; border-top: 1px solid var(--line-soft); }
.cart-fab {
  position: fixed; bottom: 28px; right: 28px; z-index: 800;
  background: var(--ink); color: #fff; border: none; border-radius: 100px;
  padding: 14px 22px; font-size: 14px; font-weight: 700; box-shadow: var(--shadow-md);
  display: flex; align-items: center; gap: 8px;
}

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-state .icon { font-size: 34px; margin-bottom: 10px; }
.empty-state p { font-size: 14px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-soft); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 16px; background: none; border: none; font-size: 13.5px; font-weight: 600;
  color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-btn.active { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.flex { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--line);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: -260px; z-index: 950; transition: left .2s ease; }
  .sidebar.open { left: 0; }
  .main { padding: 20px; }
  .field-row { grid-template-columns: 1fr; }
  .cart-drawer { width: 100%; }
}

/* ---------- Fulfilment & acknowledgments ---------- */
.badge-closed { background: #1F2937; color: #fff; }
.badge-in_transit, .badge-sent_by_publisher, .badge-sent_to_college { background: var(--accent-soft); color: var(--accent-ink); }
.badge-acknowledged, .badge-received_by_admin { background: var(--green-soft); color: var(--green); }
.badge-partially_acknowledged, .badge-awaiting_publisher { background: var(--gold-soft); color: #92400E; }
.ful-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; background: var(--surface); }
.ful-card h4 { font-size: 14px; margin-bottom: 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ful-meta { font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.ful-ack { margin-top: 10px; padding: 9px 12px; border-radius: 8px; font-size: 12.5px; background: var(--green-soft); color: var(--green); }
.ful-ack.warn { background: var(--gold-soft); color: #92400E; }
.ful-ack.wait { background: var(--accent-soft); color: var(--accent-ink); }
.ful-units { margin: 8px 0; font-size: 13px; }
.ful-units label { display: flex; gap: 8px; align-items: center; padding: 3px 0; }
.ful-units input { width: auto; }
.ful-form { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 13px; }
.ful-form textarea { width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 8px; min-height: 52px; margin: 6px 0; }
.ful-progress { height: 8px; background: var(--line-soft); border-radius: 99px; overflow: hidden; display: flex; }
.ful-progress > div { height: 100%; }
.ful-timeline { font-size: 12.5px; border-left: 2px solid var(--line); margin-left: 6px; padding-left: 14px; }
.ful-timeline .ev { margin-bottom: 10px; position: relative; }
.ful-timeline .ev::before { content: ''; position: absolute; left: -20px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent-ink); }
.ful-timeline .ev.ack::before { background: var(--green); }
.ful-timeline .ev.close::before { background: #111; }
.ful-section-title { font-size: 14px; font-weight: 800; margin: 18px 0 8px; font-family: 'Segoe UI', Arial, sans-serif; }
.ful-banner { background: var(--gold-soft); border: 1px solid #E8D28A; border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; }

/* phones: 2 cards per row, tighter padding so nothing is cut off */
@media (max-width: 520px) {
  .main { padding: 16px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card .label { font-size: 11px; }
}

.portal-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)); align-items: start; }
