/* ==========================================================================
   Paan & Chalia Shop Management System - Design Tokens & Core Stylesheet
   Mobile-First (360px) progressive enhancement to Desktop (1280px+)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Noto+Sans+Arabic:wght@400;600;700&display=swap');

/* --- Design Tokens (CSS Variables) --- */
:root {
  /* Brand & Mode Colors */
  --color-primary: #15803d; /* Paan Green */
  --color-primary-hover: #166534;
  --color-primary-light: #f0fdf4;
  --color-primary-border: #bbf7d0;

  --color-wholesale: #1e40af; /* Deep Wholesale Blue */
  --color-wholesale-light: #eff6ff;
  --color-wholesale-border: #bfdbfe;

  --color-retail: #047857; /* Retail Emerald */
  --color-retail-light: #ecfdf5;
  --color-retail-border: #a7f3d0;

  /* Neutrals & Dark Sidebar */
  --color-sidebar-bg: #0f172a;
  --color-sidebar-card: #1e293b;
  --color-sidebar-hover: #334155;
  --color-sidebar-text: #f8fafc;
  --color-sidebar-muted: #94a3b8;
  --color-sidebar-border: #334155;

  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-border-subtle: #f1f5f9;

  /* Typography Colors */
  --color-text-main: #0f172a;
  --color-text-muted: #64748b;
  --color-text-light: #94a3b8;
  --color-text-inverse: #ffffff;

  /* Functional Status Colors */
  --color-success: #16a34a;
  --color-success-bg: #f0fdf4;
  --color-success-border: #bbf7d0;

  --color-danger: #dc2626;
  --color-danger-bg: #fef2f2;
  --color-danger-border: #fecaca;

  --color-warning: #d97706;
  --color-warning-bg: #fffbeb;
  --color-warning-border: #fde68a;

  --color-info: #0284c7;
  --color-info-bg: #f0f9ff;
  --color-info-border: #bae6fd;

  /* Typography */
  --font-main: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-urdu: 'Noto Sans Arabic', 'Jameel Noori Nastaleeq', 'Urdu Typesetting', Tahoma, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Elevation / Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* Dimensions */
  --sidebar-width: 260px;
  --header-height: 60px;
  --mobile-nav-height: 64px;
  --min-tap-target: 44px;
}

/* --- Base & Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-main);
  background-color: var(--color-bg);
  color: var(--color-text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.urdu-text {
  font-family: var(--font-urdu);
  direction: rtl;
  text-align: right;
  font-size: 1.1em;
}

.icon {
  display: inline-block;
  vertical-align: -0.15em;
  flex-shrink: 0;
  stroke: currentColor;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--color-primary-hover);
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* --- App Layout Structure --- */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Desktop Sidebar (hidden on mobile by default) */
.app-sidebar {
  display: none;
}

/* Main Content Area */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-bottom: calc(var(--mobile-nav-height) + var(--space-4));
}

/* App Header */
.app-header {
  height: var(--header-height);
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-xs);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.header-shop-badge {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.shop-icon-circle {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #15803d, #047857);
  color: #fff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}

.shop-info-text {
  min-width: 0;
}

.shop-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.business-date-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.bdate-indicator {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background-color: var(--color-success);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 8px;
  border-radius: var(--radius-full);
  background-color: var(--color-border-subtle);
  font-size: 0.8rem;
  font-weight: 600;
}

.user-avatar-tiny {
  width: 26px;
  height: 26px;
  background-color: var(--color-sidebar-bg);
  color: #fff;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

.user-role-tag {
  text-transform: capitalize;
  font-size: 0.7rem;
  background: var(--color-primary-light);
  color: var(--color-primary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

/* Page Content Container */
.page-content {
  flex: 1;
  padding: var(--space-4);
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.page-header {
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.page-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--color-text-main);
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* --- Mobile Bottom Navigation --- */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--mobile-nav-height);
  background-color: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 50;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-nav-item {
  flex: 1;
  height: 100%;
  min-height: var(--min-tap-target);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
  gap: 2px;
  transition: all 0.15s ease;
  user-select: none;
}

.mobile-nav-item svg, .mobile-nav-item i {
  width: 22px;
  height: 22px;
  stroke-width: 2;
}

.mobile-nav-item.active {
  color: var(--color-primary);
}

.mobile-nav-item:active {
  background-color: var(--color-border-subtle);
}

.mobile-nav-item.highlight-sale {
  color: var(--color-primary);
  font-weight: 700;
}

/* --- Mobile "More" Drawer / Action Sheet --- */
.mobile-drawer-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  z-index: 60;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.mobile-drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

.mobile-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--color-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  max-height: 85vh;
  overflow-y: auto;
  z-index: 70;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  padding: var(--space-4) var(--space-4) calc(var(--space-6) + env(safe-area-inset-bottom, 0));
  box-shadow: var(--shadow-xl);
}

.mobile-drawer.open {
  transform: translateY(0);
}

.drawer-handle {
  width: 40px;
  height: 5px;
  background-color: var(--color-border);
  border-radius: var(--radius-full);
  margin: 0 auto var(--space-3);
}

.drawer-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: var(--space-3);
  color: var(--color-text-main);
}

.drawer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}

.drawer-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-3) var(--space-2);
  border-radius: var(--radius-md);
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  color: var(--color-text-main);
  text-align: center;
  min-height: 72px;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.drawer-card:active {
  background-color: var(--color-primary-light);
  border-color: var(--color-primary-border);
  color: var(--color-primary);
}

.drawer-card-icon {
  font-size: 1.4rem;
  line-height: 1;
}

/* --- Cards & Containers --- */
.card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: var(--space-4);
}

.card-header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1rem;
}

.card-body {
  padding: var(--space-4);
}

.card-footer {
  padding: var(--space-3) var(--space-4);
  background-color: var(--color-bg);
  border-top: 1px solid var(--color-border);
}

/* --- Stacked Cards on Mobile vs Desktop Tables --- */
.stack-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.data-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  box-shadow: var(--shadow-xs);
}

.data-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.data-card-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.data-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
}

.data-card-label {
  color: var(--color-text-muted);
}

.data-card-val {
  font-weight: 600;
}

/* Desktop Data Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.table th {
  background-color: var(--color-bg);
  padding: var(--space-3) var(--space-4);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
}

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border-subtle);
  vertical-align: middle;
}

.table tbody tr:hover {
  background-color: var(--color-bg);
}

/* Responsive Hide/Show Helpers */
.show-on-mobile { display: block !important; }
.hide-on-mobile { display: none !important; }

/* --- Forms & Numeric Inputs --- */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-main);
  margin-bottom: var(--space-1);
}

.form-control {
  width: 100%;
  min-height: var(--min-tap-target);
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: var(--color-surface);
  color: var(--color-text-main);
  font-size: 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.15);
}

.form-control::placeholder {
  color: var(--color-text-light);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--min-tap-target);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  user-select: none;
  text-align: center;
}

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

.btn-secondary {
  background-color: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text-main);
}
.btn-secondary:hover {
  background-color: var(--color-bg);
}

.btn-danger {
  background-color: var(--color-danger);
  color: #fff;
}
.btn-danger:hover {
  background-color: #b91c1c;
}

.btn-block {
  width: 100%;
}

.btn-lg {
  min-height: 52px;
  font-size: 1.05rem;
  padding: 14px 24px;
}

.btn-sm {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* Sticky Bottom Action Bar on Mobile */
.sticky-bottom-bar {
  position: sticky;
  bottom: var(--mobile-nav-height);
  left: 0;
  right: 0;
  background-color: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: var(--space-3) var(--space-4);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
  z-index: 30;
  display: flex;
  gap: var(--space-3);
}

/* --- Badges & Tags --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.badge-success { background: var(--color-success-bg); color: var(--color-success); border: 1px solid var(--color-success-border); }
.badge-danger { background: var(--color-danger-bg); color: var(--color-danger); border: 1px solid var(--color-danger-border); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); border: 1px solid var(--color-warning-border); }
.badge-info { background: var(--color-info-bg); color: var(--color-info); border: 1px solid var(--color-info-border); }
.badge-primary { background: var(--color-primary-light); color: var(--color-primary); border: 1px solid var(--color-primary-border); }

/* Rate Source Badges */
.tag-customer { background: #fdf2f8; color: #be185d; border: 1px solid #fbcfe8; }
.tag-slab { background: #f5f3ff; color: #6d28d9; border: 1px solid #ddd6fe; }
.tag-daily { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.tag-default { background: #f8fafc; color: #475569; border: 1px solid #e2e8f0; }
.tag-manual { background: #fff7ed; color: #c2410c; border: 1px solid #ffedd5; }

/* --- Alerts --- */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.9rem;
  position: relative;
}

.alert-success { background-color: var(--color-success-bg); border: 1px solid var(--color-success-border); color: #14532d; }
.alert-danger { background-color: var(--color-danger-bg); border: 1px solid var(--color-danger-border); color: #7f1d1d; }
.alert-warning { background-color: var(--color-warning-bg); border: 1px solid var(--color-warning-border); color: #78350f; }
.alert-info { background-color: var(--color-info-bg); border: 1px solid var(--color-info-border); color: #0c4a6e; }

.alert-icon {
  font-size: 1.1rem;
  font-weight: bold;
}

.alert-message {
  flex: 1;
}

.alert-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: inherit;
  opacity: 0.7;
}
.alert-close:hover { opacity: 1; }

/* --- Login Screen Styling --- */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: radial-gradient(circle at top, #1e293b 0%, #0f172a 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-xl);
}

.login-header {
  text-align: center;
  margin-bottom: var(--space-6);
}

.login-logo-circle {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #15803d, #047857);
  color: #fff;
  border-radius: var(--radius-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 800;
  margin-bottom: var(--space-3);
  box-shadow: 0 4px 12px rgba(21, 128, 61, 0.3);
}

.login-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--color-text-main);
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* ==========================================================================
   Desktop Responsive Enhancements (>= 992px)
   ========================================================================== */
@media (min-width: 992px) {
  /* Sidebar Visible */
  .app-sidebar {
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    background-color: var(--color-sidebar-bg);
    color: var(--color-sidebar-text);
    height: 100vh;
    position: sticky;
    top: 0;
    flex-shrink: 0;
    border-right: 1px solid var(--color-sidebar-border);
    z-index: 50;
    overflow-y: auto;
  }

  .sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 var(--space-5);
    border-bottom: 1px solid var(--color-sidebar-border);
    gap: var(--space-3);
  }

  .sidebar-logo-icon {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, #15803d, #047857);
    color: #fff;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 17px;
  }

  .sidebar-brand-title {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #fff;
  }

  .sidebar-nav {
    flex: 1;
    padding: var(--space-4) var(--space-3);
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .nav-group-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-sidebar-muted);
    padding: var(--space-3) var(--space-3) var(--space-1);
  }

  .nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 9px 12px;
    border-radius: var(--radius-md);
    color: var(--color-sidebar-muted);
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.15s ease;
    text-decoration: none;
  }

  .nav-link:hover {
    background-color: var(--color-sidebar-card);
    color: #fff;
  }

  .nav-link.active {
    background-color: var(--color-primary);
    color: #fff;
  }

  .nav-link-icon {
    width: 20px;
    font-size: 1.1rem;
    text-align: center;
  }

  .sidebar-footer {
    padding: var(--space-4);
    border-top: 1px solid var(--color-sidebar-border);
    background-color: rgba(0, 0, 0, 0.2);
  }

  .user-footer-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .user-footer-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
  }

  /* Main area adjusts padding */
  .app-main {
    padding-bottom: var(--space-6);
  }

  /* Hide Mobile Bottom Nav on Desktop */
  .mobile-bottom-nav,
  .mobile-drawer-overlay,
  .mobile-drawer {
    display: none !important;
  }

  /* Show tables, hide stacked cards */
  .show-on-mobile { display: none !important; }
  .hide-on-mobile { display: block !important; }

  /* Sticky Bottom Bar on desktop rests at viewport bottom */
  .sticky-bottom-bar {
    bottom: 0;
  }
}

/* ==========================================================================
   Sub-Navigation (Module Tabs)
   ========================================================================== */
.sub-nav {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.sub-nav-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  white-space: nowrap;
  transition: all 0.15s ease;
}

.sub-nav-link:hover {
  background-color: var(--color-bg);
  color: var(--color-text-main);
}

.sub-nav-link.active {
  background-color: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-xs);
}

/* --- Filter & Search Bar --- */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

@media (min-width: 640px) {
  .filter-bar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.search-input-group {
  position: relative;
  flex: 1;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-light);
  font-size: 0.9rem;
  pointer-events: none;
}

.search-input {
  padding-left: 36px !important;
}

/* --- Grid Form Rows --- */
.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

@media (min-width: 640px) {
  .form-row-2 { grid-template-columns: repeat(2, 1fr); }
  .form-row-3 { grid-template-columns: repeat(3, 1fr); }
  .form-row-4 { grid-template-columns: repeat(4, 1fr); }
}

/* --- Custom Modals --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  width: 100%;
  max-width: 500px;
  background-color: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.open .modal-box {
  transform: scale(1);
}

.modal-header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1.1rem;
}

.modal-body {
  padding: var(--space-4);
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: var(--space-3) var(--space-4);
  background-color: var(--color-bg);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* Inline Dynamic Units Table */
.inline-unit-row {
  display: grid;
  grid-template-columns: 1.8fr 1.2fr 1fr 1fr 1fr 40px;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border-subtle);
}

@media (max-width: 768px) {
  .inline-unit-row {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    background: var(--color-bg);
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    margin-bottom: 10px;
  }
}

/* ==========================================================================
   Empty States Component
   ========================================================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-8) var(--space-4);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--color-border);
  margin: var(--space-4) 0;
}

.empty-state-icon {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: var(--space-3);
  opacity: 0.85;
}

.empty-state-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-text-main);
  margin-bottom: var(--space-1);
}

.empty-state-desc {
  font-size: 0.88rem;
  color: var(--color-text-muted);
  max-width: 420px;
  margin: 0 auto var(--space-4) auto;
  line-height: 1.45;
}

.empty-state-action {
  display: inline-flex;
  gap: var(--space-2);
}

/* ==========================================================================
   Global Header Search & Modal
   ========================================================================== */
.header-search-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 38px;
}

.header-search-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-text-main);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.search-kbd-hint {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  padding: 2px 5px;
  color: var(--color-text-muted);
}

.global-search-modal-box {
  width: 92%;
  max-width: 620px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--color-primary-border);
}

.global-search-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

.global-search-header input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1.05rem;
  outline: none;
  color: var(--color-text-main);
  font-family: var(--font-main);
}

.global-search-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) var(--space-4);
  max-height: 60vh;
}

.search-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  margin-top: var(--space-3);
  margin-bottom: var(--space-2);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--color-border-subtle);
}

.search-item-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--color-text-main);
  transition: background 0.15s ease;
  margin-bottom: 4px;
  border: 1px solid transparent;
}

.search-item-link:hover,
.search-item-link.selected {
  background: var(--color-primary-light);
  border-color: var(--color-primary-border);
}

.search-item-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.search-item-sub {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.search-item-badge {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

/* ==========================================================================
   Dashboard Components & Interactive Dual Series Chart
   ========================================================================== */
.dashboard-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.kpi-link-card {
  text-decoration: none;
  color: inherit;
  display: block;
}

.kpi-link-card .kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-xs);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  height: 100%;
}

.kpi-link-card:hover .kpi-card {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
}

.kpi-top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.kpi-top-bar.primary { background: var(--color-primary); }
.kpi-top-bar.wholesale { background: var(--color-wholesale); }
.kpi-top-bar.retail { background: var(--color-retail); }
.kpi-top-bar.warning { background: var(--color-warning); }
.kpi-top-bar.danger { background: var(--color-danger); }
.kpi-top-bar.info { background: var(--color-info); }

.kpi-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}

.kpi-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.kpi-icon {
  font-size: 1.25rem;
}

.kpi-amount {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--color-text-main);
  line-height: 1.2;
}

.kpi-sub-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin-top: var(--space-2);
  font-size: 0.78rem;
  flex-wrap: wrap;
}

.rate-warning-banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 5px solid #d97706;
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.chart-card-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-xs);
}

.chart-legend-box {
  display: flex;
  gap: var(--space-4);
  align-items: center;
  font-size: 0.82rem;
  font-weight: 600;
  flex-wrap: wrap;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
}

.legend-dot.wholesale { background: #1e40af; }
.legend-dot.retail { background: #059669; }

.svg-chart-container {
  width: 100%;
  height: 220px;
  margin-top: var(--space-3);
}

/* ==========================================================================
   Settings Logo Uploader
   ========================================================================== */
.logo-upload-zone {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3);
  background: var(--color-bg);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  flex-wrap: wrap;
}

.logo-preview-box {
  width: 90px;
  height: 90px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.logo-preview-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.prefix-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-3);
}

/* ==========================================================================
   POS (Point of Sale) — Full-Page Dual-Mode Interface
   ========================================================================== */

/* Remove the page padding so POS fills the full viewport height */
.main-content:has(.pos-workspace) {
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.pos-workspace {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--color-bg);
}

/* --- Top Mode Bar --- */
.pos-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface);
  border-bottom: 2px solid var(--color-border);
  flex-shrink: 0;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.pos-mode-toggle {
  display: flex;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid var(--color-border);
  background: var(--color-bg);
}

.btn-mode {
  padding: 7px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.btn-mode.active {
  background: var(--color-primary);
  color: #fff;
}

.btn-mode.active.wholesale-mode {
  background: var(--color-wholesale);
}

.pos-mode-indicator-badge {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border: 1px solid var(--color-primary-border);
  white-space: nowrap;
}

.pos-mode-indicator-badge.wholesale-mode {
  background: var(--color-wholesale-light);
  color: var(--color-wholesale);
  border-color: var(--color-wholesale-border);
}

/* --- Main Layout: Left Catalog + Right Cart --- */
.pos-layout-grid {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* LEFT: Product catalog panel */
.pos-catalog-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: var(--space-3);
  overflow: hidden;
}

/* Category pills row */
.pos-category-pills {
  display: flex;
  gap: var(--space-1);
  overflow-x: auto;
  flex-shrink: 0;
  padding-bottom: var(--space-2);
  scrollbar-width: none;
  margin-bottom: var(--space-3);
}

.pos-category-pills::-webkit-scrollbar {
  display: none;
}

.cat-pill {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  color: var(--color-text-muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  min-height: 32px;
}

.cat-pill.active,
.cat-pill:hover {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

/* Product cards grid */
.pos-products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-2);
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding-right: 2px;
  align-content: start;
}

.pos-product-card {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-2);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  display: flex;
  flex-direction: column;
  gap: 4px;
  user-select: none;
  min-height: 90px;
  position: relative;
}

.pos-product-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(21, 128, 61, 0.15);
  transform: translateY(-1px);
}

.pos-product-card:active {
  transform: scale(0.97);
}

.pos-prod-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 4px;
}

.pos-prod-stock {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--color-success);
  font-family: var(--font-mono);
  text-align: right;
  white-space: nowrap;
}

.pos-prod-stock.out {
  color: var(--color-danger);
}

.pos-prod-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-main);
  line-height: 1.2;
  margin-top: 2px;
}

.pos-prod-urdu {
  font-size: 0.78rem;
  color: var(--color-primary);
}

.pos-prod-price-box {
  margin-top: auto;
  padding-top: 4px;
}

.pos-prod-price {
  font-size: 0.9rem;
  font-weight: 900;
  color: var(--color-primary);
  font-family: var(--font-mono);
  line-height: 1;
}

.pos-prod-price small {
  font-weight: 500;
  font-size: 0.65rem;
  color: var(--color-text-muted);
}

/* Wholesale mode card highlight */
.pos-workspace.ws-mode .pos-product-card:hover {
  border-color: var(--color-wholesale);
  box-shadow: 0 2px 8px rgba(30, 64, 175, 0.15);
}

/* RIGHT: Cart panel (desktop only) */
.pos-cart-panel {
  width: 320px;
  min-width: 280px;
  max-width: 360px;
  flex-shrink: 0;
  border-left: 2px solid var(--color-border);
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  overflow: hidden;
}

.pos-cart-items-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) var(--space-3);
  min-height: 0;
}

.pos-empty-cart {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-4);
  color: var(--color-text-muted);
  text-align: center;
  height: 100%;
  min-height: 120px;
}

.pos-cart-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border-subtle);
}

.pos-cart-item-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-main);
}

.pos-cart-item-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.pos-cart-qty-input {
  width: 64px;
  text-align: center;
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  padding: 4px 6px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.pos-cart-rate-input {
  width: 80px;
  text-align: right;
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  padding: 4px 6px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.pos-cart-item-amount {
  margin-left: auto;
  font-size: 0.9rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--color-text-main);
  white-space: nowrap;
}

.pos-cart-remove-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-danger);
  font-size: 1rem;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  line-height: 1;
}

.pos-cart-footer {
  padding: var(--space-3);
  border-top: 2px solid var(--color-border);
  flex-shrink: 0;
  background: var(--color-surface);
}

/* --- Preset chips in product sheet --- */
.pos-preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pos-preset-chip {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--color-border);
  background: var(--color-bg);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: background 0.15s, color 0.15s;
}

.pos-preset-chip:hover {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

/* --- Mobile Cart Sticky Bar --- */
.pos-mobile-cart-bar {
  position: fixed;
  bottom: 56px; /* above mobile nav */
  left: 0;
  right: 0;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  z-index: 90;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.15);
}

/* --- Responsive overrides for mobile --- */
@media (max-width: 767px) {
  .pos-top-bar {
    padding: var(--space-2);
    gap: var(--space-1);
  }

  .pos-mode-toggle {
    width: 100%;
  }

  .btn-mode {
    flex: 1;
    font-size: 0.8rem;
    padding: 8px 8px;
  }

  .pos-catalog-panel {
    padding: var(--space-2);
    /* leave room for the sticky cart bar at bottom */
    padding-bottom: 72px;
  }

  .pos-products-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: var(--space-1);
  }

  .pos-product-card {
    min-height: 80px;
    padding: var(--space-1);
  }

  .pos-prod-name {
    font-size: 0.78rem;
  }

  .pos-prod-price {
    font-size: 0.82rem;
  }

  .hide-on-mobile {
    display: none !important;
  }
}

@media (min-width: 768px) {
  .show-on-mobile {
    display: none !important;
  }

  .pos-products-grid {
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  }
}

@media (min-width: 1024px) {
  .pos-products-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }

  .pos-cart-panel {
    width: 340px;
  }
}

