/* 
   Sales System Premium Theme 
   Glassmorphism + Modern Professional 
*/

:root {
  /* Colors - Modern Dark/Blue Theme */
  --primary: #4361ee;
  --primary-hover: #3a56d4;
  --secondary: #3f37c9;
  --accent: #4895ef;
  --success: #4cc9f0;
  --danger: #f72585;
  --warning: #f8961e;
  --info: #480ca8;

  --bg-body: #f0f2f5;
  --bg-card: #ffffff;
  --text-main: #2b2d42;
  --text-muted: #8d99ae;
  --border: #e9ecef;

  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.5);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

  --radius: 12px;
  --transition: all 0.3s ease;
}

/* Dark Mode Support (Class-based toggle if needed later, using sleek dark defaults for sidebar) */
.dark-theme {
  --bg-body: #0f172a;
  --bg-card: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border: #334155;
  --glass-bg: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family:
    "Segoe UI",
    system-ui,
    -apple-system,
    sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
  margin: 0;
}

/* Global Responsiveness for Screens < 1400px (MacBooks) */
@media screen and (max-width: 1400px) {
    .sidebar { width: 220px !important; }
    .main-content { padding: 1.5rem !important; }
    .page-title { font-size: 1.4rem !important; }
    .stat-card { padding: 1rem !important; gap: 0.75rem !important; }
    .stat-icon { width: 50px !important; height: 50px !important; font-size: 1.2rem !important; }
    th, td { padding: 0.75rem 0.5rem !important; font-size: 0.85rem !important; }
}

/* --- Custom Scrollbar (Modern & Visible) --- */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #ffffff; /* High contrast white */
    border-radius: 10px;
    border: 3px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background: #e2e8f0;
}

/* Firefox support */
* {
    scrollbar-width: thin;
    scrollbar-color: #ffffff rgba(0, 0, 0, 0.2);
}

/* --- Layout --- */
#app {
  display: flex;
  width: 100%;
  height: 100%;
}

.sidebar {
  width: 260px;
  background: var(--sidebar-bg, linear-gradient(180deg, #1a1c23 0%, #252836 100%));
  color: var(--sidebar-text, #ffffff);
  display: flex;
  flex-direction: column;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 4px 0 15px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  position: relative;
  overflow: hidden !important;
  height: 100vh !important;
  display: flex !important;
  flex-direction: column !important;
  flex-shrink: 0;
}

/* Auto-collapse sidebar on smaller laptops (MacBook Air/Pro 13-14") */
@media screen and (max-width: 1280px) {
  .sidebar { 
    width: 70px !important; 
  }
  
  /* Brand Adjustment */
  .sidebar .brand {
    padding: 1.5rem 0 !important;
    justify-content: center !important;
    border-bottom-color: rgba(255,255,255,0.1) !important;
  }
  .sidebar .brand div:not(:first-child) { display: none !important; }
  .sidebar .brand i { font-size: 1.6rem !important; margin: 0 !important; }

  /* Nav Links / Section Titles */
  .sidebar .nav-section-title {
    padding: 0 !important;
    margin: 1rem 12px !important;
    height: 1px !important;
    background: rgba(255,255,255,0.1) !important;
    overflow: hidden !important;
    border: none !important;
  }
  .sidebar .nav-section-title * { display: none !important; }

  /* Force content visibility and ENABLE CLICKS */
  .sidebar .nav-section-content {
    max-height: none !important;
    opacity: 1 !important;
    display: block !important;
    pointer-events: all !important; /* CRITICAL FIX: restores interactivity */
  }

  .sidebar .nav-link { 
    justify-content: center !important; 
    padding: 0 !important; 
    margin: 0.4rem auto !important;
    border-radius: 12px !important;
    font-size: 0 !important;
    height: 44px !important;
    width: 44px !important;
    display: flex !important;
    align-items: center !important;
    transition: all 0.2s ease !important;
  }
  .sidebar .nav-link span { display: none !important; }
  .sidebar .nav-link i { 
    font-size: 1.3rem !important; 
    margin: 0 !important; 
  }
  
  .sidebar .nav-link:hover { 
    transform: scale(1.1) !important;
    background: rgba(255, 255, 255, 0.15) !important;
  }

  /* Profile */
  .sidebar .user-profile {
    padding: 1.25rem 0 !important;
    justify-content: center !important;
  }
  .sidebar .user-profile div:not(.user-avatar) { display: none !important; }
}

.brand {
  padding: 2rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--sidebar-border, rgba(255, 255, 255, 0.05));
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.brand span {
  color: #fff;
}

.nav-links {
  list-style: none;
  flex: 1 1 0%; /* Allow shrinking */
  overflow-y: auto !important;
  overflow-x: hidden;
  min-height: 0;
  padding: 0 10px 2rem 0; /* Right padding for scrollbar */
  margin: 0;
}

.desktop-topbar .topbar-btn {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: background 0.2s ease, transform 0.1s ease;
  padding: 0.5rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.desktop-topbar .topbar-btn:hover {
  background: rgba(0,0,0,0.05) !important;
  color: var(--primary);
}

.sidebar.sidebar-collapsed {
  width: 80px;
  padding: 1.5rem 0.5rem;
}

.sidebar.sidebar-collapsed .brand span,
.sidebar.sidebar-collapsed .brand div,
.sidebar.sidebar-collapsed .nav-section-title span,
.sidebar.sidebar-collapsed .nav-section-title i.chevron,
.sidebar.sidebar-collapsed .user-profile > div:nth-child(2) {
  display: none !important;
}

.sidebar.sidebar-collapsed .nav-link span {
  display: none;
}

.sidebar.sidebar-collapsed .nav-link {
  justify-content: center;
  padding: 1rem 0;
  font-size: 0; /* Hide raw text nodes */
}

.sidebar.sidebar-collapsed .nav-link i {
  font-size: 1.2rem;
  margin: 0;
}

.sidebar.sidebar-collapsed .nav-section-title {
  padding-left: 0;
  padding-right: 0;
  justify-content: center;
}

.sidebar.sidebar-collapsed .user-profile {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.nav-item {
  margin-bottom: 0.5rem;
}

.nav-section-title {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--sidebar-text-muted, #718096);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 1.25rem 1rem 0.6rem;
  margin-top: 0.15rem;
  border-top: 1px solid var(--sidebar-border, rgba(255, 255, 255, 0.05));
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
}

.nav-section-title:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.02);
}

.nav-section-title span {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-section-title i:not(.chevron) {
  width: 18px;
  text-align: center;
}

.nav-section-title i.chevron {
  transition: transform 0.3s ease;
  font-size: 0.7rem;
}

.nav-section-title.collapsed i.chevron {
  transform: rotate(-90deg);
}

.nav-section-title:first-child {
  padding-top: 0.5rem;
  margin-top: 0;
  border-top: none;
}

.nav-section-content {
  max-height: 1000px;
  overflow: hidden;
  transition: max-height 0.3s ease-in-out, opacity 0.2s ease;
  opacity: 1;
}

.nav-section-content.collapsed {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  color: var(--sidebar-text, rgba(255, 255, 255, 0.7));
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
  border-radius: 12px;
  margin: 0.2rem 0;
  font-size: 0.95rem;
  position: relative;
}

.nav-link:hover {
  background: var(--sidebar-hover, rgba(255, 255, 255, 0.08));
  color: var(--sidebar-text-active, #fff);
  transform: translateX(5px);
}

.nav-link.active {
  background: var(--sidebar-active-bg, var(--primary));
  color: var(--sidebar-active-text, #fff);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.nav-link i {
  width: 20px;
  text-align: center;
}

.user-profile {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--sidebar-border, rgba(255, 255, 255, 0.05));
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--sidebar-profile-bg, transparent);
  flex-shrink: 0;
}

.user-avatar {
  width: 40px;
  height: 40px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

/* Main Content */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  position: relative;
  background-image:
    radial-gradient(
      circle at 10% 20%,
      rgba(67, 97, 238, 0.05) 0%,
      transparent 20%
    ),
    radial-gradient(
      circle at 90% 80%,
      rgba(72, 149, 239, 0.05) 0%,
      transparent 20%
    );
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.page-title {
  font-size: 1.8rem;
  font-weight: 600;
}

/* --- Components --- */
.card {
  background: var(--bg-card);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  padding: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 1.5rem;
  transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
  position: relative;
  overflow: hidden;
}

.card:hover {
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
  transform: translateY(-4px);
  border-color: rgba(67, 97, 238, 0.2);
}

.card-glass {
  background: rgba(255, 255, 255, 0.03) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Dashboard Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

/* Color Utils */
.bg-soft-primary { background: rgba(67, 97, 238, 0.1) !important; }
.bg-soft-success { background: rgba(76, 201, 240, 0.1) !important; }
.bg-soft-danger  { background: rgba(247, 37, 133, 0.1) !important; }
.bg-soft-warning { background: rgba(248, 150, 30, 0.1) !important; }
.bg-soft-info    { background: rgba(72, 12, 168, 0.1) !important; }

.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info    { color: var(--info) !important; }

.stat-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.5rem;
  background: var(--bg-card);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.stat-icon {
  width: 65px;
  height: 65px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.stat-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.stat-info h3 {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}

.stat-info p {
  font-size: clamp(1.2rem, 1.5vw, 1.6rem);
  font-weight: 800;
  color: var(--text-main);
  margin: 0;
  letter-spacing: -0.5px;
  white-space: nowrap;
}

@media (max-width: 1400px) {
  .stat-info p {
    font-size: 1.15rem;
  }
}

/* Dashboard Charts */
.dashboard-charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

.chart-card {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.chart-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
}

.chart-header i {
  color: var(--text-muted);
  cursor: pointer;
}

.chart-body {
  flex: 1;
  position: relative;
  height: 320px;
}

@media (max-width: 768px) {
  .dashboard-charts-grid {
    grid-template-columns: 1fr;
  }
}

/* Tables */
.table-container {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
  position: relative;
  scrollbar-width: thin;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.table-container::-webkit-scrollbar {
  height: 8px;
}
.table-container::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 10px;
}
.table-container::-webkit-scrollbar-track {
  background: #f1f5f9;
}

/* Force scroll on data-heavy tables */
.table-container table {
  min-width: 1000px;
}

/* Modals with scroll context */
.modal-content {
  padding: 1.5rem !important;
  overflow-y: auto;
  flex: 1;
}

@media screen and (max-width: 1366px) {
    .main-content { padding: 1rem !important; }
    .card { padding: 1rem !important; }
    table th, table td { padding: 0.6rem !important; font-size: 0.85rem !important; }
}

th,
td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

tr:hover {
  background-color: rgba(67, 97, 238, 0.02);
}

.badge {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success {
  background: rgba(76, 201, 240, 0.15);
  color: #0096c7;
}

.badge-warning {
  background: rgba(248, 150, 30, 0.15);
  color: #e85d04;
}

.badge-danger {
  background: rgba(247, 37, 133, 0.15);
  color: #d00000;
}

/* Buttons */
.btn {
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 6px rgba(67, 97, 238, 0.2);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.btn-form {
  min-width: 200px;
  display: flex !important;
  justify-content: center;
  align-items: center;
  margin: 1.5rem auto 0 auto;
  padding: 0.8rem 1.5rem !important;
  border-radius: 50px !important; /* Premium rounded look */
  font-size: 1rem;
}

.btn-outline {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-main);
  backdrop-filter: blur(4px);
}

.btn-secondary {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #475569;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.btn-secondary:hover {
  background: #fff;
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.btn-export {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid #e1e8ed;
  color: #555;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  border-radius: 10px;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
}

.btn-export:hover {
  background: white;
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 5px 15px rgba(67, 97, 238, 0.1);
  transform: translateY(-2px);
}

.btn-export i {
  font-size: 1rem;
}

.btn-export.pdf { color: #e74c3c; }
.btn-export.excel { color: #27ae60; }

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.btn-premium {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white !important;
  border: none;
  box-shadow: 0 4px 15px rgba(67, 97, 238, 0.3);
  padding: 0.8rem 1.5rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-premium:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(67, 97, 238, 0.4);
}

.btn-premium-success {
  background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
  color: white !important;
  border: none;
  box-shadow: 0 4px 15px rgba(46, 204, 113, 0.3);
  padding: 0.8rem 1.5rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-premium-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(46, 204, 113, 0.4);
}

input,
select,
textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.8);
  transition: var(--transition);
}

/* Fix for invisible dropdown options */
select option {
  color: var(--text-main);
  background-color: white;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

/* Login Screen */
.login-container {
  height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  position: relative;
  overflow: hidden;
}

/* Background Abstract Shapes */
.login-container::before {
  content: "";
  position: absolute;
  width: 600px;
  height: 600px;
  top: -100px;
  left: -100px;
  background: radial-gradient(
    circle,
    rgba(67, 97, 238, 0.2) 0%,
    transparent 70%
  );
  border-radius: 50%;
  z-index: 1;
}

.login-container::after {
  content: "";
  position: absolute;
  width: 500px;
  height: 500px;
  bottom: -100px;
  right: -100px;
  background: radial-gradient(
    circle,
    rgba(247, 37, 133, 0.15) 0%,
    transparent 70%
  );
  border-radius: 50%;
  z-index: 1;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  color: white;
  z-index: 2;
  padding: 2.5rem;
  border-radius: 20px;
}

.login-card h2 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(to right, #fff, #94a3b8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-card p {
  color: #94a3b8 !important;
  font-size: 0.95rem;
}

.login-card label {
  color: #cbd5e1;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  display: block;
}

.login-card input {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  padding: 0.85rem;
  border-radius: 10px;
  transition: all 0.3s ease;
}

.login-card input:focus {
  background: rgba(15, 23, 42, 0.8);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.25);
  transform: translateY(-1px);
}

.login-card input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.login-card .btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  border: none;
  padding: 0.85rem;
  font-size: 1rem;
  letter-spacing: 0.5px;
  margin-top: 1rem;
  transition: all 0.3s ease;
}

.login-card .btn-primary:hover {
  box-shadow: 0 10px 20px -10px rgba(67, 97, 238, 0.5);
  transform: translateY(-2px);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  width: auto;
  min-width: 320px;
  max-width: 1100px !important;
  width: 95% !important;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  transform: translateY(20px);
  transition: var(--transition);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-content {
  padding: 2rem;
  overflow-y: auto;
  flex: 1;
}

.close-modal {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
}

/* Flex utilities */
.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gap-2 {
  gap: 0.5rem;
}

.text-right {
  text-align: right;
}

.mb-4 {
  margin-bottom: 1rem;
}

/* Footer Dev */
/* Footer Dev */
#footer-dev {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.8);
  color: var(--text-muted);
  text-align: center;
  padding: 0.5rem;
  font-size: 0.8rem;
  cursor: pointer;
  z-index: 1000;
  border-top: 1px solid var(--border);
  backdrop-filter: blur(8px);
  transition: all 0.3s ease;
}

/* Desktop Sidebar Offset */
@media (min-width: 1025px) {
  #app:has(.sidebar) + #footer-dev {
    left: 260px;
  }
}

/* Tablet Sidebar Offset */
@media (max-width: 1024px) and (min-width: 769px) {
  #app:has(.sidebar) + #footer-dev {
    left: 220px;
  }
}

#footer-dev:hover {
  color: var(--primary);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 -2px 10px rgba(67, 97, 238, 0.1);
}

/* --- POS Exclusive Layout Redesign --- */
/* Overall container */
.pos-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    height: calc(100vh - 180px);
    /* Adjust based on your header */
}

/* Glassmorphism search */
.pos-search-wrapper {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 0.8rem 1.5rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.05);
    margin-bottom: 1.5rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
}

.pos-search-wrapper:focus-within {
    box-shadow: 0 8px 32px 0 rgba(67, 97, 238, 0.15);
    background: rgba(255, 255, 255, 0.9);
    transform: translateY(-2px);
}

.pos-search-wrapper input {
    border: none;
    background: transparent;
    font-size: 1.1rem;
    color: var(--text-main);
    width: 100%;
    outline: none;
}

/* Product List Container */
.pos-product-list-container {
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.02);
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Product Cards */
.pos-product-item {
    background: white;
    border: 1px solid rgba(226, 232, 240, 0.5);
    padding: 1.2rem 0.8rem;
    border-radius: 16px;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 190px;
    height: auto;
    width: 100%;
}

/* Shine effect */
.pos-product-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.8) 50%, rgba(255, 255, 255, 0) 100%);
    transform: skewX(-25deg);
    transition: 0.5s;
    z-index: 1;
}

.pos-product-item:hover::before {
    left: 150%;
}

.pos-product-item:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 15px 30px rgba(67, 97, 238, 0.1);
    border-color: rgba(67, 97, 238, 0.3);
}

.pos-product-item .icon {
    font-size: 2.2rem;
    /* Slighly smaller icon */
    margin-bottom: 0.8rem;
    color: transparent;
    background: linear-gradient(135deg, var(--primary) 0%, var(--success) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    transition: transform 0.3s ease;
}

.pos-product-item:hover .icon {
    transform: scale(1.1);
}

.pos-product-item .title {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    line-height: 1.2;
    /* Limit to 3 lines for better visibility of long names */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: break-word;
}

.pos-product-item .stock {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-bottom: 0.75rem;
    background: rgba(0, 0, 0, 0.03);
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-block;
}

.pos-product-item .price {
    color: var(--primary);
    font-weight: 800;
    font-size: 1.15rem;
}

/* Scrollbar adjustment for POS product list */
.pos-product-scroll {
    overflow-y: auto;
    padding-right: 0.5rem;
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    /* Further reduced for better mobile responsiveness */
    gap: 1rem;
    align-content: start;
    /* Keeps items at top */
}

/* Cart Panel */
.pos-cart-panel {
    background: white;
    border-radius: 24px;
    padding: 1.8rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(226, 232, 240, 0.8);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.pos-cart-panel h3 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pos-cart-client-select {
    width: 100%;
    padding: 1rem 1.2rem;
    border: 2px solid transparent;
    border-radius: 16px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-main);
    background: #f8fafc;
    transition: all 0.3s ease;
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234361ee' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1.2rem center;
    background-size: 1em;
}

.pos-cart-client-select:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(67, 97, 238, 0.1);
}

.pos-empty-cart {
    text-align: center;
    color: #94a3b8;
    font-size: 1.1rem;
    margin-top: 3rem;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.pos-barcode-icon {
    font-size: 5rem;
    background: linear-gradient(135deg, #cbd5e1 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    opacity: 0.5;
}

/* Cart Items Layout */
.pos-cart-item-row {
    background: #f8fafc;
    border-radius: 16px;
    padding: 1rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.pos-cart-item-row:hover {
    background: white;
    border-color: rgba(67, 97, 238, 0.2);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.04);
    transform: translateX(4px);
}

.pos-cart-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.pos-cart-item-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-main);
}

.pos-cart-item-price {
    font-weight: 700;
    color: var(--primary);
    font-size: 1.05rem;
}

.pos-cart-item-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pos-qty-control {
    display: inline-flex;
    align-items: center;
    background: white;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.pos-qty-control button {
    border: none;
    background: transparent;
    padding: 0.4rem 0.8rem;
    cursor: pointer;
    color: rgba(67, 97, 238, 0.8);
    transition: background 0.2s;
    font-weight: bold;
}

.pos-qty-control button:hover {
    background: rgba(67, 97, 238, 0.1);
}

.pos-qty-control input {
    width: 40px;
    text-align: center;
    border: none;
    border-left: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    padding: 0.4rem 0;
    font-weight: 600;
    background: transparent;
    appearance: none;
    border-radius: 0;
}

.pos-qty-control input:focus {
    box-shadow: none;
}

/* Hide arrows in input number */
.pos-qty-control input::-webkit-outer-spin-button,
.pos-qty-control input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.pos-cart-item-total {
    font-weight: 800;
    color: var(--text-main);
}

.pos-cart-item-remove {
    background: rgba(247, 37, 133, 0.1);
    color: var(--danger);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.pos-cart-item-remove:hover {
    background: var(--danger);
    color: white;
    transform: rotate(90deg) scale(1.1);
}

.pos-cart-footer {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 2px dashed #e2e8f0;
}

.pos-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, rgba(67, 97, 238, 0.05) 0%, rgba(76, 201, 240, 0.05) 100%);
    padding: 1.2rem;
    border-radius: 16px;
}

.pos-total-row .label {
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.pos-total-row .amount {
    font-size: 2rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary) 0%, #3a0ca3 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.pos-btn-cancel,
.pos-btn-charge {
    padding: 1rem;
    font-size: 1.1rem;
    border-radius: 16px;
    width: 100%;
}

.pos-btn-cancel {
    background: white;
    border: 2px solid #e2e8f0;
    color: var(--text-main);
}

.pos-btn-cancel:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.pos-btn-charge {
    background: linear-gradient(135deg, #4cc9f0 0%, #4361ee 100%);
    color: white;
    border: none;
    box-shadow: 0 10px 20px rgba(67, 97, 238, 0.3);
}

.pos-btn-charge:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 25px rgba(67, 97, 238, 0.4);
    background: linear-gradient(135deg, #4895ef 0%, #3f37c9 100%);
}

/* --- Responsive Design (Mobile & Tablet) --- */
@media (max-width: 1024px) {
    .pos-layout {
        grid-template-columns: 1.5fr 1fr;
        gap: 1rem;
        height: auto;
        min-height: calc(100vh - 180px);
    }
}

@media (max-width: 768px) {
    .pos-layout {
        grid-template-columns: 1fr;
        height: auto;
        display: flex;
        flex-direction: column;
    }

    .pos-cart-panel {
        min-height: 500px;
    }
}

/* Mobile Topbar */
.mobile-topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
    z-index: 9;
    position: sticky;
    top: 0;
}

.mobile-menu-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-main);
    cursor: pointer;
}

/* Sidebar Backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-backdrop.show {
    display: block;
    opacity: 1;
}

/* Base Responsive Rules */
@media (max-width: 1024px) {

    /* Tablet adjustments */
    .sidebar {
        width: 220px;
    }

    .main-content {
        padding: 1.5rem;
    }

    #footer-dev {
        left: 220px;
    }
}

@media (max-width: 768px) {

    /* Mobile Layout adjustments */
    body {
        flex-direction: column;
        overflow-y: auto;
    }

    #app {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    .mobile-topbar {
        display: flex;
    }

    .desktop-topbar {
        display: none !important;
    }

    /* Sidebar to Drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        /* Hidden by default */
        height: 100vh;
        width: 280px;
        z-index: 100;
        transition: left 0.3s ease;
        box-shadow: none;
        /* Shadow handled by backdrop */
    }

    .sidebar.sidebar-open {
        left: 0;
        box-shadow: 4px 0 15px rgba(0, 0, 0, 0.5);
    }

    /* Main Content */
    .main-content {
        width: 100%;
        height: auto;
        flex: 1;
        overflow-y: visible;
        /* Let body handle scroll */
        padding: 1rem;
    }

    /* Adjust page headers */
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    /* Stats Grid */
    .stats-grid {
        grid-template-columns: 1fr;
        /* Stack vertically */
    }

    /* POS Adjustments */
    .pos-layout {
        grid-template-columns: 1fr !important;
        /* Force stack */
        height: auto !important;
        /* Remove fixed height */
    }

    .pos-product-list {
        max-height: 400px;
        /* Instead of flex:1, give it max height on mobile */
        overflow-y: auto;
    }

    .pos-cart-panel {
        margin-top: 1rem;
    }

    /* Cards and Forms */
    .card {
        padding: 1rem;
    }

    /* Modals need to fit mobile better */
    .modal {
        width: 95%;
        max-height: 95vh;
        margin: 0 auto;
    }

    .modal-content {
        padding: 1rem;
    }

    /* Footer adjustments */
    #footer-dev {
        left: 0;
        /* Full width */
        position: relative;
        /* Static position at bottom of scrollable body */
        margin-top: auto;
        /* Push to bottom */
    }

    /* Login Screen Mobile Fixes */
    .login-card {
        padding: 1.5rem;
        margin: 1rem;
        max-width: 100%;
    }

    /* Make tables scrollable natively but ensure buttons stack nicely if needed */
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
}

/* Very Small Screens */
@media (max-width: 480px) {
    .stat-card {
        flex-direction: column;
        text-align: center;
        padding: 1rem;
    }

    .stat-icon {
        margin: 0 auto;
    }

    /* Hide some less critical table columns on very small screens using CSS classes if needed */
    /* .hide-mobile { display: none; } */
}

/* --- Modern Modal Form Styles --- */

.modern-modal-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.modern-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Base custom input styles taking cues from POS design */
.modern-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.modern-input-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.modern-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.modern-input-wrapper i {
    position: absolute;
    left: 1rem;
    color: var(--primary);
    opacity: 0.7;
}

.modern-input-wrapper input,
.modern-input-wrapper select {
    width: 100%;
    padding: 0.8rem 1rem 0.8rem 2.8rem;
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 12px;
    background: #fdfdfd;
    transition: all 0.3s ease;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-main);
}

.modern-input-wrapper input:focus,
.modern-input-wrapper select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
    background: white;
    outline: none;
}

/* Modern Permissions Section */
.modern-permissions-section {
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
    margin-top: 0.5rem;
}

.modern-permissions-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modern-permissions-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.8rem;
    max-height: 280px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.modern-perm-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(248, 250, 252, 0.6);
    padding: 0.8rem 1rem;
    border-radius: 12px;
    border: 1px solid rgba(226, 232, 240, 0.5);
    transition: all 0.2s ease;
}

.modern-perm-row:hover {
    background: white;
    border-color: rgba(67, 97, 238, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

.modern-perm-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
}

/* Pill Selectors */
.pill-selector {
    display: flex;
    background: #e2e8f0;
    border-radius: 20px;
    padding: 3px;
    gap: 2px;
}

.pill-option {
    padding: 0.4rem 0.8rem;
    border-radius: 16px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    user-select: none;
}

.pill-option:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.5);
}

/* Pill Active States */
.pill-option[data-val="none"].active {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.pill-option[data-val="read"].active {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.pill-option[data-val="write"].active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
#footer-dev strong {
  color: var(--text-main);
  font-weight: 600;
}

/* --- Daily Summary Responsive Grid --- */
.summary-grid-resumen {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 2rem;
}

@media (max-width: 1200px) {
    .summary-grid-resumen {
        grid-template-columns: 1fr;
    }
}



/* --- Permissions Grid & Segmented Control --- */
.modern-permissions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.25rem;
    margin-top: 1.5rem;
}
.perm-group-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transition: var(--transition);
}
.perm-group-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}
.perm-group-header {
    font-weight: 700;
    font-size: 1rem;
    color: var(--primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 2px solid #f1f5f9;
    padding: 0 0.5rem 0.75rem 0.5rem;
}
.modern-perm-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid #f1f5f9;
}
.modern-perm-row:last-child { border-bottom: none; }
.modern-perm-label {
    font-size: 0.9rem;
    color: var(--text-main);
    font-weight: 500;
    padding-left: 0.25rem;
}
.segment-control {
    display: flex;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 8px;
    gap: 3px;
}
.segment-btn {
    padding: 5px 12px;
    font-size: 0.75rem;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    white-space: nowrap;
}
.segment-btn:hover { color: var(--primary); background: rgba(255,255,255,0.5); }
.segment-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}
.segment-btn.active.none { color: #94a3b8; }
.segment-btn.active.read { color: var(--warning); }
.segment-btn.active.write { color: var(--primary); }
