/* ============================================================
   BFB Portal Theme – visual overrides on top of Bootstrap 5.3
   Loaded AFTER Bootstrap CDN and layout.php inline styles.
   ============================================================ */

/* ----- Color reference -----
   Text primary:      #1e293b
   Text secondary:    #9ca3af
   Page bg:           #f4f5f7
   Card / table bg:   #fff
   Header / footer:   #fafbfc
   Border primary:    #e5e7eb
   Border subtle:     #f3f4f6
   Dark accent:       #1e293b
   Amber dot:         #f59e0b
   Blue dot:          #3b82f6
   Green:             #10b981
   Red:               #ef4444
   Label / tag bg:    #f3f4f6
   ----------------------------- */

/* ==========================================================
   1. BASE STYLES
   ========================================================== */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: #f4f5f7;
  color: #1e293b;
  -webkit-font-smoothing: antialiased;
}

.container {
  font-size: 13px;
  line-height: 1.5;
}

/* ==========================================================
   2. NAVBAR OVERRIDES
   ========================================================== */
.navbar,
.nav-bar {
  background: #1e293b !important;
  height: 48px;
  padding: 0 24px;
}

.navbar .nav-link,
.nav-bar .nav-link {
  color: #94a3b8;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.15s;
}

.navbar .nav-link:hover,
.nav-bar .nav-link:hover {
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
}

.navbar .nav-link.active,
.nav-bar .nav-link.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  font-weight: 500;
  text-decoration: none;
}

.navbar-brand,
.nav-brand {
  color: #fff !important;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  text-decoration: none;
}

/* ==========================================================
   3. BUTTON OVERRIDES
   ========================================================== */
.btn {
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  padding: 6px 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.btn svg {
  width: 14px;
  height: 14px;
}

.btn-primary {
  --bs-btn-bg: #1e293b;
  --bs-btn-border-color: #1e293b;
  --bs-btn-color: #fff;
  --bs-btn-hover-bg: #334155;
  --bs-btn-hover-border-color: #334155;
  --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: #334155;
  --bs-btn-active-border-color: #334155;
  --bs-btn-active-color: #fff;
  --bs-btn-disabled-bg: #1e293b;
  --bs-btn-disabled-border-color: #1e293b;
  --bs-btn-disabled-color: #fff;
  background-color: #1e293b;
  border-color: #1e293b;
  color: #fff;
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: #334155 !important;
  border-color: #334155 !important;
  color: #fff !important;
}

.btn-outline-secondary {
  border-color: #d1d5db;
  color: #374151;
}

.btn-outline-secondary:hover {
  border-color: #9ca3af;
  background: #f9fafb;
  color: #374151;
}

/* ==========================================================
   4. FORM OVERRIDES
   ========================================================== */
.form-control,
.form-select {
  font-size: 13px;
  border-radius: 6px;
  border-color: #d1d5db;
  color: #1e293b;
}

.form-control {
  padding: 7px 12px;
}

.form-select {
  padding: 7px 36px 7px 12px;
}

.form-control:focus,
.form-select:focus {
  border-color: #6b7280;
  box-shadow: none;
}

.form-control::placeholder {
  color: #9ca3af;
}

/* ==========================================================
   5. TABLE – .table-portal
   ========================================================== */
.table-portal {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
}

.table-portal thead th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  font-weight: 500;
  padding: 10px 14px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  background: #fafbfc;
}

.table-portal thead th.r {
  text-align: right;
}

.table-portal tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
  font-size: 13px;
}

.table-portal tbody tr:last-child td {
  border-bottom: none;
}

.table-portal tbody tr:hover {
  background: #f8fafc;
}

.meta {
  color: #9ca3af;
  font-size: 12px;
}

.order-link {
  font-weight: 600;
  color: #1e293b;
  text-decoration: none;
}

.order-link:hover {
  color: #3b82f6;
}

/* ==========================================================
   6. KPI PILLS
   ========================================================== */
.kpi-row {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.kpi-pill {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: #fff;
  color: #6b7280;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}

.kpi-pill:hover {
  border-color: #9ca3af;
  color: #374151;
  text-decoration: none;
}

.kpi-pill.active {
  background: #1e293b;
  color: #fff;
  border-color: #1e293b;
}

.kpi-pill .num {
  font-weight: 700;
  margin-left: 5px;
}

/* ==========================================================
   7. PROGRESS BAR
   ========================================================== */
.progress-wrap {
  position: relative;
  display: inline-flex;
  cursor: default;
}

.progress-bar-mini {
  display: flex;
  gap: 3px;
  align-items: center;
}

.progress-bar-mini .step {
  width: 22px;
  height: 4px;
  border-radius: 2px;
  background: #e5e7eb;
  transition: background 0.15s;
}

.progress-bar-mini .step.done {
  background: #10b981;
}

.progress-bar-mini .step.current {
  background: #3b82f6;
}

/* ==========================================================
   8. PROGRESS TOOLTIP
   ========================================================== */
.progress-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  line-height: 1.7;
  white-space: nowrap;
  z-index: 1050;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  pointer-events: none;
}

/* Arrow pointing down (default: tooltip above) */
.progress-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1e293b;
}

/* Flip tooltip below the bar */
.progress-wrap.tooltip-below .progress-tooltip {
  bottom: auto;
  top: calc(100% + 10px);
}

.progress-wrap.tooltip-below .progress-tooltip::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: #1e293b;
}

.progress-wrap:hover .progress-tooltip {
  display: block;
}

.tt-step {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tt-icon {
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  font-size: 12px;
}

.tt-icon.done    { color: #10b981; }
.tt-icon.current { color: #3b82f6; }
.tt-icon.pending { color: #4b5563; }

.tt-label         { color: #e2e8f0; }
.tt-label.done    { color: #6ee7b7; }
.tt-label.current { color: #93c5fd; font-weight: 500; }
.tt-label.pending { color: #6b7280; }

.tt-detail {
  color: #64748b;
  margin-left: 2px;
}

/* ==========================================================
   9. NEXT STEP
   ========================================================== */
.next-step {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: #6b7280;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-yellow { background: #f59e0b; }
.dot-blue   { background: #3b82f6; }
.dot-green  { background: #10b981; }
.dot-red    { background: #ef4444; }

.next-label {
  background: #f3f4f6;
  padding: 2px 9px;
  border-radius: 4px;
  font-weight: 500;
  color: #374151;
}

/* ==========================================================
   10. TAG (neutral inline label)
   ========================================================== */
.tag,
.order-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  color: #6b7280;
  background: #f3f4f6;
  padding: 2px 8px;
  border-radius: 4px;
  vertical-align: middle;
}

.order-tag {
  margin-left: 6px;
}

/* ==========================================================
   11. AMOUNT
   ========================================================== */
.amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.amount-pos  { color: #10b981; }
.amount-neg  { color: #ef4444; }
.amount-zero { color: #9ca3af; font-weight: 400; }

/* ==========================================================
   12. ICON BUTTON
   ========================================================== */
.btn-icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 4px;
  color: #9ca3af;
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
}

.btn-icon:hover {
  background: #f3f4f6;
  color: #6b7280;
}

.btn-icon svg {
  width: 14px;
  height: 14px;
}

/* ==========================================================
   13. PAGE HEADER
   ========================================================== */
.page-header-portal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-header-portal .page-title {
  font-size: 18px;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
}

.page-header-portal .header-actions {
  display: flex;
  gap: 8px;
}

/* ==========================================================
   14. TOOLBAR
   ========================================================== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 7px 12px 7px 34px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  color: #1e293b;
  outline: none;
  transition: border-color 0.15s;
}

.search-box input:focus {
  border-color: #6b7280;
}

.search-box input::placeholder {
  color: #9ca3af;
}

.search-box .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  pointer-events: none;
}

.toolbar-sep {
  width: 1px;
  height: 24px;
  background: #e5e7eb;
}

.toolbar-meta {
  font-size: 12px;
  color: #9ca3af;
  margin-left: auto;
}

/* ==========================================================
   15. TABLE WRAP & PAGINATION
   ========================================================== */
.table-wrap {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: visible;
}

/* Round corners on first/last rows since overflow is visible */
.table-wrap .table-portal thead th:first-child { border-top-left-radius: 8px; }
.table-wrap .table-portal thead th:last-child { border-top-right-radius: 8px; }

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-top: 1px solid #f3f4f6;
  background: #fafbfc;
}

.table-pagination .page-info {
  font-size: 12px;
  color: #9ca3af;
}

.table-pagination .page-links {
  display: flex;
  gap: 2px;
}

.page-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 12px;
  color: #6b7280;
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
  transition: all 0.15s;
}

.page-btn:hover {
  background: #e5e7eb;
}

.page-btn.active {
  background: #1e293b;
  color: #fff;
}

/* ==========================================================
   16. TEMP INFO BOX
   ========================================================== */
.alert-portal {
  background: #fafbfc;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px 18px;
  font-size: 12px;
  color: #6b7280;
  line-height: 1.6;
  margin-bottom: 16px;
}

/* ==========================================================
   17. SHARED: PAGE HEADER (used on all pages)
   ========================================================== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.page-header .page-title {
  font-size: 18px;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
}

.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ==========================================================
   18. SHARED: CARDS
   ========================================================== */
.card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: none;
}

.card-header {
  background: #fafbfc;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 600;
  font-size: 13px;
  padding: 10px 16px;
}

.card-body {
  padding: 16px;
}

/* ==========================================================
   19. SHARED: BOOTSTRAP TABLES (table-striped, table-compact)
   ========================================================== */
.table {
  font-size: 13px;
  color: #1e293b;
}

.table thead th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  font-weight: 500;
  border-bottom: 1px solid #e5e7eb;
  background: #fafbfc;
  white-space: nowrap;
  padding: 10px 14px;
}

.table tbody td {
  padding: 10px 14px;
  vertical-align: middle;
  border-bottom: 1px solid #f3f4f6;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: rgba(248, 250, 252, 0.5);
  --bs-table-bg-type: rgba(248, 250, 252, 0.5);
}

.table tbody tr:hover {
  background: #f8fafc;
}

.table.table-compact > :not(caption) > * > * {
  padding-top: 7px;
  padding-bottom: 7px;
}

.table tfoot td {
  font-weight: 600;
  border-top: 1px solid #e5e7eb;
}

/* ==========================================================
   20. SHARED: BADGES
   ========================================================== */
.badge {
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.02em;
  border-radius: 4px;
}

.badge-status {
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-weight: 600;
}

.badge.text-bg-success {
  background-color: #10b981 !important;
  color: #fff !important;
}

.badge.text-bg-warning {
  background-color: #f59e0b !important;
  color: #fff !important;
}

.badge.text-bg-info {
  background-color: #3b82f6 !important;
  color: #fff !important;
}

.badge.text-bg-primary {
  background-color: #1e293b !important;
  color: #fff !important;
}

.badge.text-bg-secondary {
  background-color: #e5e7eb !important;
  color: #374151 !important;
}

.badge.text-bg-danger {
  background-color: #ef4444 !important;
  color: #fff !important;
}

/* ==========================================================
   21. SHARED: TABS
   ========================================================== */
.nav-tabs {
  border-bottom: 1px solid #e5e7eb;
}

.nav-tabs .nav-link {
  font-weight: 500;
  font-size: 13px;
  color: #6b7280;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 16px;
  border-radius: 0;
  transition: all 0.15s;
}

.nav-tabs .nav-link:hover {
  color: #374151;
  border-bottom-color: #d1d5db;
  background: none;
}

.nav-tabs .nav-link.active {
  color: #1e293b;
  font-weight: 600;
  border-bottom-color: #1e293b;
  background: none;
}

/* ==========================================================
   22. SHARED: ACCORDIONS
   ========================================================== */
.accordion-item {
  border: 1px solid #e5e7eb;
  border-radius: 8px !important;
  overflow: hidden;
}

.accordion-item + .accordion-item {
  margin-top: 8px;
}

.accordion-button {
  font-weight: 600;
  font-size: 13px;
  padding: 10px 16px;
  color: #374151;
  background: #fff;
  box-shadow: none;
}

.accordion-button:not(.collapsed) {
  background: #fafbfc;
  color: #1e293b;
  box-shadow: none;
}

.accordion-button:focus {
  box-shadow: none;
  border-color: #e5e7eb;
}

.accordion-body {
  background: #fff;
  font-size: 13px;
  padding: 16px;
}

/* ==========================================================
   23. SHARED: ALERTS
   ========================================================== */
.alert {
  font-size: 13px;
  border-radius: 8px;
  padding: 12px 16px;
}

.alert-info {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}

.alert-success {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

.alert-warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.alert-danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

/* ==========================================================
   24. SHARED: SECTION HELPERS
   ========================================================== */
.section-muted {
  color: #9ca3af;
  font-size: 12px;
}

.section-actions {
  padding: 10px 16px;
  background: #fafbfc;
  border-top: 1px solid #f3f4f6;
}

/* ==========================================================
   25. SHARED: CHECKBOX STYLING
   ========================================================== */
input[type="checkbox"] {
  width: 15px;
  height: 15px;
  border-radius: 3px;
  accent-color: #1e293b;
  cursor: pointer;
}

/* ==========================================================
   26. SHARED: MODAL OVERRIDES
   ========================================================== */
.modal-content {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.modal-header {
  border-bottom: 1px solid #f3f4f6;
  padding: 16px 20px;
}

.modal-header .modal-title {
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  border-top: 1px solid #f3f4f6;
  padding: 12px 20px;
}

.form-label {
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
  margin-bottom: 4px;
}

/* ==========================================================
   27. STATS KPI ROW
   ========================================================== */
.stats-kpi-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.stats-kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 20px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  min-width: 160px;
}

.stats-kpi-label {
  font-size: 11px;
  font-weight: 500;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stats-kpi-value {
  font-size: 18px;
  font-weight: 700;
  color: #1e293b;
}

.stats-kpi-sub {
  font-size: 13px;
  font-weight: 600;
  color: #10b981;
}

.stats-kpi-highlight {
  border-color: #d1fae5;
  background: #f0fdf4;
}

.stats-sync-info {
  font-size: 12px;
  color: #9ca3af;
}
