/* =========================================================
   Office ERP — Corporate Theme Design System
   Clean, professional business look (navy blue + white)
   Overrides AdminLTE/Bootstrap while keeping required classes
   ========================================================= */

:root {
  --erp-primary: #1d4ed8;
  --erp-primary-2: #2563eb;
  --erp-navy: #10254e;
  --erp-bg: #eef2f8;
  --erp-card-bg: #ffffff;
  --erp-ink: #1c2b45;
  --erp-muted: #5d6b85;
  --erp-line: #d9e1ec;
  --erp-radius: 10px;
  --erp-shadow: 0 1px 2px rgba(16, 37, 78, .05), 0 6px 16px -10px rgba(16, 37, 78, .12);
  --erp-shadow-lg: 0 14px 34px -16px rgba(16, 37, 78, .28);
}

html { font-size: 15px; }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--erp-bg);
  color: var(--erp-ink);
  letter-spacing: -0.004em;
}

h1, h2, h3, h4, h5, .display-*, .card-title {
  font-family: 'Inter', 'Segoe UI', sans-serif;
  letter-spacing: -0.01em;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c4cdda; border-radius: 9px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #9aa7ba; background-clip: padding-box; }

/* ---------- Navbar ---------- */
.app-header {
  background: var(--erp-card-bg) !important;
  border-bottom: 1px solid var(--erp-line) !important;
}
.app-header .nav-link { color: var(--erp-ink); border-radius: 8px; transition: .15s; }
.app-header .nav-link:hover { background: rgba(29, 78, 216, .07); color: var(--erp-primary); }
.navbar .date-chip {
  background: rgba(29, 78, 216, .08); color: var(--erp-primary);
  border-radius: 6px; padding: .32rem .8rem; font-size: .78rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: .4rem;
}
/* PWA install button */
.app-header #pwaInstallBtn { padding: .38rem .5rem; position: relative; }
.app-header #pwaInstallBtn img {
  width: 26px; height: 26px; object-fit: contain; border-radius: 6px; display: block;
  box-shadow: 0 1px 4px rgba(16, 37, 78, .28);
}
.app-header #pwaInstallBtn.pwa-ready::after {
  content: ''; position: absolute; top: 6px; right: 4px; width: 8px; height: 8px;
  border-radius: 50%; background: #22c55e; border: 2px solid #fff;
}
.avatar-circle {
  width: 34px; height: 34px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: .85rem;
  background: linear-gradient(135deg, var(--erp-navy), var(--erp-primary));
  box-shadow: 0 2px 6px rgba(29, 78, 216, .35);
}
.chat-badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px;
  border-radius: 999px; background: #dc2626; color: #fff;
  font-size: 10px; font-weight: 800; text-align: center;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .95);
}
.chat-badge.position-static { position: static; flex-shrink: 0; }

/* chat group list — keep text readable on light active bg (Bootstrap active = white on blue) */
.list-group-item.group-item { color: var(--erp-ink); }
.group-item.active,
.group-item.active:hover {
  color: var(--erp-ink) !important;
  background: rgba(99, 102, 241, .08) !important;
  border-left-color: #6366f1 !important;
  border-left-width: 3px !important;
}
.group-item.active small.text-muted,
.group-item.active small { color: #5d6b85 !important; }

/* ---------- Sidebar (dark corporate navy) ---------- */
.app-sidebar {
  background: linear-gradient(180deg, #0d1f42 0%, #132a56 100%) !important;
  border-right: 1px solid #0a1834;
}
.sidebar-brand {
  background: rgba(255, 255, 255, .05) !important;
  border-bottom: 1px solid rgba(255, 255, 255, .09) !important;
  padding-block: .55rem;
}
.app-sidebar .brand-text { color: #fff !important; font-weight: 800; font-size: .78rem; }
.sidebar-brand .brand-image { border-radius: 8px; box-shadow: 0 2px 8px rgba(0, 0, 0, .35) !important; opacity: 1 !important; }
.sidebar-brand .brand-link { align-items: center; }
.app-sidebar .sidebar-brand .brand-text {
  white-space: normal;
  line-height: 1.2;
  word-break: break-word;
  padding-right: .15rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sidebar-menu .nav-link {
  color: rgba(255, 255, 255, .75);
  border-radius: 8px;
  margin: 1px 8px;
  transition: all .15s;
  font-weight: 500;
  font-size: .865rem;
  padding-top: .36rem; padding-bottom: .36rem;
}
.sidebar-menu .nav-link:hover { color: #fff; background: rgba(255, 255, 255, .09); }
.sidebar-menu > .nav-item > .nav-link.active {
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  color: #fff;
  box-shadow: 0 4px 12px -4px rgba(37, 99, 235, .7);
}
.sidebar-menu .nav-icon { color: #8fa8dc !important; }
.sidebar-menu > .nav-item > .nav-link.active .nav-icon { color: #fff !important; }
.sidebar-menu > .nav-item > .nav-link > p { font-size: .865rem; }
.sidebar-menu .nav-treeview { background: rgba(0, 13, 36, .4) !important; border-radius: 8px; margin: 2px 8px; padding: 4px 0 !important; }
.sidebar-menu .nav-treeview .nav-link { font-size: .8rem; padding-top: .2rem; padding-bottom: .2rem; }
.sidebar-menu .nav-treeview .nav-link > p { font-size: .8rem; }
.sidebar-menu .nav-treeview .nav-link i.nav-icon { font-size: .45rem !important; color: #7aa0f0 !important; }
.nav-arrow { transition: transform .2s; }
.menu-open > .nav-link .nav-arrow { transform: rotate(90deg); }

/* compact (mini) sidebar — AdminLTE v4 class names */
.sidebar-mini.sidebar-collapse .sidebar-menu .nav-link { margin: 4px 10px; }
.sidebar-mini.sidebar-collapse .sidebar-menu .nav-treeview { margin: 2px 8px; }

/* ---------- Forms (corporate) ---------- */
.form-control, .form-select {
  border-radius: 8px;
  border-color: #ccd7e6;
  padding: .5rem .8rem;
  font-size: .92rem;
  background-color: #fff;
  box-shadow: inset 0 1px 2px rgba(16, 37, 78, .04);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--erp-primary);
  box-shadow: 0 0 0 .18rem rgba(29, 78, 216, .14);
  background-color: #fff;
}
.form-control::placeholder { color: #9aa8c0; }
.form-label { font-weight: 600; font-size: .82rem; color: #42536e; margin-bottom: .3rem; }
.form-control[readonly] { background: #f7f9fc; }

/* custom select arrow */
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%235d6b85' viewBox='0 0 16 16'><path d='M8 11 3 6h10z'/></svg>");
  background-repeat: no-repeat;
  background-position: right .7rem center;
  background-size: 14px 14px;
  padding-right: 2.2rem;
}
.form-select-sm { background-size: 12px 12px; padding-right: 1.9rem; }

/* checkboxes & radios */
input[type="checkbox"].form-check-input, input[type="radio"].form-check-input,
.form-check-input { border-radius: .28em; border-color: #b9c6d8; width: 1.05em; height: 1.05em; }
.form-check-input:checked { background-color: var(--erp-primary); border-color: var(--erp-primary); }
.form-check-input:focus { box-shadow: 0 0 0 .18rem rgba(29, 78, 216, .14); }
.form-check-label { font-size: .9rem; }

/* input groups */
.input-group-text { border-radius: 8px 0 0 8px; background: #f4f7fc; border-color: #ccd7e6; color: #42608c; font-weight: 600; font-size: .84rem; }
.input-group > :not(:first-child):not(.dropdown-menu):not(.valid-tooltip):not(.invalid-tooltip):not(.invalid-feedback) { border-radius: 0 8px 8px 0; }

/* ---------- Flatpickr calendar (corporate) ---------- */
.flatpickr-calendar {
  border: 1px solid var(--erp-line);
  border-radius: 12px;
  box-shadow: var(--erp-shadow-lg);
  background: #fff;
  padding: 6px;
  width: 300px;
}
.flatpickr-calendar.arrowTop:before { border-bottom-color: var(--erp-line); }
.flatpickr-calendar.arrowTop:after { border-bottom-color: #fff; }
.flatpickr-months .flatpickr-month { color: var(--erp-navy); }
.flatpickr-current-month .cur-month, .flatpickr-current-month input.cur-year { font-weight: 800; color: var(--erp-navy); }
.flatpickr-current-month input.cur-year { border-bottom-color: var(--erp-primary); }
.flatpickr-weekday { color: var(--erp-muted); font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.flatpickr-day {
  border-radius: 8px;
  color: #33415c;
  line-height: 34px;
  height: 34px; max-width: 34px;
  transition: .12s;
  font-weight: 500;
}
.flatpickr-day:hover { background: rgba(29, 78, 216, .08); }
.flatpickr-day.selected, .flatpickr-day.selected:hover {
  background: var(--erp-primary) !important;
  border-color: var(--erp-primary) !important;
  color: #fff !important;
  box-shadow: 0 2px 8px -2px rgba(29, 78, 216, .6);
}
.flatpickr-day.today { border-color: var(--erp-primary); color: var(--erp-primary); font-weight: 700; }
.flatpickr-day.today.selected { color: #fff; }
.flatpickr-day.flatpickr-disabled, .flatpickr-day.prevMonthDay, .flatpickr-day.nextMonthDay { color: #c3cddc; }
.flatpickr-day.weekend { color: #1d4ed8; }
.flatpickr-day.weekend.prevMonthDay, .flatpickr-day.weekend.nextMonthDay { color: #b9c6d8; }
.flatpickr-day.weekend.selected { color: #fff; }
.flatpickr-months .flatpickr-prev-month:hover svg, .flatpickr-months .flatpickr-next-month:hover svg { fill: var(--erp-primary); }
.flatpickr-innerContainer, .flatpickr-rContainer { padding: 0; }
.flatpickr-weekdays { padding: 6px 0 4px; }
.dayContainer { padding: 0; min-width: 280px; max-width: 280px; }
.flatpickr-time input:hover, .flatpickr-time input:focus { background: rgba(29, 78, 216, .05); }
.flatpickr-time .numInputWrapper span.arrowUp:after { border-bottom-color: var(--erp-primary); }
.flatpickr-time .numInputWrapper span.arrowDown:after { border-top-color: var(--erp-primary); }
.flatpickr-months .flatpickr-monthSelect-dropdown, .flatpickr-monthSelect-month { border-radius: 8px; transition: .12s; }
.flatpickr-monthSelect-month:hover { background: rgba(29, 78, 216, .08); }
.flatpickr-monthSelect-month.selected { background: var(--erp-primary) !important; color: #fff !important; box-shadow: 0 2px 8px -2px rgba(29, 78, 216, .6); }
.flatpickr-input, input.flatpickr-input { cursor: pointer; }

/* ---------- Content & page header ---------- */
.content-wrapper { background: transparent; padding-bottom: 1.5rem; }
.content-header h1 {
  font-weight: 800; font-size: 1.4rem; color: var(--erp-ink);
}
.content-header h1 i { color: var(--erp-primary); }
.breadcrumb { font-size: .8rem; }
.breadcrumb-item.active { color: var(--erp-muted); }

/* ---------- Cards ---------- */
.card {
  border: 1px solid var(--erp-line);
  border-radius: var(--erp-radius);
  box-shadow: var(--erp-shadow);
  background: var(--erp-card-bg);
}
.card-header {
  border-bottom: 1px solid var(--erp-line);
  background: #fbfcfe;
  border-radius: var(--erp-radius) var(--erp-radius) 0 0 !important;
  padding: .85rem 1.15rem;
}
.card-header .card-title { font-weight: 700; font-size: 1rem; }
.card-body { padding: 1.15rem; }

/* ---------- Stat boxes (flat corporate tiles) ---------- */
.small-box,
.info-box {
  border-radius: var(--erp-radius);
  overflow: hidden;
  border: 0;
  box-shadow: var(--erp-shadow);
  position: relative;
  transition: transform .15s, box-shadow .15s;
}
.small-box:hover, .info-box:hover { transform: translateY(-2px); box-shadow: var(--erp-shadow-lg); }
.small-box { padding-bottom: 2px; position: relative; }
.small-box::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: rgba(0, 0, 0, .16);
}
.small-box .inner { padding: 1.1rem 1.25rem 1.6rem; }
.small-box h3 { font-weight: 800; font-size: 1.7rem; letter-spacing: -0.02em; }
.small-box p { font-weight: 600; opacity: .92; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.small-box .icon { font-size: 3rem; top: 14px; right: 14px; opacity: .28; filter: none; }
.small-box-footer {
  background: rgba(0, 0, 0, .12) !important;
  color: #fff;
  font-size: .75rem;
  letter-spacing: .02em;
  display: flex; align-items: center; justify-content: center; gap: .4rem;
  transition: background .15s;
}
.small-box-footer:hover { background: rgba(0, 0, 0, .2) !important; color: #fff; }

/* flat corporate tiles */
.text-bg-primary  { background: #1d4ed8 !important; }
.text-bg-success  { background: #059669 !important; }
.text-bg-danger   { background: #dc2626 !important; }
.text-bg-warning  { background: #d97706 !important; color: #fff !important; }
.text-bg-info     { background: #0284c7 !important; }
.text-bg-secondary{ background: #475569 !important; }

.info-box { min-height: 86px; padding: .8rem 1rem; color: #fff !important; align-items: center; }
.info-box .info-box-icon {
  border-radius: 8px;
  background: rgba(255, 255, 255, .18) !important;
  color: #fff !important;
  font-size: 1.4rem;
  display: flex; align-items: center; justify-content: center;
}
.info-box .info-box-number { font-weight: 800; }
.info-box .info-box-text { opacity: .85; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Buttons ---------- */
.btn { border-radius: 8px; font-weight: 600; transition: all .15s ease; }
.btn-primary { background: var(--erp-primary); border: 1px solid var(--erp-primary); box-shadow: 0 2px 6px -2px rgba(29, 78, 216, .5); }
.btn-primary:hover { background: #1a43b0; border-color: #1a43b0; filter: none; }
.btn-success { box-shadow: 0 2px 6px -2px rgba(5, 150, 105, .4); }
.btn-danger  { box-shadow: 0 2px 6px -2px rgba(220, 38, 38, .4); }
.btn-outline-primary, .btn-outline-secondary, .btn-outline-success,
.btn-outline-info, .btn-outline-danger, .btn-outline-warning { border-radius: 8px; }
.btn-sm { border-radius: 7px; }
.btn-check:checked + .btn { box-shadow: 0 2px 8px -2px rgba(29, 78, 216, .6); }

/* ---------- Tables ---------- */
.table { --bs-table-hover-bg: rgba(29, 78, 216, .04); }
.table thead th {
  background: #f4f7fc;
  color: #3a4a66;
  font-size: .74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--erp-line) !important;
  padding: .7rem .85rem;
  white-space: nowrap;
}
.table tbody td { padding: .7rem .85rem; vertical-align: middle; }
.table-bordered, .table-bordered th, .table-bordered td { border-color: var(--erp-line); }
div.dataTables_wrapper div.dataTables_length select,
div.dataTables_wrapper div.dataTables_filter input { border-radius: 8px; border: 1px solid var(--erp-line); padding: .3rem .55rem; }
div.dataTables_wrapper div.dataTables_filter input:focus { border-color: var(--erp-primary); box-shadow: 0 0 0 .18rem rgba(29,78,216,.13); }

/* DataTables responsive + corporate pagination */
.dataTables_wrapper { overflow-x: auto; }
table.dataTable { width: 100% !important; }
.dataTables_wrapper .row { align-items: center; margin: 0; }
div.dataTables_wrapper div.dataTables_info { font-size: .8rem; color: var(--erp-muted); }
div.dataTables_wrapper div.dataTables_paginate { margin-top: .8rem; }
div.dataTables_wrapper .dataTables_paginate .paginate_button {
  border: 1px solid var(--erp-line) !important;
  border-radius: 7px;
  margin: 0 2px;
  padding: .32rem .7rem !important;
  font-size: .82rem;
  font-weight: 600;
  color: var(--erp-primary) !important;
  background: #fff !important;
  transition: .12s;
}
div.dataTables_wrapper .dataTables_paginate .paginate_button:hover { background: rgba(29, 78, 216, .07) !important; border-color: #b8c7dc !important; }
div.dataTables_wrapper .dataTables_paginate .paginate_button.current,
div.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--erp-primary) !important;
  border-color: var(--erp-primary) !important;
  color: #fff !important;
  box-shadow: 0 2px 6px -2px rgba(29, 78, 216, .55);
}
div.dataTables_wrapper .dataTables_paginate .paginate_button.disabled { color: #a6b2c6 !important; background: #fff !important; }
div.dataTables_wrapper div.dataTables_length label { font-size: .8rem; color: var(--erp-muted); }
div.dataTables_wrapper div.dataTables_filter label { font-size: .8rem; color: var(--erp-muted); }
div.dataTables_wrapper div.dataTables_filter input { margin-left: .3rem; }

/* ---------- Badges ---------- */
.badge { font-weight: 600; letter-spacing: .02em; border-radius: 999px; padding: .42em .72em; }
.bg-primary { background: var(--erp-primary) !important; }

/* ---------- Alerts ---------- */
.alert { border-radius: 10px; border: 0; box-shadow: 0 3px 10px -6px rgba(16,37,78,.2); }

/* ---------- Dropdown ---------- */
.dropdown-menu { border-radius: 10px; border: 1px solid var(--erp-line); box-shadow: var(--erp-shadow-lg); padding: .5rem; }
.dropdown-item { border-radius: 7px; padding: .5rem .8rem; font-size: .9rem; }
.dropdown-item:hover { background: rgba(29, 78, 216, .07); color: var(--erp-primary); }
.dropdown-header { border-radius: 7px; background: #f1f5f9; }

/* ---------- Pagination ---------- */
.page-link { border-radius: 7px; margin: 0 2px; border-color: var(--erp-line); color: var(--erp-primary); font-weight: 600; }
.page-item.active .page-link { background: var(--erp-primary); border-color: var(--erp-primary); }

/* ---------- Select2 ---------- */
.select2-container--bootstrap5 .select2-selection { border-radius: 8px; border-color: var(--erp-line) !important; }
.select2-container--bootstrap5 .select2-selection--single .select2-selection__rendered { line-height: 36px; color: var(--erp-ink); }
.select2-container--bootstrap5 .select2-selection--single { height: 38px; }
.select2-container--bootstrap5 .select2-dropdown { border-radius: 10px; border-color: var(--erp-line); box-shadow: var(--erp-shadow-lg); }

/* ---------- Footer ---------- */
.app-footer { background: transparent; border-top: 1px solid var(--erp-line) !important; color: var(--erp-muted); font-size: .8rem; }

/* ---------- Mobile App Bar ---------- */
.mobile-appbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1040;
  padding: 10px 16px 12px;
  display: none;
  background: transparent;
}
.mobile-appbar .ab-inner {
  background: rgba(20, 37, 78, .94);
  backdrop-filter: blur(14px);
  border-radius: 999px;
  box-shadow: 0 10px 30px -8px rgba(16, 37, 78, .5);
  display: flex; justify-content: space-around; align-items: center;
  padding: .45rem .7rem;
  max-width: 520px; margin: 0 auto;
}
.mobile-appbar .ab-link {
  color: rgba(255, 255, 255, .6); text-decoration: none;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: .62rem; font-weight: 600; letter-spacing: .02em;
  border-radius: 999px; padding: .3rem .55rem; transition: .15s;
}
.mobile-appbar .ab-link i { font-size: 1.15rem; }
.mobile-appbar .ab-link.active { color: #fff; background: var(--erp-primary); box-shadow: 0 3px 10px -3px rgba(29,78,216,.8); }
.mobile-appbar .ab-link:hover { color: #fff; }

@media (max-width: 991.98px) {
  body { padding-bottom: 86px; }
  .mobile-appbar { display: block; }
  .content-header h1 { font-size: 1.25rem; }
  .app-footer { padding-bottom: 60px; }
}

/* ---------- Login page ---------- */
.login-page-body {
  background:
    linear-gradient(rgba(16, 37, 78, .08), rgba(16, 37, 78, .08)),
    radial-gradient(900px 500px at 10% -10%, rgba(29, 78, 216, .25) 0%, transparent 55%),
    linear-gradient(135deg, #eef2f8 0%, #ffffff 100%);
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  max-width: 430px; width: 100%; border: 1px solid var(--erp-line);
  border-radius: 14px;
  background: rgba(255, 255, 255, .98);
  box-shadow: var(--erp-shadow-lg);
  overflow: hidden;
  position: relative;
}
.login-card::before {
  content: ''; position: absolute; inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--erp-navy), var(--erp-primary));
}
.login-logo { width: 72px; height: 72px; object-fit: contain; border-radius: 12px; box-shadow: 0 8px 20px -8px rgba(29,78,216,.45); }
.brand-text { font-weight: 800; font-size: 1.3rem; letter-spacing: -.01em; }
.login-card .btn-primary { border-radius: 8px; padding: .7rem 1rem; font-weight: 700; }

/* ---------- Print ---------- */
@media print {
  .app-sidebar, .app-header, .app-footer, .no-print, .mobile-appbar { display: none !important; }
  .app-main { margin-left: 0 !important; }
  .content-wrapper { margin-left: 0 !important; padding: 0; }
  body { background: #fff; padding-bottom: 0 !important; }
  .card { border: none; box-shadow: none; }
  .card-header { display: none; }
  .table thead th { background: #fff !important; }
}