/**
 * Site-wide responsive overrides
 * Ensures no horizontal overflow and proper stacking on small screens
 */

/* Prevent horizontal scroll and limit width */
html {
  overflow-x: hidden;
  max-width: 100%;
}
body {
  overflow-x: hidden;
  max-width: 100%;
}

/* Main content area: allow shrinking in flex layout */
.page-wrapper {
  min-width: 0;
  max-width: 100%;
}
.page-wrapper .content {
  min-width: 0;
  max-width: 100%;
}

/* Tables: horizontal scroll on small screens */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 767.98px) {
  .table-responsive table {
    min-width: 500px;
  }
}

/* POS: stack columns and allow scroll */
@media (max-width: 991.98px) {
  .pos-wrapper .row.g-0 {
    flex-direction: column;
  }
  .pos-wrapper .pos-left,
  .pos-wrapper .col-lg-4 {
    max-width: 100%;
    flex: 0 0 100%;
  }
  .pos-wrapper .pos-right {
    min-width: 0;
    max-width: 100%;
  }
}
@media (max-width: 575.98px) {
  .pos-wrapper .slider-wrapper .nav-tabs {
    flex-wrap: wrap;
  }
  .pos-wrapper .pos-item-card {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* Report pages: filter row wraps */
.earning-report-filter-wrap,
.sales-report-filter-wrap,
.order-report-filter-wrap,
.border-bottom.earning-report-filter-wrap,
.border-bottom.sales-report-filter-wrap,
.border-bottom.order-report-filter-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.report-filter {
  min-width: 0;
}
@media (max-width: 767.98px) {
  .report-filter .form-label,
  .report-filter .dropdown .btn,
  .report-filter .form-control {
    width: 100%;
  }
  .report-filter .input-group {
    width: 100% !important;
  }
}

/* Topbar / header: wrap and avoid overflow */
.navbar-header,
.topbar-menu,
.header-menu {
  flex-wrap: wrap;
}
@media (max-width: 991.98px) {
  .header-links {
    flex-wrap: wrap;
  }
  .header-links a {
    font-size: 0.875rem;
    padding: 0.35rem 0.5rem;
  }
}

/* Dashboard & cards: ensure images and text don't overflow */
.card .img-fluid,
.card img.img-fluid {
  max-width: 100%;
  height: auto;
}
.card-body {
  min-width: 0;
}

/* Offcanvas: full width on small screens */
@media (max-width: 575.98px) {
  .offcanvas {
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* Form controls and dropdowns: respect container width */
.form-control,
.form-select,
.input-group,
.dropdown .dropdown-toggle {
  max-width: 100%;
}
@media (max-width: 767.98px) {
  .daterangepick.custom-date,
  .w-auto.d-flex {
    width: 100% !important;
    max-width: 100%;
  }
}

/* Page headers: stack title and actions */
@media (max-width: 575.98px) {
  .d-flex.align-items-center.flex-wrap.gap-3.mb-4 .flex-grow-1,
  .d-flex.align-items-sm-center.flex-sm-row.flex-column.gap-3.mb-4 .flex-grow-1 {
    width: 100%;
  }
  .d-flex.gap-2.d-flex.align-items-center.flex-wrap,
  .gap-2.d-flex.align-items-center.flex-wrap {
    width: 100%;
    justify-content: flex-start;
  }
}

/* Admin dashboard: chart and cards stack */
@media (max-width: 991.98px) {
  .col-xxl-8.col-lg-7,
  .col-xxl-4.col-lg-5 {
    max-width: 100%;
    flex: 0 0 100%;
  }
}

/* Orders list: smaller cards on mobile */
@media (max-width: 575.98px) {
  .orders-list-four .col-sm-6 {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* Login / auth: ensure form is contained */
@media (max-width: 575.98px) {
  .auth-vh .col-xl-8,
  .auth-vh .col-lg-10,
  .auth-vh .col-md-8,
  .auth-vh .col-sm-10 {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}

/* Super admin: reset sidebar margin on mobile so content is full width */
@media (max-width: 991.98px) {
  .mini-sidebar.expand-menu .page-wrapper {
    margin-left: 0 !important;
  }
}

/* Modals and dropdowns: don't overflow viewport on small screens */
@media (max-width: 575.98px) {
  .modal-dialog {
    margin: 0.5rem;
    max-width: calc(100% - 1rem);
  }
  .dropdown-menu {
    max-width: min(90vw, 320px);
  }
}

/* Order-by-QR (public menu): ensure mobile-friendly */
@media (max-width: 991.98px) {
  .order-by-qr-header h1 {
    font-size: 1.1rem;
  }
}
@media (max-width: 575.98px) {
  .container.py-4 {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
  .order-by-qr .sticky-top {
    position: relative;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   SIMPLE CLEAN SIDEBAR  — flat single-column, replaces two-col-sidebar
   The sidebar is always a dark-green panel regardless of light/dark theme.
   All text colours use explicit values with !important so Bootstrap and
   theme variables cannot bleed through.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── 1. Background per theme ── */
[data-bs-theme="light"] .sidebar-simple {
  background: #1B2E1B !important;
  border-right: 1px solid rgba(255,255,255,0.06) !important;
}
[data-bs-theme="dark"] .sidebar-simple {
  background: #0F1F0F !important;
  border-right: 1px solid rgba(255,255,255,0.05) !important;
}

/* ── 2. Layout skeleton ── */
.sidebar,
.sidebar.sidebar-simple {
  bottom: var(--app-footer-height) !important;
}
@media (max-width: 991.98px) {
  .sidebar,
  .sidebar.sidebar-simple {
    bottom: 0 !important;
  }
}

.sidebar-simple {
  flex-direction: column !important;
  overflow: visible !important;
  height: 100%;
  min-height: 0;
}

/* ── 3. Brand / Logo header ── */
.sidebar-simple .sb-header {
  display: flex !important;
  align-items: center !important;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255,255,255,0.10) !important;
  flex-shrink: 0;
  min-height: var(--topbar-height);
  box-sizing: border-box;
}
.sidebar-simple .sb-header.sb-header--gtc {
  align-items: stretch !important;
  flex-direction: column !important;
  justify-content: flex-start !important;
  gap: 0 !important;
  padding: 0.6rem 0.5rem 0 !important;
  min-height: 0 !important;
  height: auto !important;
  position: relative;
  border-bottom: none !important;
}
.sidebar-simple .sb-header.sb-header--gtc .gtc-brand-stack--sidebar {
  padding: 0 1rem 0.35rem !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14) !important;
  margin-bottom: 0 !important;
}
/* Cancel legacy .sidebar [data-simplebar] { top: 58px } — removes gap under brand line */
.sidebar-simple .sb-nav[data-simplebar] {
  position: relative !important;
  top: 0 !important;
  height: auto !important;
  min-height: 0 !important;
  flex: 1 1 auto !important;
}
.sidebar-simple .sb-header.sb-header--gtc + .sb-nav {
  margin-top: 0 !important;
  padding: 0 0 6px !important;
  padding-top: 0 !important;
  border-top: none !important;
}
.sidebar-simple .sb-header.sb-header--gtc + .sb-nav > ul {
  padding-top: 1.75rem !important;
}
.sidebar-simple .sb-header--gtc + .sb-nav ul li.sb-section:first-child {
  margin-top: 0 !important;
  padding: 0.1rem 20px 0.12rem !important;
}
.sidebar-simple .sb-header--gtc + .sb-nav > ul > li:first-child:not(.sb-section) {
  margin-top: 0 !important;
}
.sidebar-simple .sb-header--gtc + .sb-nav > ul > li:first-child:not(.sb-section) > a {
  margin-top: 0 !important;
  padding-top: 6px !important;
  padding-bottom: 6px !important;
}
.sidebar-simple .sb-header--gtc .sidebar-close {
  position: absolute;
  top: 0.65rem;
  right: 0.5rem;
}
.sidebar-simple .sb-logo-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 8px;
  flex-shrink: 0;
}
.sidebar-simple .sb-brand-text { flex: 1; min-width: 0; }

.sidebar-simple .sb-brand-name {
  display: block !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: 0.6px !important;
  text-transform: uppercase !important;
  color: #ffffff !important;
  line-height: 1.3 !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-simple .sb-brand-sub {
  display: block !important;
  font-size: 11px !important;
  color: rgba(255,255,255,0.52) !important;
  margin-top: 1px;
}
.sidebar-simple .sb-header .sidebar-close {
  display: none;
  background: none !important;
  border: none !important;
  color: rgba(255,255,255,0.65) !important;
  padding: 4px 6px;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 18px;
}
@media (max-width: 991.98px) {
  .sidebar-simple .sb-header .sidebar-close { display: flex; align-items: center; }
}

/* ── 4. Navigation scroll area ── */
.sidebar-simple .sb-nav {
  flex: 1 1 auto !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding: 6px 0;
}
.sidebar-simple .sb-nav::-webkit-scrollbar { width: 3px; }
.sidebar-simple .sb-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-simple .sb-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

/* ── 5. Nav list items ── */
.sidebar-simple .sb-nav ul {
  list-style: none !important;
  padding: 0 0 12px 0 !important;
  margin: 0 !important;
}

/* Section title */
.sidebar-simple .sb-nav ul li.sb-section {
  font-size: 10px !important;
  font-weight: 600 !important;
  letter-spacing: 1px !important;
  text-transform: uppercase !important;
  color: rgba(255,255,255,0.38) !important;
  padding: 10px 20px 4px !important;
  margin-top: 4px;
}
.sidebar-simple .sb-nav ul li.sb-section:first-child { margin-top: 0; }

/* Nav links — base */
.sidebar-simple .sb-nav ul li a {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 9px 12px !important;
  margin: 1px 8px !important;
  border-radius: 8px !important;
  color: rgba(255,255,255,0.75) !important;
  text-decoration: none !important;
  font-size: 13.5px !important;
  font-weight: 500 !important;
  transition: background .15s, color .15s !important;
  white-space: nowrap;
  background: transparent !important;
}

/* Nav links — hover */
.sidebar-simple .sb-nav ul li a:hover {
  background: rgba(255,255,255,0.08) !important;
  color: #ffffff !important;
}

/* Nav links — active */
.sidebar-simple .sb-nav ul li a.active {
  background: rgba(255,255,255,0.14) !important;
  color: #ffffff !important;
  font-weight: 600 !important;
}

/* Icons */
.sidebar-simple .sb-nav ul li a i {
  font-size: 17px !important;
  width: 20px !important;
  text-align: center !important;
  flex-shrink: 0 !important;
  color: inherit !important;
}

/* ── 6. Footer ── */
.sidebar-simple .sb-footer {
  flex-shrink: 0 !important;
  padding: 12px !important;
  border-top: 1px solid rgba(255,255,255,0.10) !important;
  position: relative;
  z-index: 30;
  overflow: visible !important;
}
.sidebar-simple .sb-footer .dropdown-menu {
  z-index: 1055;
}

/* ── 7. Premium promo card ── */
.sb-premium-card {
  background: linear-gradient(135deg, var(--primary) 0%, rgba(var(--primary-rgb), .65) 100%);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  text-align: center;
  color: #fff;
}
.sb-premium-card .sb-premium-icon { font-size: 22px; margin-bottom: 6px; display: block; }
.sb-premium-card h6 { color: #fff !important; font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.sb-premium-card p  { font-size: 11px; margin-bottom: 10px; opacity: .85; line-height: 1.4; color: #fff !important; }
.sb-premium-card .sb-upgrade-btn {
  display: inline-block;
  background: rgba(255,255,255,.22);
  border: 1px solid rgba(255,255,255,.5);
  border-radius: 20px;
  color: #fff !important;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 18px;
  text-decoration: none;
  transition: background .15s;
}
.sb-premium-card .sb-upgrade-btn:hover { background: rgba(255,255,255,.36); color: #fff !important; }

/* Compact variant — smaller padding/text */
.sb-premium-card--sm {
  padding: 10px 12px !important;
  margin-bottom: 8px !important;
  border-radius: 10px !important;
}
.sb-premium-card--sm .sb-premium-icon-sm { font-size: 18px; margin-bottom: 4px; display: block; }
.sb-premium-card--sm h6 { font-size: 12px !important; margin-bottom: 2px !important; }
.sb-premium-card--sm p  { font-size: 10px !important; margin-bottom: 8px !important; }
.sb-premium-card--sm .sb-upgrade-btn {
  font-size: 11px !important;
  padding: 4px 14px !important;
}

/* ── 8. User profile block ── */
.sb-user-block {
  display: flex !important;
  align-items: center !important;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s;
}
.sb-user-block:hover { background: rgba(255,255,255,0.08) !important; }
.sb-user-block .sb-user-info { flex: 1; min-width: 0; }
.sb-user-block .sb-user-name {
  display: block !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  color: #ffffff !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sb-user-block .sb-user-role {
  display: block !important;
  font-size: 11px !important;
  color: rgba(255,255,255,0.52) !important;
}
.sb-user-block .sb-chevron {
  color: rgba(255,255,255,0.42) !important;
  font-size: 14px;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════════
   LIGHT MODE — Warm cream/green theme overrides
   Matches the sidebar's dark green palette for a cohesive look.
   ═══════════════════════════════════════════════════════════════════════ */

/* Body & page background: warm cream */
[data-bs-theme="light"] body {
  background: #FAF7F2 !important;
}

/* Cards: pure white with warm shadow */
[data-bs-theme="light"] .card {
  background: #FFFFFF;
  border-color: #E8E2D9;
  box-shadow: 0 1px 6px rgba(180, 170, 155, 0.10);
}

/* Page wrapper content area */
[data-bs-theme="light"] .page-wrapper {
  background: #FAF7F2;
}

/* Site footer: full-width bar; content lines up with main column (sidebar sits above it) */
.app-site-footer {
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  z-index: 100 !important;
}
.app-site-footer .app-site-footer__inner {
  margin-left: var(--sidenav-width);
  transition: margin-left 0.2s ease;
}
@media (max-width: 991.98px) {
  .app-site-footer .app-site-footer__inner {
    margin-left: 0 !important;
  }
}
.mini-sidebar .app-site-footer .app-site-footer__inner {
  margin-left: var(--sidenav-width-sm) !important;
}

/* Primary buttons: dark forest green */
[data-bs-theme="light"] .btn-primary {
  background-color: #1B4332;
  border-color: #1B4332;
  color: #fff;
}
[data-bs-theme="light"] .btn-primary:hover,
[data-bs-theme="light"] .btn-primary:focus {
  background-color: #143D29;
  border-color: #143D29;
  color: #fff;
}

/* Outline primary buttons */
[data-bs-theme="light"] .btn-outline-primary {
  color: #1B4332;
  border-color: #1B4332;
}
[data-bs-theme="light"] .btn-outline-primary:hover {
  background-color: #1B4332;
  border-color: #1B4332;
  color: #fff;
}

/* Badge soft-primary */
[data-bs-theme="light"] .badge-soft-primary,
[data-bs-theme="light"] .badge.bg-primary-transparent {
  background: #E6F0EA !important;
  color: #1B4332 !important;
}

/* Links — dark green accent */
[data-bs-theme="light"] a:hover {
  color: #1B4332;
}
[data-bs-theme="light"] .text-primary {
  color: #1B4332 !important;
}
[data-bs-theme="light"] .link-primary {
  color: #1B4332 !important;
}
[data-bs-theme="light"] .link-primary:hover {
  color: #143D29 !important;
}

/* Table header warm tint */
[data-bs-theme="light"] .table thead th {
  background: #F5F1EB;
  color: #3D3830;
  border-bottom-color: #E2DDD5;
}

/* Form controls border matching warm palette */
[data-bs-theme="light"] .form-control,
[data-bs-theme="light"] .form-select {
  border-color: #E2DDD5;
  background: #FFFFFF;
}
[data-bs-theme="light"] .form-control:focus,
[data-bs-theme="light"] .form-select:focus {
  border-color: #1B4332;
  box-shadow: 0 0 0 0.2rem rgba(27, 67, 50, 0.15);
}

/* Breadcrumb & page header text */
[data-bs-theme="light"] .page-header h4,
[data-bs-theme="light"] .page-header h3 {
  color: #1A1612;
}
