/* UltimatePOS ERP - Modern Emerald Green Theme Stylesheet */
:root {
  --primary-color: #059669;
  --primary-hover: #047857;
  --primary-dark: #065f46;
  --primary-light: #ecfdf5;
  --primary-subtle: #d1fae5;
  --primary-border: #a7f3d0;
  --secondary-color: #475569;
  --success-color: #10b981;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  --info-color: #0d9488;
  --sidebar-bg: #04271e;  /* ---1-- */
  --sidebar-header: #266656;  /* ---2-- */
  --sidebar-text: #94a3b8;
  --sidebar-hover: #063d30;
  --sidebar-active: #10b981;
  --sidebar-active-bg: rgba(16, 185, 129, 0.15);
  --topbar-height: 62px;
  --sidebar-width: 260px;
  --bg-color: #f4f7f6;
  --card-border: #e2e8f0;

  /* Bootstrap 5 Overrides */
  --bs-primary: #059669;
  --bs-primary-rgb: 5, 150, 105;
  --bs-primary-border-subtle: #a7f3d0;
  --bs-primary-bg-subtle: #ecfdf5;
  --bs-link-color: #059669;
  --bs-link-hover-color: #047857;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--bg-color);
  color: #1e293b;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

/* Custom Bootstrap Green Color Tweaks */
.btn-primary {
  background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
  border-color: #047857 !important;
  color: #ffffff !important;
  box-shadow: 0 2px 4px rgba(5, 150, 105, 0.2);
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
  background: linear-gradient(135deg, #047857 0%, #065f46 100%) !important;
  border-color: #065f46 !important;
  color: #ffffff !important;
  box-shadow: 0 4px 8px rgba(5, 150, 105, 0.3) !important;
}

.btn-outline-primary {
  color: #059669 !important;
  border-color: #059669 !important;
}
.btn-outline-primary:hover, .btn-outline-primary:focus, .btn-outline-primary:active {
  background-color: #059669 !important;
  border-color: #059669 !important;
  color: #ffffff !important;
}

.text-primary {
  color: #059669 !important;
}

.bg-primary {
  --bs-bg-opacity: 1;
  background-color: rgba(var(--bs-primary-rgb, 5, 150, 105), var(--bs-bg-opacity, 1)) !important;
}

.bg-primary-subtle {
  background-color: #ecfdf5 !important;
  color: #059669 !important;
}

.bg-secondary-subtle {
  background-color: #f1f5f9 !important;
  color: #475569 !important;
}

.bg-success-subtle {
  background-color: #d1fae5 !important;
  color: #047857 !important;
}

.bg-warning-subtle {
  background-color: #fef3c7 !important;
  color: #d97706 !important;
}

.bg-danger-subtle {
  background-color: #fee2e2 !important;
  color: #dc2626 !important;
}

.bg-info-subtle {
  background-color: #ccfbf1 !important;
  color: #0d9488 !important;
}

/* Universal Background Opacity Support for Icon Containers & Badges */
.bg-opacity-10 {
  --bs-bg-opacity: 0.1 !important;
}
.bg-opacity-20 {
  --bs-bg-opacity: 0.2 !important;
}
.bg-opacity-25 {
  --bs-bg-opacity: 0.25 !important;
}
.bg-opacity-50 {
  --bs-bg-opacity: 0.5 !important;
}
.bg-opacity-75 {
  --bs-bg-opacity: 0.75 !important;
}

/* Explicit fallback helpers for composite opacity classes */
.bg-primary.bg-opacity-10,
.bg-primary[class*="bg-opacity-10"] {
  background-color: rgba(5, 150, 105, 0.1) !important;
}

.bg-secondary.bg-opacity-10,
.bg-secondary[class*="bg-opacity-10"] {
  background-color: rgba(100, 116, 139, 0.1) !important;
}

.bg-success.bg-opacity-10,
.bg-success[class*="bg-opacity-10"] {
  background-color: rgba(16, 185, 129, 0.1) !important;
}

.bg-warning.bg-opacity-10,
.bg-warning[class*="bg-opacity-10"] {
  background-color: rgba(245, 158, 11, 0.12) !important;
}

.bg-danger.bg-opacity-10,
.bg-danger[class*="bg-opacity-10"] {
  background-color: rgba(239, 68, 68, 0.1) !important;
}

.bg-info.bg-opacity-10,
.bg-info[class*="bg-opacity-10"] {
  background-color: rgba(13, 148, 136, 0.1) !important;
}

.bg-white.bg-opacity-10,
.bg-white[class*="bg-opacity-10"] {
  background-color: rgba(255, 255, 255, 0.1) !important;
}

.bg-white.bg-opacity-25,
.bg-white[class*="bg-opacity-25"] {
  background-color: rgba(255, 255, 255, 0.25) !important;
}

.text-primary-emphasis {
  color: #047857 !important;
}

.border-primary {
  border-color: #059669 !important;
}

.form-control:focus, .form-select:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 0.25rem rgba(16, 185, 129, 0.2);
}

.form-check-input:checked {
  background-color: #059669;
  border-color: #059669;
}

/* Layout Wrapper */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  height: 100vh;
  z-index: 1000;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden !important;
  border-right: 1px solid rgba(16, 185, 129, 0.1);
}

/* Fixed Header pinned at the top of the sidebar */
.sidebar-header-fixed {
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  background-color: var(--sidebar-header);
  border-bottom: 1px solid rgba(16, 185, 129, 0.15);
  z-index: 10;
  width: 100%;
}

.sidebar-brand {
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.15rem;
  color: #ffffff;
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  overflow: hidden;
  transition: all 0.3s ease;
}

.sidebar-brand-icon {
  width: 36px;
  height: 36px;
  min-width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #69bebf; /* ---3---*/
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}

.sidebar-brand-icon img {
  height: 22px;
  width: 22px;
  object-fit: contain;
  margin: 0 !important;
}

.sidebar-brand-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.01em;
  transition: opacity 0.2s ease;
}

/* Scrollable Container from Search Box Downwards */
.sidebar-scrollable-area {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  overscroll-behavior: contain;
}

.sidebar-scrollable-area::-webkit-scrollbar {
  width: 5px;
}
.sidebar-scrollable-area::-webkit-scrollbar-thumb {
  background: rgba(16, 185, 129, 0.2);
  border-radius: 4px;
}

.sidebar-menu {
  list-style: none;
  padding: 0.85rem 0.5rem;
  margin: 0;
  flex-grow: 1;
}

.menu-header {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6ee7b7;
  font-weight: 700;
  padding: 0.75rem 1rem 0.25rem;
  opacity: 0.85;
}

.menu-item {
  margin-bottom: 0.2rem;
}

.menu-link {
  display: flex;
  align-items: center;
  padding: 0.65rem 0.85rem;
  color: #94a3b8;
  text-decoration: none;
  border-radius: 0.5rem;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.menu-link:hover {
  background-color: var(--sidebar-hover);
  color: #ecfdf5;
}

.menu-link.active {
  background-color: var(--sidebar-active-bg);
  color: #10b981;
  font-weight: 600;
  border-left: 3px solid #10b981;
}

.menu-icon {
  width: 20px;
  font-size: 1.05rem;
  margin-right: 0.75rem;
  text-align: center;
  color: #64748b;
  transition: color 0.2s ease;
}

.menu-link:hover .menu-icon,
.menu-link.active .menu-icon {
  color: #10b981;
}

/* Sidebar Search */
.sidebar-search-box {
  padding: 0.75rem 0.85rem 0.25rem;
}
.sidebar-search-wrap {
  position: relative;
}
.sidebar-search-input {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f8fafc;
  border-radius: 0.5rem;
  font-size: 0.82rem;
  padding: 0.45rem 0.65rem 0.45rem 2rem;
  width: 100%;
  transition: all 0.2s ease;
}
.sidebar-search-input:focus {
  background: rgba(255, 255, 255, 0.14);
  border-color: #10b981;
  color: #ffffff;
  outline: none;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
}
.sidebar-search-input::placeholder {
  color: #64748b;
}
.sidebar-search-icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  font-size: 0.8rem;
  pointer-events: none;
}

/* Sidebar Dropdown Submenus & Chevrons */
.menu-arrow {
  margin-left: auto;
  font-size: 0.72rem;
  transition: transform 0.25s ease;
  color: #64748b;
}
.menu-link[aria-expanded="true"] .menu-arrow {
  transform: rotate(90deg);
  color: #10b981;
}
.submenu-list {
  list-style: none;
  padding: 0.25rem 0 0.25rem 1.25rem;
  margin: 0.15rem 0 0.4rem 1.4rem;
  border-left: 1px dashed rgba(255, 255, 255, 0.15);
}
.submenu-item {
  margin-bottom: 0.15rem;
}
.submenu-link {
  display: flex;
  align-items: center;
  padding: 0.42rem 0.65rem;
  color: #94a3b8;
  text-decoration: none;
  border-radius: 0.375rem;
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.2s ease;
  position: relative;
}
.submenu-link::before {
  content: "";
  position: absolute;
  left: -1.25rem;
  top: 50%;
  width: 0.65rem;
  height: 1px;
  background: rgba(255, 255, 255, 0.2);
}
.submenu-link:hover {
  color: #ecfdf5;
  background: rgba(255, 255, 255, 0.06);
}
.submenu-link.active {
  color: #10b981;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.14);
}
.submenu-link.active::before {
  background: #10b981;
  height: 2px;
}

/* Main Content Area */
.app-main {
  flex-grow: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Topbar */
.app-topbar {
  height: var(--topbar-height);
  background: linear-gradient(180deg, #f8fafc 0%, #58a34d 100%);   /* ---2--- */
  background-color: #f1f5f9;
  border-bottom: 1px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 999;
  box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.04), 0 1px 2px -1px rgba(0, 0, 0, 0.03);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-toggle-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background-color: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #334155;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
  cursor: pointer;
  padding: 0;
}
.sidebar-toggle-btn:hover {
  background-color: #f8fafc !important;
  color: #059669;
  border-color: #059669 !important;
}

.pos-quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.38rem 0.85rem;
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #2563eb;
  font-weight: 600;
  font-size: 0.84rem;
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.pos-quick-btn:hover {
  background-color: #eff6ff;
  color: #1d4ed8;
  border-color: #93c5fd;
}

.quick-icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.quick-icon-btn:hover {
  background-color: #f8fafc;
  color: #059669;
  border-color: #059669;
}

.app-topbar .dropdown .btn {
  background-color: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  color: #1e293b;
}
.app-topbar .dropdown .btn:hover {
  background-color: #f8fafc !important;
  border-color: #94a3b8 !important;
}

.app-topbar .badge.bg-light,
.app-topbar #globalLocationSelect {
  background-color: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* ==================================================== */
/* DESKTOP & TABLET COLLAPSED / MINI ICON-ONLY SIDEBAR  */
/* ==================================================== */
@media (min-width: 768px) {
  /* Collapsed Sidebar Container */
  body.sidebar-collapsed .app-sidebar,
  html.sidebar-collapsed body .app-sidebar,
  .app-wrapper.sidebar-collapsed .app-sidebar {
    width: 68px !important;
    overflow-x: visible !important;
    overflow-y: visible !important;
  }

  /* Expanded Sidebar Container Explicit Fallback */
  body:not(.sidebar-collapsed) .app-sidebar {
    width: var(--sidebar-width) !important;
  }

  /* Main Content Margin */
  body.sidebar-collapsed .app-main,
  html.sidebar-collapsed body .app-main,
  .app-wrapper.sidebar-collapsed .app-main {
    margin-left: 68px !important;
  }

  body:not(.sidebar-collapsed) .app-main {
    margin-left: var(--sidebar-width) !important;
  }

  /* Fixed Brand Header in Collapsed Mode */
  body.sidebar-collapsed .sidebar-header-fixed,
  html.sidebar-collapsed body .sidebar-header-fixed,
  .app-wrapper.sidebar-collapsed .sidebar-header-fixed {
    width: 68px !important;
    justify-content: center !important;
    padding: 0 !important;
  }

  body.sidebar-collapsed .sidebar-brand,
  html.sidebar-collapsed body .sidebar-brand,
  .app-wrapper.sidebar-collapsed .sidebar-brand {
    padding: 0 !important;
    justify-content: center !important;
  }

  /* Hide Text & Search in Collapsed Mode */
  body.sidebar-collapsed .sidebar-brand-text,
  html.sidebar-collapsed body .sidebar-brand-text,
  .app-wrapper.sidebar-collapsed .sidebar-brand-text,
  body.sidebar-collapsed .sidebar-search-box,
  html.sidebar-collapsed body .sidebar-search-box,
  .app-wrapper.sidebar-collapsed .sidebar-search-box,
  body.sidebar-collapsed .menu-header,
  html.sidebar-collapsed body .menu-header,
  .app-wrapper.sidebar-collapsed .menu-header,
  body.sidebar-collapsed .menu-link span,
  html.sidebar-collapsed body .menu-link span,
  .app-wrapper.sidebar-collapsed .menu-link span,
  body.sidebar-collapsed .menu-link .menu-arrow,
  html.sidebar-collapsed body .menu-link .menu-arrow,
  .app-wrapper.sidebar-collapsed .menu-link .menu-arrow {
    display: none !important;
  }

  body.sidebar-collapsed .sidebar-scrollable-area,
  html.sidebar-collapsed body .sidebar-scrollable-area,
  .app-wrapper.sidebar-collapsed .sidebar-scrollable-area {
    overflow-x: visible !important;
    overflow-y: visible !important;
  }

  body.sidebar-collapsed .sidebar-menu,
  html.sidebar-collapsed body .sidebar-menu,
  .app-wrapper.sidebar-collapsed .sidebar-menu {
    padding: 0.65rem 0.35rem !important;
    overflow-x: visible !important;
  }

  body.sidebar-collapsed .menu-item,
  html.sidebar-collapsed body .menu-item,
  .app-wrapper.sidebar-collapsed .menu-item {
    position: relative;
    margin-bottom: 0.35rem;
  }

  body.sidebar-collapsed .menu-link,
  html.sidebar-collapsed body .menu-link,
  .app-wrapper.sidebar-collapsed .menu-link {
    padding: 0.65rem 0 !important;
    justify-content: center !important;
    text-align: center !important;
    border-radius: 0.5rem !important;
    position: relative;
  }

  body.sidebar-collapsed .menu-link .menu-icon,
  html.sidebar-collapsed body .menu-link .menu-icon,
  .app-wrapper.sidebar-collapsed .menu-link .menu-icon {
    margin: 0 !important;
    font-size: 1.25rem !important;
    width: 100% !important;
    text-align: center !important;
  }

  body.sidebar-collapsed .menu-link.active,
  html.sidebar-collapsed body .menu-link.active,
  .app-wrapper.sidebar-collapsed .menu-link.active {
    border-left: none !important;
    background-color: var(--sidebar-active-bg) !important;
  }

  /* Inline Collapsed Submenus Hidden */
  body.sidebar-collapsed .menu-item .collapse,
  html.sidebar-collapsed body .menu-item .collapse,
  .app-wrapper.sidebar-collapsed .menu-item .collapse {
    display: none !important;
  }

  /* Floating Popover / Flyout Menu on Hover */
  body.sidebar-collapsed .menu-item:hover > .collapse,
  html.sidebar-collapsed body .menu-item:hover > .collapse,
  .app-wrapper.sidebar-collapsed .menu-item:hover > .collapse {
    display: block !important;
    position: absolute !important;
    left: 100% !important;
    top: 0 !important;
    width: 215px !important;
    background: #0f172a !important;
    border-radius: 0.5rem !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    padding: 0.4rem 0 !important;
    z-index: 1060 !important;
    margin-left: 6px !important;
    animation: fadeInFlyout 0.15s ease-in-out;
  }

  body.sidebar-collapsed .menu-item:hover .submenu-list,
  html.sidebar-collapsed body .menu-item:hover .submenu-list,
  .app-wrapper.sidebar-collapsed .menu-item:hover .submenu-list {
    padding: 0 !important;
    margin: 0 !important;
    border-left: none !important;
  }

  body.sidebar-collapsed .menu-item:hover .submenu-link,
  html.sidebar-collapsed body .menu-item:hover .submenu-link,
  .app-wrapper.sidebar-collapsed .menu-item:hover .submenu-link {
    padding: 0.5rem 1rem !important;
    color: #cbd5e1 !important;
    font-size: 0.85rem !important;
  }

  body.sidebar-collapsed .menu-item:hover .submenu-link::before,
  html.sidebar-collapsed body .menu-item:hover .submenu-link::before,
  .app-wrapper.sidebar-collapsed .menu-item:hover .submenu-link::before {
    display: none !important;
  }

  body.sidebar-collapsed .menu-item:hover .submenu-link:hover,
  html.sidebar-collapsed body .menu-item:hover .submenu-link:hover,
  .app-wrapper.sidebar-collapsed .menu-item:hover .submenu-link:hover {
    background: rgba(16, 185, 129, 0.18) !important;
    color: #34d399 !important;
  }

  body.sidebar-collapsed .menu-item:hover .submenu-link.active,
  html.sidebar-collapsed body .menu-item:hover .submenu-link.active,
  .app-wrapper.sidebar-collapsed .menu-item:hover .submenu-link.active {
    background: rgba(16, 185, 129, 0.25) !important;
    color: #10b981 !important;
    font-weight: 700 !important;
  }

  /* Tooltip for Non-Submenu Links on Hover */
  body.sidebar-collapsed .menu-item:not(:has(.collapse)):hover > .menu-link::after,
  html.sidebar-collapsed body .menu-item:not(:has(.collapse)):hover > .menu-link::after,
  .app-wrapper.sidebar-collapsed .menu-item:not(:has(.collapse)):hover > .menu-link::after {
    content: attr(data-menu-title);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: #0f172a;
    color: #ffffff;
    padding: 0.45rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: 0.375rem;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    border: 1px solid rgba(255, 255, 255, 0.12);
    z-index: 1060;
    margin-left: 8px;
    pointer-events: none;
    animation: fadeInFlyout 0.15s ease-in-out;
  }

  @keyframes fadeInFlyout {
    from { opacity: 0; transform: translateY(-50%) translateX(-4px); }
    to { opacity: 1; transform: translateY(-50%) translateX(0); }
  }
}

.location-badge {
  background-color: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  padding: 0.35rem 0.75rem;
  border-radius: 2rem;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.topbar-btn {
  background: transparent;
  border: 1px solid var(--card-border);
  padding: 0.4rem 0.75rem;
  border-radius: 0.5rem;
  color: #475569;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
  cursor: pointer;
}

.topbar-btn:hover {
  background-color: #f8fafc;
  color: #059669;
  border-color: #a7f3d0;
}

/* Content Body */
.content-body {
  padding: 1.5rem;
  flex-grow: 1;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Cards */
.card-custom {
  background-color: #ffffff;
  border: 1px solid var(--card-border);
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.card-header-custom {
  padding: 1rem 1.25rem;
  background-color: #ffffff;
  border-bottom: 1px solid var(--card-border);
  font-weight: 600;
  font-size: 0.95rem;
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body-custom {
  padding: 1.25rem;
}

/* Stat Cards */
.stat-card {
  background: #ffffff;
  border-radius: 0.75rem;
  padding: 1.25rem;
  border: 1px solid var(--card-border);
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.08);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.stat-info-wrap {
  flex-grow: 1;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.8rem;
  color: #64748b;
  font-weight: 500;
  margin-top: 0.2rem;
}

.stat-primary .stat-icon { background-color: #ecfdf5; color: #059669; }
.stat-success .stat-icon { background-color: #d1fae5; color: #047857; }
.stat-warning .stat-icon { background-color: #fffbeb; color: #d97706; }
.stat-danger .stat-icon { background-color: #fef2f2; color: #dc2626; }
.stat-info .stat-icon { background-color: #f0fdfa; color: #0d9488; }
.stat-purple .stat-icon { background-color: #f5f3ff; color: #7c3aed; }

/* Custom Tables */
.table-custom {
  margin-bottom: 0;
}

.table-custom th {
  background-color: #f8fafc;
  color: #475569;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--card-border);
}

.table-custom td {
  padding: 0.85rem 1rem;
  font-size: 0.85rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--card-border);
}

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

/* Badges */
.badge-custom {
  padding: 0.35rem 0.65rem;
  border-radius: 2rem;
  font-size: 0.72rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.badge-paid { background-color: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.badge-partial { background-color: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.badge-due { background-color: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

/* Table Row Highlights by Payment Status */
.table-custom tbody tr.purchase-row-paid td {
  background-color: #f0fdf4 !important;
  border-bottom: 1px solid #d1fae5 !important;
}
.table-custom tbody tr.purchase-row-paid td:first-child {
  border-left: 3px solid #10b981 !important;
}
.table-custom tbody tr.purchase-row-paid:hover td {
  background-color: #dcfce7 !important;
}

.table-custom tbody tr.purchase-row-partial td {
  background-color: #fffbeb !important;
  border-bottom: 1px solid #fde68a !important;
}
.table-custom tbody tr.purchase-row-partial td:first-child {
  border-left: 3px solid #f59e0b !important;
}
.table-custom tbody tr.purchase-row-partial:hover td {
  background-color: #fef3c7 !important;
}

.table-custom tbody tr.purchase-row-due td {
  background-color: #fef2f2 !important;
  border-bottom: 1px solid #fecaca !important;
}
.table-custom tbody tr.purchase-row-due td:first-child {
  border-left: 3px solid #ef4444 !important;
}
.table-custom tbody tr.purchase-row-due:hover td {
  background-color: #fee2e2 !important;
}

/* SweetAlert2 Green Customization */
.swal2-styled.swal2-confirm {
  background-color: #059669 !important;
  border-color: #047857 !important;
}

/* ==================================================== */
/* UNIVERSAL MODAL SCROLLABILITY & MULTI-DEVICE FIT    */
/* ==================================================== */
.modal-dialog {
  margin: 1rem auto;
  max-width: 95vw;
}

@media (min-width: 576px) {
  .modal-dialog { max-width: 540px; }
  .modal-dialog.modal-lg { max-width: 820px; }
  .modal-dialog.modal-xl { max-width: 1140px; }
}

@media (min-width: 1400px) {
  .modal-dialog.modal-xl { max-width: 1280px; }
}

/* Fix for Bootstrap modal scrolling with nested <form> */
.modal-dialog-scrollable .modal-content,
.modal-dialog-scrollable form.modal-content,
.modal-content {
  max-height: calc(100vh - 2rem) !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

.modal-dialog-scrollable form {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 1 auto !important;
  overflow: hidden !important;
  max-height: 100% !important;
}

.modal-dialog-scrollable .modal-body,
.modal-body {
  overflow-y: auto !important;
  max-height: calc(85vh - 120px) !important;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}
.modal-body::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 4px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
  background-color: #94a3b8;
}

.modal-header {
  flex-shrink: 0;
}
.modal-footer {
  flex-shrink: 0;
  background-color: #f8fafc;
}

/* ==================================================== */
/* RESPONSIVE HORIZONTAL TABS (HRM, USERS, REPORTS)     */
/* ==================================================== */
.hrm-tabs-wrapper {
  position: sticky;
  top: 0;
  z-index: 1010;
  background-color: var(--body-bg, #f8fafc);
  padding: 0.25rem 0 0.5rem 0;
  margin-bottom: 1.25rem;
}

.hrm-top-tabs-card {
  border-radius: 0.75rem;
  border: 1px solid var(--card-border, #e2e8f0);
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.nav-tabs,
.hrm-top-tabs {
  display: flex;
  flex-wrap: nowrap !important;
  overflow-x: auto !important;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding: 0.25rem !important;
  gap: 0.35rem;
}
.nav-tabs::-webkit-scrollbar,
.hrm-top-tabs::-webkit-scrollbar {
  height: 4px;
}
.nav-tabs::-webkit-scrollbar-thumb,
.hrm-top-tabs::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.nav-tabs .nav-item,
.hrm-top-tabs .nav-item {
  flex: 0 0 auto;
}

.hrm-top-tabs .nav-link {
  color: #475569;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.5rem 0.95rem;
  transition: all 0.2s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid transparent;
  background: transparent;
}
.hrm-top-tabs .nav-link:hover {
  background-color: #f1f5f9;
  color: #0f172a;
  border-color: #e2e8f0;
}
.hrm-top-tabs .nav-link.active {
  background-color: #059669 !important;
  color: #ffffff !important;
  border-color: #059669 !important;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.35) !important;
}
.hrm-top-tabs .nav-link.active i {
  color: #ffffff !important;
}

/* ==================================================== */
/* SIDEBAR BACKDROP & RESPONSIVE BREAKPOINTS            */
/* ==================================================== */
.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  z-index: 1040;
  display: none;
  opacity: 0;
  transition: opacity 0.25s ease-in-out;
}
.sidebar-backdrop.show {
  display: block;
  opacity: 1;
}

/* Table Responsive Scrolling */
.table-responsive {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.table-responsive::-webkit-scrollbar {
  height: 6px;
}
.table-responsive::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 4px;
}

/* Mobile Screens (<= 767px) */
@media (max-width: 767px) {
  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1050;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25);
  }
  .app-sidebar.show {
    transform: translateX(0);
  }
  .app-main {
    margin-left: 0 !important;
    width: 100% !important;
    min-width: 0;
  }
  .app-topbar {
    padding: 0.5rem 0.75rem;
  }
  .content-body {
    padding: 0.75rem !important;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.75rem;
  }
  .pos-quick-btn span {
    display: none;
  }
}

/* Small Phones (<= 576px) */
@media (max-width: 576px) {
  .table-custom th, .table-custom td {
    padding: 0.5rem 0.5rem;
    font-size: 0.8rem;
  }
  .page-title {
    font-size: 1.15rem;
  }
  .btn-group .btn {
    padding: 0.25rem 0.4rem;
  }
  .card-body-custom {
    padding: 0.75rem;
  }
}

/* ==================================================== */
/* GLOBAL PROFESSIONAL MULTI-PAGE & MODAL PRINT STYLES  */
/* ==================================================== */
@page {
  size: landscape;
  margin: 8mm;
}

@media print {
  /* Page Margins & Setup */
  @page {
    size: landscape;
    margin: 8mm;
  }

  /* Reset HTML & Body to allow full multi-page flow without viewport clipping */
  html, body {
    width: 100% !important;
    height: auto !important;
    min-height: 100% !important;
    overflow: visible !important;
    background: #ffffff !important;
    color: #0f172a !important;
    font-size: 10.5pt !important;
    line-height: 1.4 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Disable all fixed height, flex constraints, and scroll containers */
  .app-wrapper,
  .app-main,
  .content-body,
  .container-fluid,
  .card,
  .card-custom,
  .card-body,
  .card-body-custom,
  .tab-content,
  .tab-pane,
  .table-responsive {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    float: none !important;
    position: static !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    transform: none !important;
  }

  /* Hide Navigation, Sidebars, Topbars, Controls, & Buttons */
  .no-print,
  .app-sidebar,
  .app-topbar,
  .sidebar-backdrop,
  .hrm-top-tabs,
  .nav-pills,
  .nav-tabs,
  .page-header .btn,
  .page-header .btn-group,
  .btn,
  .btn-group,
  .btn-close,
  .modal-footer,
  .action-col,
  .actions-col,
  .print-hidden-action,
  th.action-col,
  td.action-col,
  th.actions-col,
  td.actions-col,
  th:last-child.no-print,
  td:last-child.no-print,
  form.ajax-form button,
  .pagination,
  .dataTables_filter,
  .dataTables_paginate,
  .dataTables_length,
  .dataTables_info,
  #calculatorModal,
  .swal2-container {
    display: none !important;
  }

  /* Full Page Table Formatting with Repeating Headers */
  table, .table, .table-custom {
    width: 100% !important;
    border-collapse: collapse !important;
    page-break-inside: auto !important;
    margin-bottom: 1.25rem !important;
    background: #ffffff !important;
  }

  table thead {
    display: table-header-group !important; /* Repeats table header on every printed page */
  }

  table tfoot {
    display: table-footer-group !important;
  }

  table tr {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  table th, table td, .table-custom th, .table-custom td {
    border: 1px solid #94a3b8 !important;
    padding: 6px 8px !important;
    font-size: 9pt !important;
    color: #0f172a !important;
    background-color: transparent !important;
  }

  table thead th {
    background-color: #f1f5f9 !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    font-size: 8.5pt !important;
    letter-spacing: 0.02em !important;
  }

  /* Summary Stat Cards */
  .stat-card {
    border: 1px solid #cbd5e1 !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    margin-bottom: 8px !important;
    padding: 8px 12px !important;
    background: #f8fafc !important;
    box-shadow: none !important;
  }
  .stat-card .stat-icon {
    display: none !important;
  }

  /* Page Header Styling in Print Mode */
  .page-header {
    margin-bottom: 12px !important;
    padding-bottom: 6px !important;
    border-bottom: 2px solid #0f172a !important;
  }
  .page-title {
    font-size: 14pt !important;
    font-weight: 700 !important;
    color: #0f172a !important;
  }

  /* Badges in Print Mode */
  .badge {
    border: 1px solid #64748b !important;
    color: #0f172a !important;
    background: transparent !important;
    font-weight: 600 !important;
    padding: 2px 6px !important;
  }

  /* ==================================================== */
  /* MODAL PRINTING (e.g. Payslips, Invoices, Receipts)   */
  /* ==================================================== */
  body.modal-open {
    overflow: visible !important;
  }

  /* Hide main app navigation & background when printing from inside an open modal */
  body.modal-open .app-sidebar,
  body.modal-open .app-topbar,
  body.modal-open .sidebar-backdrop {
    display: none !important;
  }

  body.modal-open .modal-backdrop {
    display: none !important;
  }

  body.modal-open .modal.show {
    position: static !important;
    display: block !important;
    overflow: visible !important;
    background: transparent !important;
    width: 100% !important;
    height: auto !important;
    min-height: auto !important;
  }

  body.modal-open .modal.show .modal-dialog {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
  }

  body.modal-open .modal.show .modal-content {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    background: #ffffff !important;
  }

  body.modal-open .modal.show .modal-header {
    background: transparent !important;
    color: #0f172a !important;
    border-bottom: 2px solid #0f172a !important;
    padding: 0 0 8px 0 !important;
    margin-bottom: 12px !important;
  }

  body.modal-open .modal.show .modal-header .modal-title {
    font-size: 15pt !important;
    font-weight: bold !important;
    color: #0f172a !important;
  }

  body.modal-open .modal.show .modal-body {
    padding: 0 !important;
    overflow: visible !important;
    max-height: none !important;
  }

  /* Printable Payslip Specific Formatting */
  .printable-payslip {
    border: 2px solid #334155 !important;
    padding: 16px !important;
    background: #ffffff !important;
    color: #0f172a !important;
    margin-bottom: 20px !important;
  }
}

/* ============================================================
   Standardized Professional Export / Print Icon Buttons
   Matching Print (White/Border), PDF (Red), Excel (Green) Trio
   ============================================================ */
.btn-export-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-export-icon {
  width: 38px;
  height: 38px;
  min-width: 38px;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 8px !important;
  font-size: 1.15rem !important;
  line-height: 1 !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  text-decoration: none !important;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.btn-export-icon:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px -2px rgba(0, 0, 0, 0.2) !important;
}

.btn-export-icon:active {
  transform: translateY(0);
}

.btn-export-icon.btn-export-print {
  background-color: #ffffff !important;
  color: #0f172a !important;
  border: 1.5px solid #0f172a !important;
}
.btn-export-icon.btn-export-print:hover {
  background-color: #f8fafc !important;
  border-color: #000000 !important;
  color: #000000 !important;
}

.btn-export-icon.btn-export-pdf {
  background-color: #dc2626 !important;
  color: #ffffff !important;
  border: 1.5px solid #dc2626 !important;
}
.btn-export-icon.btn-export-pdf:hover {
  background-color: #b91c1c !important;
  border-color: #b91c1c !important;
  color: #ffffff !important;
}

.btn-export-icon.btn-export-excel {
  background-color: #15803d !important;
  color: #ffffff !important;
  border: 1.5px solid #15803d !important;
}
.btn-export-icon.btn-export-excel:hover {
  background-color: #166534 !important;
  border-color: #166534 !important;
  color: #ffffff !important;
}
