/* ==========================================================================
   Pak POS Master - Design System & Global Stylesheet
   Zero-Scroll Fluid Responsive Layout & Collapsible Persistent Sidebar
   ========================================================================== */

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

:root {
  --primary: #059669;
  --primary-hover: #047857;
  --primary-light: #ecfdf5;
  --primary-dark: #064e3b;
  
  --secondary: #0f172a;
  --secondary-light: #1e293b;
  --secondary-hover: #334155;
  
  --accent: #f59e0b;
  --accent-light: #fef3c7;
  
  --danger: #e11d48;
  --danger-light: #ffe4e6;
  
  --info: #0284c7;
  --info-light: #e0f2fe;
  
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-white: #ffffff;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  --sidebar-width: 250px;
  --sidebar-collapsed-width: 70px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Hide all horizontal scrollbars completely */
::-webkit-scrollbar {
  width: 5px;
  height: 0px !important;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

html, body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden !important;
}

.urdu-font {
  font-family: 'Noto Nastaliq Urdu', serif;
  direction: rtl;
}

/* App Layout */
.app-wrapper {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
  overflow-x: hidden !important;
}

/* Sidebar (Full & Collapsed Modes) */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--secondary);
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

/* Collapsed Desktop Sidebar Mode */
.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .sidebar-header h2,
.sidebar.collapsed .sidebar-header small,
.sidebar.collapsed .menu-category,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .nav-link .badge,
.sidebar.collapsed .sidebar-footer .user-profile-badge div {
  display: none !important;
}

.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 1.1rem 0;
}

.sidebar.collapsed .nav-link {
  justify-content: center;
  padding: 0.75rem 0;
}

.sidebar.collapsed .nav-link i {
  font-size: 1.25rem;
  margin: 0;
}

.sidebar-header {
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background-color: #0b1120;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.sidebar-header img {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.sidebar-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.02em;
  margin: 0;
  white-space: nowrap;
}

.sidebar-header small {
  display: block;
  font-size: 0.7rem;
  color: #34d399;
  font-weight: 500;
  white-space: nowrap;
}

.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem 0.65rem;
}

.menu-category {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 0.65rem 0.65rem 0.2rem;
  white-space: nowrap;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  margin-bottom: 0.15rem;
  white-space: nowrap;
}

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

.nav-link:hover {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.06);
}

.nav-link.active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.35);
}

.nav-link .badge {
  margin-left: auto;
  font-size: 0.65rem;
  padding: 0.15rem 0.45rem;
  border-radius: 9999px;
  background-color: var(--accent);
  color: #78350f;
  font-weight: 700;
}

.sidebar-footer {
  padding: 0.85rem;
  background-color: #0b1120;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 0.75rem;
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.82rem;
  flex-shrink: 0;
}

.logout-link {
  color: #ef4444;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  border: 1px solid rgba(239, 68, 68, 0.2);
  background: rgba(239, 68, 68, 0.05);
  transition: all 0.2s;
}

.logout-link:hover {
  background-color: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: calc(100% - var(--sidebar-width));
  max-width: calc(100% - var(--sidebar-width));
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1), width 0.25s cubic-bezier(0.4, 0, 0.2, 1), max-width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-x: hidden !important;
}

/* Main Wrapper Expanded when Sidebar is Collapsed */
.main-wrapper.expanded {
  margin-left: var(--sidebar-collapsed-width);
  width: calc(100% - var(--sidebar-collapsed-width));
  max-width: calc(100% - var(--sidebar-collapsed-width));
}

/* Top Navbar */
.topbar {
  height: 64px;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
  width: 100%;
}

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

.btn-toggle-sidebar {
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  cursor: pointer;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-toggle-sidebar:hover {
  background-color: #e2e8f0;
  color: var(--primary-dark);
}

.branch-select-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  background-color: var(--primary-light);
  border: 1px solid #a7f3d0;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary-dark);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.quick-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-pos {
  background: linear-gradient(135deg, var(--primary) 0%, #047857 100%);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(5, 150, 105, 0.25);
}

.btn-pos:hover {
  background: linear-gradient(135deg, #047857 0%, #065f46 100%);
  color: #ffffff;
}

.btn-outline-action {
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-outline-action:hover {
  background-color: var(--bg-main);
  border-color: #cbd5e1;
}

/* Action Button Mini Icons (Edit / Delete / Print) */
.btn-action-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  background: #ffffff;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-action-icon.edit-btn { color: var(--info); }
.btn-action-icon.edit-btn:hover { background: var(--info-light); border-color: var(--info); }

.btn-action-icon.delete-btn { color: var(--danger); }
.btn-action-icon.delete-btn:hover { background: var(--danger-light); border-color: var(--danger); }

.btn-action-icon.print-btn { color: var(--text-main); }
.btn-action-icon.print-btn:hover { background: #f1f5f9; border-color: #94a3b8; }

/* Page Container */
.page-container {
  padding: 1.25rem;
  flex: 1;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden !important;
}

/* Command Center Launchpad Grid */
.launchpad-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.launchpad-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.launchpad-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.launchpad-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.launchpad-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.launchpad-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--secondary);
  margin-bottom: 0.35rem;
}

.launchpad-card p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
  flex: 1;
}

.launchpad-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  background: #f1f5f9;
  color: #475569;
}

/* KPI Cards Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
  width: 100%;
}

.kpi-card {
  background-color: var(--bg-card);
  padding: 1rem 1.15rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: transform 0.2s ease;
  min-width: 0;
}

.kpi-card:hover {
  transform: translateY(-2px);
}

.kpi-info {
  min-width: 0;
  overflow: hidden;
}

.kpi-info h4 {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-info .amount {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.kpi-info .urdu-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  margin-left: 0.5rem;
}

.icon-emerald { background-color: var(--primary-light); color: var(--primary); }
.icon-amber { background-color: var(--accent-light); color: var(--accent); }
.icon-rose { background-color: var(--danger-light); color: var(--danger); }
.icon-blue { background-color: var(--info-light); color: var(--info); }
.icon-purple { background-color: #f3e8ff; color: #9333ea; }

/* Content Cards & Data Tables */
.card {
  background-color: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
  overflow: hidden;
  width: 100%;
}

.card-header {
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #ffffff;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.card-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.card-body {
  padding: 1.15rem;
}

/* Fluid Table Container (No Horizontal Scrollbars) */
.table-responsive {
  width: 100%;
  overflow-x: hidden !important;
}

.table-custom {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.82rem;
  table-layout: auto;
}

.table-custom th {
  background-color: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  white-space: normal;
}

.table-custom td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
  white-space: normal;
  word-break: break-word;
}

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

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 9999px;
  white-space: nowrap;
}

.badge-success { background-color: var(--primary-light); color: var(--primary-dark); }
.badge-warning { background-color: var(--accent-light); color: #92400e; }
.badge-danger { background-color: var(--danger-light); color: #9f1239; }
.badge-info { background-color: var(--info-light); color: #075985; }
.badge-secondary { background-color: #f1f5f9; color: #475569; }

/* Custom Forms & Controls */
.form-group {
  margin-bottom: 0.85rem;
}

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

.form-control, .form-select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-size: 0.84rem;
  font-family: inherit;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: #ffffff;
  color: var(--text-main);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 1rem;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background-color: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.25s ease;
}

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

.modal-header {
  padding: 0.95rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #f8fafc;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
}

.btn-close-modal {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
}

.modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
  background-color: #f8fafc;
}

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background-color: #ffffff;
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.05);
  z-index: 90;
  justify-content: space-around;
  align-items: center;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 600;
  gap: 0.15rem;
  flex: 1;
}

.mobile-nav-item i {
  font-size: 1.15rem;
}

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

.mobile-pos-center {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #ffffff !important;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -18px;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.4);
}

/* ==========================================================================
   Universal Print Stylesheet (Clean A4 / Letter Reports)
   ========================================================================== */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .sidebar, .topbar, .mobile-bottom-nav, .quick-action-btn, .modal-overlay, .btn-action-icon, .shortcuts-footer {
    display: none !important;
  }
  .main-wrapper {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .page-container {
    padding: 0 !important;
  }
  .card {
    border: none !important;
    box-shadow: none !important;
  }
  .card-header {
    border-bottom: 2px solid #000 !important;
  }
  .table-custom th, .table-custom td {
    border-bottom: 1px solid #ddd !important;
  }
}

/* ==========================================================================
   Responsive Breakpoints: Completely Fluid on Mobile & Tablets
   ========================================================================== */
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
  }
  
  .sidebar.show {
    transform: translateX(0);
  }
  
  .main-wrapper, .main-wrapper.expanded {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  
  .mobile-bottom-nav {
    display: flex;
  }
  
  .page-container {
    padding: 0.85rem 0.75rem 4.5rem 0.75rem;
  }
  
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
  }
  
  .kpi-card {
    padding: 0.75rem 0.85rem;
  }
  
  .kpi-info .amount {
    font-size: 1.1rem;
  }
}

@media (max-width: 576px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  
  .topbar {
    padding: 0 0.75rem;
  }
  
  .branch-select-pill span {
    display: none;
  }

  .quick-action-btn span {
    display: none;
  }

  .quick-action-btn {
    padding: 0.45rem 0.6rem;
  }

  .table-custom {
    font-size: 0.75rem;
  }

  .table-custom th, .table-custom td {
    padding: 0.5rem 0.4rem;
  }
}
