/* Extracted from base.html - first inline <style> block */
:root {
  --page-loading-bg: rgba(255, 255, 255, 0.92);
  --page-loading-spinner: var(--bs-primary);
}

body {
  background: #f6f7fb;
}

.card {
  border: 0;
  border-radius: 16px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .06);
}

.navbar {
  box-shadow: 0 6px 18px rgba(0, 0, 0, .06);
}

.navbar .nav-link {
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem !important;
}

@media (min-width: 1200px) {
  .navbar .nav-link {
    font-size: 0.92rem;
    padding: 0.35rem 0.65rem !important;
  }
}


.badge-kpi-ok {
  background: #1f7a3f;
}

.badge-kpi-no {
  background: #b42318;
}

.dt-search {
  display: none;
}

/* dùng filter từng cột */
table.dataTable tbody tr:hover {
  background: #f1f5ff;
}

h1,
h2,
h3,
h4,
h5 {
  font-weight: 800;
}

a {
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.emp-pill {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .25rem .6rem;
  border-radius: 999px;
  font-weight: 700;
  background: var(--bs-primary-bg-subtle);
  color: var(--bs-primary-text-emphasis);
  border: 1px solid var(--bs-primary-border-subtle);
  white-space: nowrap;
}

/* ============================================
   PAGE HEADER - Unified style
   ============================================ */
.page-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 16px;
  padding: 20px 24px;
  margin-bottom: 20px;
  color: white;
  position: relative;
  overflow: hidden;
}

.page-header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 300px;
  height: 300px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
}

.page-header .page-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0 0 4px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-header .page-title i {
  font-size: 1.3rem;
  opacity: 0.9;
}

.page-header .page-subtitle {
  opacity: 0.9;
  font-size: 0.875rem;
  margin: 0;
}

.page-header .page-actions {
  position: relative;
  z-index: 1;
}

.page-header .btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  backdrop-filter: blur(4px);
}

.page-header .btn:hover {
  background: rgba(255, 255, 255, 0.3);
  color: white;
}

/* Header selects (e.g. ADS view-as employee) */
.page-header .header-select {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
}

.page-header .header-select:focus {
  border-color: rgba(255, 255, 255, 0.65);
  box-shadow: 0 0 0 .2rem rgba(255, 255, 255, 0.15);
}

.page-header .header-select option {
  color: #111;
  background: #fff;
}

@media (max-width: 767.98px) {
  .page-header {
    padding: 16px 18px;
    border-radius: 12px;
  }

  .page-header .page-title {
    font-size: 1.2rem;
  }

  .page-header .page-subtitle {
    font-size: 0.8rem;
  }
}

/* Section card header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title i {
  color: var(--bs-primary);
}

/* Column resize handle */
th.resizable-th {
  position: relative;
}

.col-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  touch-action: none;
}

/* ============================================
   PAGE LOADING OVERLAY - Smooth transitions
   ============================================ */
.page-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--page-loading-bg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.page-loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

.page-loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-left-color: var(--page-loading-spinner);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.page-loading-text {
  margin-top: 16px;
  font-size: 0.95rem;
  color: #6c757d;
  font-weight: 500;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================
   NAVBAR STATS (inline in navbar)
   ============================================ */
.navbar-stats {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 0;
  background: #f8fafc;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  margin-right: 8px;
  overflow: hidden;
  font-size: 0.68rem;
  flex-shrink: 0;
}

.navbar-stats .stat-item {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px 6px;
  white-space: nowrap;
  border-right: 1px solid #e2e8f0;
  line-height: 1;
}

.navbar-stats .stat-item:last-child {
  border-right: none;
}

.navbar-stats .stat-label {
  font-size: 0.58rem;
  color: #94a3b8;
  font-weight: 600;
}

.navbar-stats .stat-value {
  font-size: 0.68rem;
  font-weight: 700;
}

@media (max-width: 1399.98px) {
  .navbar-stats .stat-item {
    padding: 3px 5px;
  }

  .navbar-stats .stat-label {
    font-size: 0.55rem;
  }

  .navbar-stats .stat-value {
    font-size: 0.62rem;
  }
}

@media (max-width: 991.98px) {
  .navbar-stats {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    margin: 6px 0;
    border-radius: 6px;
  }
}

/* ============================================
   SKELETON LOADING PLACEHOLDERS
   ============================================ */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
}

.skeleton-text {
  height: 16px;
  margin-bottom: 8px;
}

.skeleton-text-sm {
  height: 12px;
  margin-bottom: 6px;
}

.skeleton-title {
  height: 24px;
  width: 60%;
  margin-bottom: 12px;
}

.skeleton-img {
  width: 100%;
  height: 120px;
  border-radius: 8px;
}

.skeleton-card {
  padding: 16px;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: -200% 0;
  }

  100% {
    background-position: 200% 0;
  }
}

/* ============================================
   MOBILE RESPONSIVE IMPROVEMENTS
   ============================================ */

/* Navbar mobile improvements */
@media (max-width: 991.98px) {
  .navbar-brand {
    font-size: 1rem;
  }

  .navbar .navbar-nav {
    flex-direction: column;
    gap: 0.25rem !important;
    padding: 0.75rem 0;
    max-height: 60vh;
    overflow-y: auto;
  }

  .navbar .nav-link {
    padding: 0.6rem 1rem !important;
    border-radius: 8px !important;
    font-size: 0.95rem;
  }

  .navbar .nav-link.active {
    background: var(--bs-primary);
    color: white !important;
  }

  /* Revenue dashboard mobile */
  .navbar .revenue-dashboard-mobile {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    margin: 0.5rem 0;
    border-radius: 12px;
  }

  .navbar .revenue-dashboard-mobile>div {
    display: flex;
    justify-content: space-between;
    width: 100%;
  }

  /* Auth buttons mobile */
  .navbar .d-flex.gap-2:last-child {
    flex-direction: column;
    width: 100%;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
  }

  .navbar .d-flex.gap-2:last-child .btn {
    width: 100%;
    padding: 0.5rem 1rem;
  }

  .navbar .d-flex.gap-2:last-child .align-self-center {
    text-align: center;
    margin-bottom: 0.5rem;
  }
}

/* Cards on mobile */
@media (max-width: 767.98px) {
  .card {
    border-radius: 12px;
  }

  .container-fluid {
    padding-left: 12px;
    padding-right: 12px;
  }

  h2,
  h3 {
    font-size: 1.25rem;
  }

  h4,
  h5 {
    font-size: 1.1rem;
  }

  /* Tables scroll hint */
  .table-responsive {
    position: relative;
  }

  .table-responsive::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.9));
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s;
  }

  .table-responsive.scrolled-end::after {
    opacity: 0;
  }

  /* Smaller badges */
  .badge {
    font-size: 0.75rem;
    padding: 0.3em 0.5em;
  }

  /* Employee pills compact */
  .emp-pill {
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
  }

  /* Form controls */
  .form-control,
  .form-select {
    font-size: 16px;
    /* Prevents iOS zoom */
  }

  /* Alert compact */
  .alert {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
  }

  /* Buttons touch-friendly */
  .btn {
    min-height: 38px;
  }

  .btn-sm {
    min-height: 32px;
  }
}

/* Extra small screens */
@media (max-width: 575.98px) {
  .container-fluid {
    padding-left: 8px;
    padding-right: 8px;
  }

  main.container-fluid {
    padding-left: 8px;
    padding-right: 8px;
  }

  /* Stack flex items vertically */
  .d-flex.flex-wrap.gap-2.justify-content-between {
    flex-direction: column;
    align-items: stretch !important;
  }

  /* Full width buttons on small screens */
  .btn-group-mobile-full {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .btn-group-mobile-full .btn {
    width: 100%;
  }
}

/* Touch scroll improvements */
.table-responsive,
.overflow-auto,
[style*="overflow"] {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

/* Improve tap targets */
@media (hover: none) {

  .btn,
  .nav-link,
  .list-group-item-action {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* Hide scrollbars but keep functionality on mobile */
@media (max-width: 767.98px) {
  .hide-scrollbar {
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .hide-scrollbar::-webkit-scrollbar {
    display: none;
  }
}

/* Loading state for cards/sections */
.loading-section {
  position: relative;
  min-height: 100px;
}

.loading-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-section::after {
  content: 'Đang tải...';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 11;
  font-size: 0.9rem;
  color: #6c757d;
  background: white;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.loading-section.loaded::before,
.loading-section.loaded::after {
  display: none;
}

/* Pull-to-refresh indicator */
.ptr-element {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(-100%);
  padding: 10px 20px;
  background: white;
  border-radius: 0 0 12px 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  transition: transform 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ptr-element.visible {
  transform: translateX(-50%) translateY(0);
}

.ptr-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #e9ecef;
  border-top-color: var(--bs-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ============================================
   SIDEBAR LAYOUT — Pancake-style
   ============================================ */
:root {
  --sb-w: 185px;
  --sb-w-collapsed: 50px;
  --sb-bg: #1e293b;
  --sb-active: #6366f1;
  --sb-hover: rgba(255, 255, 255, .08);
  --sb-text: #cbd5e1;
  --sb-text-active: #fff;
  --topbar-h: 52px;
}

body {
  overflow-x: hidden;
}

/* Sidebar */
.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sb-w);
  background: var(--sb-bg);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: width .25s cubic-bezier(.4, 0, .2, 1);
  overflow: hidden;
  box-shadow: 2px 0 12px rgba(0, 0, 0, .15);
}

.app-sidebar.collapsed {
  width: var(--sb-w-collapsed);
}

/* Logo area */
.sb-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  flex-shrink: 0;
  text-decoration: none !important;
}

.sb-brand img {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.sb-brand .brand-text {
  font-weight: 800;
  font-size: .85rem;
  color: #fff;
  white-space: nowrap;
  opacity: 1;
  transition: opacity .2s;
}

.app-sidebar.collapsed .brand-text {
  opacity: 0;
  width: 0;
}

/* Nav scroll */
.sb-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .15) transparent;
}

.sb-nav::-webkit-scrollbar {
  width: 4px;
}

.sb-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .15);
  border-radius: 4px;
}

/* Section label */
.sb-section {
  padding: 16px 14px 5px;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255, 255, 255, .3);
  white-space: nowrap;
  overflow: hidden;
}

.app-sidebar.collapsed .sb-section {
  text-align: center;
  font-size: 0;
  padding: 8px 0;
}

.app-sidebar.collapsed .sb-section::after {
  content: '···';
  font-size: .7rem;
  color: rgba(255, 255, 255, .3);
}

/* Menu item */
.sb-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  color: var(--sb-text);
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none !important;
  white-space: nowrap;
  position: relative;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sb-item:hover {
  background: var(--sb-hover);
  color: var(--sb-text-active);
  text-decoration: none !important;
}

.sb-item.active {
  background: var(--sb-active);
  color: #fff;
  border-radius: 0 24px 24px 0;
  margin-right: 8px;
  font-weight: 600;
}

.sb-item i.sb-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sb-item .sb-label {
  opacity: 1;
  transition: opacity .2s;
  overflow: hidden;
}

.app-sidebar.collapsed .sb-item .sb-label {
  opacity: 0;
  width: 0;
}

.app-sidebar.collapsed .sb-item {
  justify-content: center;
  padding: 10px 0;
}

.app-sidebar.collapsed .sb-item.active {
  border-radius: 0;
  margin-right: 0;
}

.sb-item .sb-badge {
  margin-left: auto;
  background: #ef4444;
  color: #fff;
  font-size: .6rem;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.app-sidebar.collapsed .sb-item .sb-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 1px 4px;
  font-size: .5rem;
}

/* Submenu */
.sb-sub {
  overflow: hidden;
  max-height: 0;
  transition: max-height .3s ease;
  background: rgba(0, 0, 0, .15);
}

.sb-sub.open {
  max-height: 500px;
}

.sb-sub .sb-item {
  padding-left: 50px;
  font-size: .8rem;
}

.app-sidebar.collapsed .sb-sub {
  display: none;
}

.sb-item .sb-arrow {
  margin-left: auto;
  font-size: .65rem;
  transition: transform .2s;
  flex-shrink: 0;
}

.sb-item .sb-arrow.open {
  transform: rotate(180deg);
}

.app-sidebar.collapsed .sb-item .sb-arrow {
  display: none;
}

/* Collapse button */
.sb-footer {
  border-top: 1px solid rgba(255, 255, 255, .06);
  padding: 8px;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
}

.sb-collapse-btn {
  background: none;
  border: none;
  color: var(--sb-text);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
  font-size: .85rem;
}

.sb-collapse-btn:hover {
  background: var(--sb-hover);
  color: #fff;
}

/* Topbar */
.app-topbar {
  position: fixed;
  top: 0;
  right: 0;
  height: var(--topbar-h);
  left: var(--sb-w);
  background: #fff;
  z-index: 1030;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid #e5e7eb;
  transition: left .25s cubic-bezier(.4, 0, .2, 1);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .04);
}

body.sb-collapsed .app-topbar {
  left: var(--sb-w-collapsed);
}

/* Main content */
.app-main {
  margin-left: var(--sb-w);
  margin-top: var(--topbar-h);
  padding: 20px;
  min-height: calc(100vh - var(--topbar-h));
  transition: margin-left .25s cubic-bezier(.4, 0, .2, 1);
}

body.sb-collapsed .app-main {
  margin-left: var(--sb-w-collapsed);
}

/* Mobile sidebar overlay */
.sb-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  z-index: 1039;
  opacity: 0;
  transition: opacity .25s;
}

.sb-overlay.show {
  display: block;
  opacity: 1;
}

@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
    width: var(--sb-w) !important;
  }

  .app-sidebar.mobile-open {
    transform: translateX(0);
  }

  .app-topbar {
    left: 0 !important;
  }

  .app-main {
    margin-left: 0 !important;
    padding: 14px;
  }
}

/* Topbar stats */
.topbar-stats {
  display: flex;
  align-items: center;
  gap: 0;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  overflow: hidden;
  font-size: .7rem;
}

.topbar-stats .ts-item {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 5px 10px;
  border-right: 1px solid #e2e8f0;
  white-space: nowrap;
}

.topbar-stats .ts-item:last-child {
  border-right: none;
}

.topbar-stats .ts-label {
  font-size: .6rem;
  color: #94a3b8;
  font-weight: 600;
}

.topbar-stats .ts-value {
  font-weight: 700;
}

@media (max-width: 767.98px) {
  .topbar-stats {
    display: none;
  }
}

/* Mobile hamburger */
.topbar-hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 1.3rem;
  color: #374151;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 6px;
}

.topbar-hamburger:hover {
  background: #f3f4f6;
}

@media (max-width: 991.98px) {
  .topbar-hamburger {
    display: flex;
    align-items: center;
  }
}
