/* ============================================================
   Payment Manager - Custom Stylesheet
   Bootstrap 5 + Custom Components
   ============================================================ */

:root {
  --sidebar-width: 260px;
  --sidebar-bg: #1e2139;
  --sidebar-text: #c0c4d6;
  --sidebar-hover: rgba(255,255,255,0.08);
  --sidebar-active: #0d6efd;
  --topbar-height: 58px;
  --primary: #0d6efd;
  --success: #198754;
  --danger: #dc3545;
  --warning: #ffc107;
  --info: #0dcaf0;
  --teal: #20c997;
  --orange: #fd7e14;
  --font-main: 'Inter', sans-serif;
}

/* ============================================================
   GLOBAL
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-main);
  background: #f4f6fb;
  color: #2d3436;
  min-height: 100vh;
  overflow-x: hidden;
}

a { text-decoration: none; }
a:hover { text-decoration: none; }

.font-monospace { font-family: 'Courier New', monospace; font-size: 0.8rem; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: 1050;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.3s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

/* Brand */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.2rem 0.8rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.3px;
}
.sidebar-brand i { color: var(--primary); font-size: 1.2rem; }
.sidebar-close { color: var(--sidebar-text); padding: 0.25rem; }

/* User info */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.sidebar-user .user-avatar { color: rgba(255,255,255,0.5); }
.sidebar-user .user-name { display: block; font-size: 0.875rem; font-weight: 600; color: #fff; line-height: 1.2; }
.sidebar-user .user-role { font-size: 0.65rem; }

/* Nav */
.sidebar-menu { flex: 1; padding: 0.5rem 0 1rem; }

.sidebar-menu .nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 1.2rem;
  color: var(--sidebar-text);
  border-radius: 0;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.sidebar-menu .nav-link i:first-child { width: 18px; text-align: center; flex-shrink: 0; }
.sidebar-menu .nav-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}
.sidebar-menu .nav-link.active {
  background: rgba(13,110,253,0.18);
  color: #74b3ff;
  font-weight: 600;
}
.sidebar-menu .nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}
.caret { font-size: 0.65rem; transition: transform 0.2s; }
.nav-link[aria-expanded="true"] .caret { transform: rotate(180deg); }

/* Sub-menu */
.sub-menu {
  background: rgba(0,0,0,0.15);
  border-left: 2px solid rgba(255,255,255,0.08);
  margin-left: 1.2rem;
  margin-right: 0.6rem;
  border-radius: 0 0 4px 4px;
}
.sub-menu .nav-link {
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
  gap: 0.55rem;
}
.sub-menu .nav-link i { font-size: 0.75rem; width: 14px; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s ease;
}

/* Top Navbar */
.top-navbar {
  background: #fff;
  border-bottom: 1px solid #e9ecef;
  height: var(--topbar-height);
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 1040;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.sidebar-toggle { color: #555; border: none; background: none; }
.sidebar-toggle:hover { color: var(--primary); }

/* Page Content */
.page-content {
  flex: 1;
  padding: 1.5rem;
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card {
  background: #fff;
  border-radius: 0.75rem;
  padding: 1.1rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  overflow: hidden;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.1); }
.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.stat-body { flex: 1; min-width: 0; }
.stat-value { font-size: 1.35rem; font-weight: 700; line-height: 1.2; color: #1a1a2e; }
.stat-label { font-size: 0.78rem; color: #6c757d; font-weight: 500; margin-top: 2px; }
.stat-link { position: absolute; inset: 0; }

/* Teal and Orange custom colors */
.text-teal { color: var(--teal) !important; }
.text-orange { color: var(--orange) !important; }
.bg-teal-subtle { background-color: rgba(32,201,151,0.15) !important; }
.bg-orange-subtle { background-color: rgba(253,126,20,0.15) !important; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  border-radius: 0.65rem;
}
.card-header {
  border-radius: 0.65rem 0.65rem 0 0 !important;
  font-size: 0.9rem;
}

/* ============================================================
   TABLES
   ============================================================ */
.table thead th {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
  padding: 0.7rem 0.75rem;
}
.table tbody td { font-size: 0.85rem; padding: 0.6rem 0.75rem; }
.table-hover tbody tr:hover { background-color: rgba(13,110,253,0.04); }

/* Row highlight for receive/send */
.table-success-subtle td { background-color: rgba(25,135,84,0.04) !important; }
.table-danger-subtle td  { background-color: rgba(220,53,69,0.04)  !important; }

/* ============================================================
   CHARTS
   ============================================================ */
.chart-container {
  position: relative;
  height: 220px;
}

/* ============================================================
   RECEIPT / FILE UPLOAD DROP ZONE
   ============================================================ */
.upload-zone {
  border: 2.5px dashed #ced4da;
  border-radius: 0.75rem;
  padding: 3rem 1rem;
  text-align: center;
  background: #fafbfd;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--primary);
  background: rgba(13,110,253,0.04);
}
.upload-zone .upload-icon { font-size: 2.5rem; color: #adb5bd; margin-bottom: 0.75rem; }
.upload-zone.drag-over .upload-icon { color: var(--primary); }
.upload-zone .upload-title { font-weight: 600; color: #495057; }
.upload-zone .upload-sub { font-size: 0.82rem; color: #6c757d; margin-top: 0.25rem; }

/* Image Preview */
.receipt-preview {
  max-width: 100%;
  max-height: 280px;
  border-radius: 0.5rem;
  border: 1px solid #dee2e6;
  object-fit: contain;
  margin-top: 1rem;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-label { font-weight: 500; font-size: 0.875rem; color: #344054; }
.form-control, .form-select {
  border-color: #d0d5dd;
  border-radius: 0.45rem;
  font-size: 0.875rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,110,253,0.15);
}
.input-group-text { border-color: #d0d5dd; background: #f8f9fa; font-size: 0.875rem; }

/* ============================================================
   BADGES
   ============================================================ */
.badge { font-weight: 500; letter-spacing: 0.2px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn { border-radius: 0.45rem; font-weight: 500; font-size: 0.875rem; }
.btn-sm { font-size: 0.78rem; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination .page-link { font-size: 0.82rem; border-radius: 0.35rem; margin: 0 2px; }

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.7);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   SIDEBAR OVERLAY (Mobile)
   ============================================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1049;
}

/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 2px 0 20px rgba(0,0,0,0.3);
  }
  .sidebar.show {
    transform: translateX(0);
  }
  .sidebar-overlay.show {
    display: block;
  }
  .main-content {
    margin-left: 0 !important;
  }
  .page-content {
    padding: 1rem;
  }
  .stat-value { font-size: 1.1rem; }
}

@media (max-width: 575.98px) {
  .top-navbar { padding: 0 0.75rem; }
  .page-content { padding: 0.75rem; }
  .stat-card { padding: 0.8rem; gap: 0.65rem; }
  .stat-icon { width: 42px; height: 42px; font-size: 1.1rem; }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
  .sidebar, .top-navbar, .sidebar-overlay,
  .no-print, .btn, .pagination, nav {
    display: none !important;
  }
  .main-content { margin-left: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #dee2e6 !important; }
  body { background: #fff; }
  .page-content { padding: 0; }
  .table thead th { background: #f8f9fa !important; color: #000 !important; }
}

/* ============================================================
   LEDGER TABLE
   ============================================================ */
.ledger-table th { background: #1e2139; color: #fff; }
.ledger-table .running-balance { font-weight: 700; }
.ledger-credit { color: var(--success); font-weight: 600; }
.ledger-debit  { color: var(--danger);  font-weight: 600; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert { border-radius: 0.5rem; font-size: 0.875rem; }

/* ============================================================
   COMMISSION SETTINGS
   ============================================================ */
.commission-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(255,193,7,0.15);
  color: #856404;
  border-radius: 20px;
  padding: 0.2rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
}

/* ============================================================
   DUPLICATE WARNING
   ============================================================ */
.duplicate-warning {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 0.5rem;
  padding: 1rem;
}
.duplicate-warning h6 { color: #856404; }

/* ============================================================
   REPORT CARDS
   ============================================================ */
.report-card {
  background: #fff;
  border-radius: 0.75rem;
  padding: 1.5rem;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
  border: 2px solid transparent;
}
.report-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  border-color: var(--primary);
}
.report-card .report-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.report-card h6 { font-weight: 700; margin-bottom: 0.25rem; }
.report-card p { font-size: 0.8rem; color: #6c757d; margin: 0; }

/* ============================================================
   APPROVE BUTTON
   ============================================================ */
.btn-approve {
  background: #198754;
  border-color: #198754;
  color: #fff;
  font-weight: 600;
}
.btn-approve:hover {
  background: #146c43;
  color: #fff;
}

/* ============================================================
   ACTIONS COLUMN — prevent wrapping on small screens
   ============================================================ */
td.actions-col, th.actions-col {
    white-space: nowrap;
    min-width: 150px;
}

/* ============================================================
   SLIP CARD OCR BORDER HIGHLIGHT
   ============================================================ */
.card.border-success { border: 2px solid #198754 !important; }
.card.border-danger  { border: 2px solid #dc3545 !important; }
.border-success input, .border-success select { border-color: #198754 !important; }

/* ============================================================
   BULK UPLOAD DROP ZONE COMPACT
   ============================================================ */
#bulkDropZone { padding: 1.5rem 1rem; }

/* ============================================================
   STATUS BADGES — larger for approve flow
   ============================================================ */
.badge.fs-6 { padding: 0.4em 0.75em; }

/* ============================================================
   SLIP CARD OCR AUTO-FILL HIGHLIGHT
   ============================================================ */
.border-success.form-control,
.border-success.form-select {
  border-color: #198754 !important;
  background-color: rgba(25,135,84,0.04) !important;
}

/* ============================================================
   TABLE ACTION BUTTONS — consistent sizing
   ============================================================ */
.table .btn-sm {
  padding: 0.2rem 0.45rem;
  font-size: 0.75rem;
}

/* ============================================================
   BULK RECEIPT UPLOAD — Receipt Cards
   ============================================================ */

/* Card hover lift */
.receipt-card {
    transition: box-shadow 0.2s, border-color 0.2s;
}
.receipt-card:hover {
    box-shadow: 0 6px 24px rgba(0,0,0,0.10) !important;
}

/* OCR spark indicator (magic wand) */
.ocr-spark {
    background: rgba(25,135,84,0.08);
    border-color: #c3e6cb;
    padding: 0 6px;
    cursor: default;
}

/* OCR badge on card header */
.ocr-badge {
    font-size: 0.72rem;
    border: 1px solid #c3e6cb;
    background: rgba(25,135,84,0.08) !important;
    color: #146c43 !important;
}

/* Collapse icon transition */
.collapse-icon {
    transition: transform 0.2s;
    font-size: 0.72rem;
}

/* Save sticky bar */
#saveBar .card {
    border-top: 3px solid #198754 !important;
    border-radius: 0 !important;
}

/* Success border on OCR-filled inputs */
.border-success.form-control,
.border-success.form-select {
    border-color: #198754 !important;
    background-color: rgba(25,135,84,0.04) !important;
}

/* Queue progress label */
#queueLabel { font-size: 0.82rem; }

/* Receipt card header cursor */
.receipt-card .card-header { user-select: none; }

/* Bulk drop zone — larger */
#bulkDropZone { min-height: 180px; }

/* Preview image hover overlay */
.receipt-card img {
    transition: opacity 0.15s;
}
.receipt-card img:hover { opacity: 0.85; }

/* Toast container fix */
.toast-container { pointer-events: none; }
.toast-container .toast { pointer-events: all; }

/* Save bar z-index over sticky table headers */
#saveBar { z-index: 1029; }
