/* ============================================================
   SPM LIGHT THEME - Clean Modern UI
   ============================================================ */

:root {
  --primary:       #2563eb;
  --primary-light: #eff6ff;
  --primary-dark:  #1d4ed8;
  --secondary:     #64748b;
  --success:       #16a34a;
  --success-light: #f0fdf4;
  --warning:       #d97706;
  --warning-light: #fffbeb;
  --danger:        #dc2626;
  --danger-light:  #fef2f2;
  --info:          #0891b2;
  --info-light:    #ecfeff;

  --bg:            #f1f5f9;
  --surface:       #ffffff;
  --surface2:      #f8fafc;
  --border:        #e2e8f0;
  --border-light:  #f1f5f9;

  --text:          #0f172a;
  --text-muted:    #64748b;
  --text-light:    #94a3b8;

  --sidebar-w:     260px;
  --topbar-h:      64px;
  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:     0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg:     0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.05);
  --transition:    0.18s ease;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; }
body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ============================================================
   LAYOUT WRAPPER
   ============================================================ */
#wrapper {
  display: flex;
  min-height: 100vh;
}
#content-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-left: var(--sidebar-w);
  transition: margin-left var(--transition);
}
#content { flex: 1; padding: 0; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--transition), transform var(--transition);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-light);
  text-decoration: none;
  flex-shrink: 0;
}
.sidebar-brand-logo {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand-logo img { width: 24px; height: 24px; object-fit: contain; filter: brightness(0) invert(1); }
.sidebar-brand-text { font-weight: 700; font-size: 15px; color: var(--text); line-height: 1.2; }
.sidebar-brand-text small { display: block; font-size: 11px; font-weight: 500; color: var(--text-muted); }

/* Nav Section Labels */
.sidebar-section-label {
  padding: 14px 20px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--text-light);
}

/* Nav Items */
.sidebar-nav { padding: 8px 12px; flex: 1; }
.sidebar-nav .nav-item { margin-bottom: 2px; }

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13.5px;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.sidebar-nav .nav-link:hover {
  background: var(--primary-light);
  color: var(--primary);
}
.sidebar-nav .nav-item.active > .nav-link,
.sidebar-nav .nav-link.active {
  background: var(--primary-light);
  color: var(--primary);
}
.sidebar-nav .nav-link i {
  width: 18px; text-align: center; font-size: 14px; flex-shrink: 0;
}

/* Collapse arrow */
.sidebar-nav .nav-link[data-bs-toggle="collapse"]::after {
  content: "\f107";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  margin-left: auto;
  transition: transform var(--transition);
  font-size: 11px;
}
.sidebar-nav .nav-link[data-bs-toggle="collapse"]:not(.collapsed)::after {
  transform: rotate(-180deg);
}

/* Submenu */
.sidebar-submenu {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 4px 0;
  margin-top: 2px;
}
.sidebar-submenu .nav-link {
  font-size: 13px;
  font-weight: 500;
  padding: 7px 12px 7px 38px;
}
.sidebar-submenu .nav-link.active,
.sidebar-submenu .nav-link:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* Toggled / collapsed sidebar */
body.sidebar-toggled .sidebar { width: 72px; }
body.sidebar-toggled .sidebar-brand-text,
body.sidebar-toggled .sidebar-section-label,
body.sidebar-toggled .nav-link span,
body.sidebar-toggled .nav-link::after { display: none; }
body.sidebar-toggled .sidebar-nav .nav-link { justify-content: center; padding: 10px; }
body.sidebar-toggled .sidebar-brand { justify-content: center; padding: 20px 8px 16px; }
body.sidebar-toggled #content-wrapper { margin-left: 72px; }

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky; top: 0; z-index: 1030;
  box-shadow: var(--shadow);
}
.topbar-toggle {
  background: none; border: none;
  color: var(--text-muted);
  padding: 6px 8px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 18px;
  transition: background var(--transition), color var(--transition);
}
.topbar-toggle:hover { background: var(--bg); color: var(--text); }

.topbar-title {
  font-weight: 700; font-size: 15px; color: var(--text);
}
.topbar-breadcrumb {
  font-size: 13px; color: var(--text-muted);
  display: flex; align-items: center; gap: 6px;
}
.topbar-breadcrumb span { color: var(--text-light); }

.topbar-right {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
}

/* Avatar / user dropdown */
.topbar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border-radius: var(--radius);
  cursor: pointer; border: 1px solid var(--border);
  background: var(--surface); transition: background var(--transition);
  text-decoration: none;
}
.topbar-user:hover { background: var(--bg); }
.topbar-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 12px;
  flex-shrink: 0;
}
.topbar-avatar img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.topbar-user-info { line-height: 1.2; }
.topbar-user-name { font-weight: 700; font-size: 13px; color: var(--text); }
.topbar-user-role { font-size: 11px; color: var(--text-muted); }

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.page-content { padding: 24px; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-title {
  font-size: 20px; font-weight: 700; color: var(--text); margin: 0;
}
.page-subtitle { font-size: 13px; color: var(--text-muted); margin: 2px 0 0; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 15px; font-weight: 700; color: var(--text); margin: 0; }
.card-body { padding: 20px; }
.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
}

/* Stat Cards */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
  text-decoration: none; color: inherit;
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  color: inherit;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-accent, var(--primary));
}
.stat-icon {
  width: 52px; height: 52px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
  background: var(--card-icon-bg, var(--primary-light));
  color: var(--card-icon-color, var(--primary));
}
.stat-body { min-width: 0; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1; margin-bottom: 2px; }
.stat-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }

/* Color variants for stat cards */
.stat-card.primary   { --card-accent: var(--primary); --card-icon-bg: var(--primary-light); --card-icon-color: var(--primary); }
.stat-card.success   { --card-accent: var(--success); --card-icon-bg: var(--success-light); --card-icon-color: var(--success); }
.stat-card.warning   { --card-accent: var(--warning); --card-icon-bg: var(--warning-light); --card-icon-color: var(--warning); }
.stat-card.danger    { --card-accent: var(--danger);  --card-icon-bg: var(--danger-light);  --card-icon-color: var(--danger); }
.stat-card.info      { --card-accent: var(--info);    --card-icon-bg: var(--info-light);    --card-icon-color: var(--info); }
.stat-card.secondary { --card-accent: #8b5cf6; --card-icon-bg: #f5f3ff; --card-icon-color: #8b5cf6; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.table-toolbar {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.table-responsive { overflow-x: auto; }
.table { margin: 0; width: 100%; border-collapse: collapse; }
.table thead th {
  padding: 12px 16px;
  background: var(--surface2);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  font-size: 13.5px;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg); }
.table-striped tbody tr:nth-of-type(odd) { background: var(--surface2); }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px; font-weight: 700;
  letter-spacing: .3px;
}
.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-completed { background: #d1fae5; color: #065f46; }
.badge-failed   { background: #fee2e2; color: #991b1b; }
.badge-rejected { background: #fce7f3; color: #9d174d; }
.badge-active   { background: #d1fae5; color: #065f46; }
.badge-inactive { background: #f1f5f9; color: var(--text-muted); }
.badge-primary  { background: var(--primary-light); color: var(--primary-dark); }
.badge-info     { background: var(--info-light); color: #155e75; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer; transition: all var(--transition);
  text-decoration: none; white-space: nowrap;
}
.btn:focus { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn-primary    { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-success    { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #15803d; color: #fff; }
.btn-danger     { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover  { background: #b91c1c; color: #fff; }
.btn-warning    { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-warning:hover { background: #b45309; color: #fff; }
.btn-info       { background: var(--info); color: #fff; border-color: var(--info); }
.btn-info:hover    { background: #0e7490; color: #fff; }
.btn-secondary  { background: var(--secondary); color: #fff; border-color: var(--secondary); }
.btn-light      { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-light:hover { background: var(--bg); }
.btn-outline-primary { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary-light); }
.btn-outline-secondary { background: transparent; color: var(--secondary); border-color: var(--border); }
.btn-outline-secondary:hover { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }

/* Action button group */
.action-btns { display: flex; gap: 4px; flex-wrap: wrap; }

/* ============================================================
   FORMS
   ============================================================ */
.form-label { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-control, .form-select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  line-height: 1.5;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
  outline: none;
}
.form-control::placeholder { color: var(--text-light); }
.form-text { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* Filter bar */
.filter-bar {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end;
  padding: 16px 20px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.filter-group { display: flex; flex-direction: column; min-width: 140px; }
.filter-group label { font-size: 11px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .4px; }
.filter-group .form-control, .filter-group .form-select { padding: 7px 10px; font-size: 13px; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 50%, #f8fafc 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  max-width: 900px;
  width: 100%;
  display: flex;
}
.login-illustration {
  flex: 1;
  background: linear-gradient(135deg, var(--primary) 0%, #1e40af 100%);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 48px 32px;
  text-align: center;
  min-height: 500px;
}
.login-illustration img { width: 100px; height: 100px; object-fit: contain; margin-bottom: 24px; filter: brightness(0) invert(1); }
.login-illustration h2 { color: #fff; font-size: 24px; font-weight: 800; margin: 0 0 8px; }
.login-illustration p { color: rgba(255,255,255,.75); font-size: 14px; margin: 0; }

.login-form-section { flex: 1; padding: 48px 40px; display: flex; flex-direction: column; justify-content: center; }
.login-form-section h1 { font-size: 26px; font-weight: 800; color: var(--text); margin: 0 0 4px; }
.login-form-section p { color: var(--text-muted); font-size: 14px; margin: 0 0 28px; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 10px; font-size: 13.5px;
  border: 1px solid transparent; margin-bottom: 16px;
}
.alert-success { background: var(--success-light); color: #065f46; border-color: #a7f3d0; }
.alert-danger   { background: var(--danger-light);  color: #991b1b; border-color: #fca5a5; }
.alert-warning  { background: var(--warning-light); color: #92400e; border-color: #fde68a; }
.alert-info     { background: var(--info-light);    color: #155e75; border-color: #a5f3fc; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-content { border-radius: var(--radius); border: none; box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--border); padding: 16px 20px; }
.modal-title { font-size: 15px; font-weight: 700; }
.modal-footer { border-top: 1px solid var(--border); padding: 14px 20px; }
.btn-close { opacity: .5; }
.btn-close:hover { opacity: 1; }

/* ============================================================
   REPORT SPECIFIC
   ============================================================ */
.report-filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.report-filters .row { --bs-gutter-x: 14px; }

.report-export-bar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}

/* Status dots */
.status-dot {
  display: inline-block;
  width: 7px; height: 7px; border-radius: 50%;
  margin-right: 5px;
}
.status-dot.pending  { background: var(--warning); }
.status-dot.completed { background: var(--success); }
.status-dot.failed   { background: var(--danger); }

/* Print styles */
@media print {
  .topbar, .sidebar, .page-header .btn, .filter-bar, .report-export-bar,
  .no-print { display: none !important; }
  #content-wrapper { margin-left: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; }
  .table { font-size: 11px; }
  body { background: #fff !important; }
}

/* ============================================================
   FOOTER
   ============================================================ */
.app-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 24px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-primary   { color: var(--primary) !important; }
.text-success   { color: var(--success) !important; }
.text-danger    { color: var(--danger)  !important; }
.text-warning   { color: var(--warning) !important; }
.text-muted-c   { color: var(--text-muted) !important; }
.bg-surface     { background: var(--surface) !important; }
.bg-light-c     { background: var(--bg) !important; }
.border-c       { border: 1px solid var(--border) !important; }
.rounded-c      { border-radius: var(--radius) !important; }
.shadow-c       { box-shadow: var(--shadow) !important; }
.fw-700         { font-weight: 700; }
.fw-600         { font-weight: 600; }
.gap-2c         { gap: 8px; }
.d-flex-center  { display: flex; align-items: center; gap: 8px; }

/* Scroll to top */
.scroll-to-top {
  position: fixed; right: 20px; bottom: 20px;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; box-shadow: var(--shadow-md);
  transition: background var(--transition), transform var(--transition);
  z-index: 1050;
}
.scroll-to-top:hover { background: var(--primary-dark); color: #fff; transform: translateY(-2px); }

/* Chart containers */
.chart-container { position: relative; min-height: 280px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991.98px) {
  #content-wrapper { margin-left: 0; }
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.show { transform: translateX(0); }
  .topbar-title { display: none; }
  body.sidebar-toggled .sidebar { transform: translateX(0); width: var(--sidebar-w); }
  body.sidebar-toggled #content-wrapper { margin-left: 0; }
  .login-illustration { display: none; }
  .login-form-section { padding: 32px 24px; }
}
@media (max-width: 575.98px) {
  .page-content { padding: 16px; }
  .stat-value { font-size: 22px; }
  .filter-bar { padding: 12px; }
  .table thead th, .table tbody td { padding: 10px 12px; }
}

/* ============================================================
   HIGHCHARTS LIGHT THEME GLOBAL OVERRIDES
   Ensures charts are always white/light regardless of page
   ============================================================ */
.highcharts-container { background: #ffffff !important; }
.highcharts-background { fill: #ffffff !important; }
.highcharts-plot-background { fill: #ffffff !important; }

.highcharts-axis-labels text { fill: #475569 !important; color: #475569 !important; }
.highcharts-axis-title text  { fill: #64748b !important; }
.highcharts-title text        { fill: #dc2626 !important; font-weight: 700 !important; }
.highcharts-subtitle text     { fill: #64748b !important; }

.highcharts-grid-line   { stroke: #e2e8f0 !important; }
.highcharts-tick        { stroke: #cbd5e1 !important; }
.highcharts-axis-line   { stroke: #cbd5e1 !important; }
.highcharts-minor-tick  { stroke: #f1f5f9 !important; }

.highcharts-tooltip-box { fill: #ffffff !important; stroke: #e2e8f0 !important; }
.highcharts-tooltip text { fill: #0f172a !important; }

.highcharts-legend-box  { fill: #ffffff !important; }
.highcharts-legend-item text { fill: #0f172a !important; color: #0f172a !important; }

/* Chart containers page-level */
#container, #container1 {
    background: #ffffff !important;
    border-radius: 10px;
    overflow: hidden;
}

/* sb-admin-2 override — remove any dark card backgrounds inherited */
.card-body { background-color: #ffffff !important; }
.card { background-color: #ffffff !important; }
