:root {
  /* Materio Theme Color Variables */
  --primary: #7C3AED;
  --primary-hover: #6D28D9;
  --primary-light: #F5F3FF;
  --primary-dark: #5B21B6;
  
  --success: #10B981;
  --success-light: #D1FAE5;
  --success-bg: #ECFDF5;
  
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --warning-bg: #FFFBEB;
  
  --danger: #EF4444;
  --danger-hover: #DC2626;
  --danger-light: #FEE2E2;
  --danger-bg: #FEF2F2;
  
  --bg-main: #F8F7FA;
  --bg-secondary: #FAFAFA;
  --panel: #FFFFFF;
  
  --text-primary: #4B465C;
  --text-secondary: #6C757D;
  --text-muted: #A8AAAE;
  
  --border-color: #E7E7E7;
  --border-light: #F0F0F0;
  
  --shadow-sm: 0 2px 6px rgba(76, 78, 100, 0.06);
  --shadow-md: 0 4px 12px rgba(76, 78, 100, 0.08);
  --shadow-lg: 0 6px 24px rgba(76, 78, 100, 0.12);
  
  /* Legacy variable mappings for backward compatibility */
  --bg: var(--bg-main);
  --text: var(--text-primary);
  --muted: var(--text-muted);
  --brand: var(--primary);
  --brand-weak: var(--primary-light);
  --border: var(--border-color);
}

* { box-sizing: border-box; }
html, body { 
  height: 100%;
  overflow-x: hidden; /* Prevent horizontal scroll on body */
  width: 100%;
  max-width: 100%;
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-primary);
  background: var(--bg-main);
  line-height: 1.6;
  position: relative;
}

/* Auth-only gradient background */
.auth-bg {
  /* Login/Register gradient per COLOR_REFERENCE.md */
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

.layout { 
  display: flex; 
  min-height: 100vh; 
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: 100vh;
  background: var(--panel);
  border-right: 2px solid var(--border-color);
  border-left: 1px solid var(--border-light);
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  padding: 20px 16px;
  box-shadow: var(--shadow-sm);
  overflow-y: auto;
  z-index: 100;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 12px;
}

.brand {
  font-weight: 700;
  color: var(--primary);
  font-size: 18px;
  flex: 1;
  margin: 0;
}

.sidebar-close-btn {
  display: none;
  background: var(--danger);
  color: white;
  border: none;
  padding: 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s ease;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-close-btn:hover {
  background: var(--danger-hover);
  transform: scale(1.05);
}
.menu { 
  display: flex; 
  flex-direction: column; 
  gap: 4px; 
}

/* Base menu item styles - for direct link items */
.menu-item { 
  color: var(--text-secondary); 
  text-decoration: none; 
  padding: 12px 16px; 
  border-radius: 8px; 
  display: block;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}

/* Remove padding from dropdown containers (they're just wrappers) */
.menu-item.dropdown {
  padding: 0;
  background: transparent;
}

.menu-item:not(.dropdown):hover { 
  background: var(--primary-light); 
  color: var(--primary);
}

.dropdown { 
  position: relative; 
  width: 100%;
}

.dropdown-toggle {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.2s ease;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dropdown-toggle::after {
  content: '\f078';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 12px;
  margin-left: auto;
  transition: transform 0.3s ease;
}

.dropdown.open .dropdown-toggle::after {
  transform: rotate(180deg);
}

.dropdown-toggle:hover { 
  background: var(--primary-light); 
  color: var(--primary);
}

.dropdown-menu { 
  display: none; 
  flex-direction: column; 
  margin-left: 16px; 
  padding-left: 16px; 
  border-left: 2px solid var(--border-light);
  margin-top: 4px;
  gap: 2px;
}

.dropdown.open .dropdown-menu { 
  display: flex; 
}

.dropdown-menu a { 
  padding: 10px 12px; 
  border-radius: 6px; 
  text-decoration: none; 
  color: var(--text-muted);
  font-size: 13px;
  transition: all 0.2s ease;
  display: block;
  width: 100%;
  box-sizing: border-box;
}

.dropdown-menu a:hover { 
  background: var(--primary-light); 
  color: var(--primary);
}

/* Active menu item styles */
.menu-item:not(.dropdown).active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.dropdown-menu a.active {
  background: var(--primary);
  color: white;
  font-weight: 600;
}

.dropdown-menu a.active:hover {
  background: var(--primary-dark);
  color: white;
}

/* Open dropdown styles */
.dropdown.open .dropdown-toggle {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.main { 
  display: flex; 
  flex-direction: column; 
  margin-left: 260px;
  width: calc(100% - 260px);
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
}
.topbar { 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  padding: 20px 24px; 
  background: var(--panel); 
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}
.page-title { 
  font-size: 20px; 
  margin: 0; 
  color: var(--text-primary);
  font-weight: 600;
}
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.search input { 
  padding: 12px 16px; 
  border: 1px solid var(--border-color); 
  border-radius: 8px; 
  width: 320px; 
  background: var(--panel);
  color: var(--text-primary);
  font-size: 14px;
  transition: all 0.2s ease;
}
.search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* Button Styles */
.btn {
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background: var(--border-light);
}

.btn-danger {
  background: var(--danger);
  color: white;
  box-shadow: var(--shadow-sm);
}
.btn-danger:hover {
  background: var(--danger-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--success);
  color: white;
  box-shadow: var(--shadow-sm);
}
.btn-success:hover {
  background: #059669;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

.btn-lg {
  padding: 16px 32px;
  font-size: 16px;
}

.btn-outline-primary {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-outline-primary:hover {
  background: var(--primary);
  color: white;
}

/* Cards */
.card {
  background: var(--panel);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}

.card-body { padding: 0; }

/* Tables */
.table-container {
  overflow-x: auto;
  overflow-y: visible;
  border-radius: 12px;
  border: 1px solid var(--border-light);
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.table-container::-webkit-scrollbar {
  height: 8px;
}

.table-container::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  min-width: 600px;
}

thead {
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--border-color);
}

th {
  padding: 16px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
}

tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--bg-secondary);
}

/* Forms */
.form-group {
  margin-bottom: 20px;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.form-group input,
.form-group textarea {
  width: 100%;
  max-width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--panel);
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
}

/* Regular select elements (not using searchable dropdown component) */
select:not(.searchable-dropdown) {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--panel);
  transition: all 0.2s ease;
  cursor: pointer;
  appearance: none;
  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='%237c3aed' 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 12px center;
  background-size: 16px;
  padding-right: 40px;
}

select:not(.searchable-dropdown):focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

select:not(.searchable-dropdown):disabled {
  background-color: var(--bg-secondary);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.7;
}

/* Modal */
.modal { display: none; position: fixed; inset: 0; z-index: 1050; }
.modal.open { display: block; }
.modal-backdrop { 
  position: fixed; 
  inset: 0; 
  background: rgba(0,0,0,0.5); 
  backdrop-filter: blur(2px);
}
.modal-content { 
  position: relative; 
  max-width: 600px; 
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  margin: 5% auto; 
  background: var(--panel); 
  border-radius: 12px; 
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
}

.modal-content::-webkit-scrollbar {
  width: 8px;
}

.modal-content::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
.modal-header { 
  padding: 24px; 
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}
.modal-body { padding: 24px; }
.modal-close { 
  background: transparent; 
  border: 0; 
  font-size: 24px; 
  color: var(--text-muted); 
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
}
.modal-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}
.modal-actions { 
  display: flex; 
  gap: 12px; 
  justify-content: flex-end;
  padding: 24px;
  border-top: 1px solid var(--border-light);
}

/* Modal Form Styling - Add Retailer Modal */
.modal-body form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-body form label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  letter-spacing: 0.3px;
}

.modal-body form input[type="text"],
.modal-body form input[type="tel"],
.modal-body form input[type="password"],
.modal-body form input[type="email"],
.modal-body form textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--panel);
  transition: all 0.2s ease;
  font-family: inherit;
}

.modal-body form input[type="text"]:focus,
.modal-body form input[type="tel"]:focus,
.modal-body form input[type="password"]:focus,
.modal-body form input[type="email"]:focus,
.modal-body form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.modal-body form textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

.modal-body form input[type="text"]::placeholder,
.modal-body form input[type="tel"]::placeholder,
.modal-body form input[type="password"]::placeholder,
.modal-body form textarea::placeholder {
  color: var(--text-muted);
}

.modal-body form .modal-actions {
  margin-top: 8px;
}

.modal-body form .modal-actions .btn {
  min-width: 120px;
}

/* Responsive Modal Form */
@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    margin: 20px auto;
    max-height: 95vh;
  }
  
  .modal-body {
    padding: 20px;
  }
  
  .modal-body form {
    gap: 16px;
  }
  
  .modal-actions {
    flex-direction: column-reverse;
    padding: 20px;
  }
  
  .modal-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-success {
  background: var(--success-light);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-light);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-light);
  color: var(--danger);
}

.badge-primary {
  background: var(--primary-light);
  color: var(--primary);
}

/* Map space-separated badge variants used in templates */
.badge.success { background: var(--success-light); color: var(--success); }
.badge.warning { background: var(--warning-light); color: var(--warning); }
.badge.danger { background: var(--danger-light); color: var(--danger); }
.badge.primary { background: var(--primary-light); color: var(--primary); }

/* Content Area */
.content {
  padding: 24px;
  flex: 1;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 8px 0;
}

.page-header p {
  color: var(--text-secondary);
  margin: 0;
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.stat-card-title {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.stat-card-icon.primary {
  background: var(--primary-light);
  color: var(--primary);
}

.stat-card-icon.success {
  background: var(--success-light);
  color: var(--success);
}

.stat-card-icon.warning {
  background: var(--warning-light);
  color: var(--warning);
}

.stat-card-icon.danger {
  background: var(--danger-light);
  color: var(--danger);
}

.stat-card-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

/* Alerts */
.alert {
  padding: 16px 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.alert-success {
  background: var(--success-bg);
  border: 1px solid var(--success-light);
  color: var(--success);
}

.alert-warning {
  background: var(--warning-bg);
  border: 1px solid var(--warning-light);
  color: var(--warning);
}

.alert-danger {
  background: var(--danger-bg);
  border: 1px solid var(--danger-light);
  color: var(--danger);
}

.alert-icon {
  font-size: 20px;
  flex-shrink: 0;
}

/* -------------------------------------------------
   Django Messages (base.html -> .messages/.message)
   ------------------------------------------------- */
.messages {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 11000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(92vw, 420px);
  pointer-events: none; /* allow clicks to pass through except on the card */
}

.messages .message {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  transition: opacity 0.3s ease, transform 0.3s ease;
  animation: slideIn 0.3s ease;
  border-left: 6px solid var(--primary);
}

.messages .message.fade-out {
  opacity: 0;
  transform: translateX(100px);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.messages .message.success { background: var(--success-bg); border-color: var(--success-light); border-left-color: var(--success); color: var(--success); }
.messages .message.warning { background: var(--warning-bg); border-color: var(--warning-light); border-left-color: var(--warning); color: var(--warning); }
.messages .message.error   { 
  background: var(--danger-bg);  
  border-color: var(--danger-light);  
  border-left-color: var(--danger); 
  color: var(--danger);
  border-left-width: 6px;
  font-weight: 500;
}
.messages .message.info    { background: var(--primary-light); border-color: var(--primary-light); border-left-color: var(--primary); color: var(--primary); }

.messages .message .message-close {
  margin-left: auto;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.messages .message .message-close:hover {
  background: var(--border-light);
  color: var(--text-primary);
}

/* Mobile Menu Toggle Button */
.hamburger-btn {
  display: none;
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s ease;
  z-index: 101;
}

.hamburger-btn:hover {
  background: var(--primary-hover);
}

.hamburger-btn.active {
  background: var(--danger);
}

.hamburger-btn.active:hover {
  background: var(--danger-hover);
}

/* Sidebar Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* Responsive Design */
@media (max-width: 768px) {
  .hamburger-btn {
    display: block;
  }

  /* Hide hamburger when sidebar is open */
  body.sidebar-open .hamburger-btn {
    display: none;
  }
  
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 100;
  }
  
  .sidebar.active {
    transform: translateX(0);
  }

  /* Show close button when sidebar is active */
  .sidebar.active .sidebar-close-btn {
    display: flex;
  }

  .sidebar-close-btn {
    display: none;
  }
  
  .main {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .content {
    padding: 16px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }
  
  .topbar {
    padding: 16px;
    flex-wrap: wrap;
    gap: 12px;
  }
  
  .page-title {
    font-size: 18px;
  }
  
  .topbar-actions {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .user-menu {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .user-menu span {
    font-size: 13px;
  }
  
  .btn {
    padding: 10px 16px;
    font-size: 13px;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .content {
    padding: 16px;
  }
  
  .modal-content {
    margin: 10% 20px;
    width: calc(100% - 40px);
    max-height: 85vh;
  }
  
  .table-container {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    font-size: 12px;
    margin: 0 -16px;
    padding: 0 16px;
    width: calc(100% + 32px);
  }
  
  .table-container table {
    min-width: 600px;
  }
  
  th, td {
    padding: 10px 8px;
    font-size: 12px;
    white-space: nowrap;
  }

  /* Ensure no other elements cause horizontal scroll - only tables should scroll */
  .card,
  .search-filter-section,
  .search-form,
  .filters,
  .form-row,
  .product-detail-grid,
  .new-order-product-card,
  .new-order-images-horizontal,
  .new-order-product-fields,
  .new-order-bag-fields,
  .stock-metrics,
  .metrics-grid,
  .page-header,
  .inventory-header,
  .inventory-filters,
  .new-order-product-details,
  .new-order-bag-section,
  .new-order-methai-section,
  .product-info,
  .stock-info,
  .order-summary-section {
    max-width: 100%;
    overflow-x: hidden;
  }
  
  .card {
    padding: 16px;
  }
  
  .card-header {
    font-size: 16px;
    margin-bottom: 12px;
    padding-bottom: 12px;
  }
  
  .search-bar {
    min-width: auto;
  }
  
  .filters {
    flex-direction: column;
    align-items: stretch;
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
  
  .search-filter-section {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-form {
    flex-direction: column;
    align-items: stretch;
    min-width: auto;
  }
  
  .inventory-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .inventory-filters {
    width: 100%;
    flex-direction: column;
  }
  
  .inventory-filters select {
    width: 100%;
  }
  
  .pagination {
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .pagination-info {
    width: 100%;
    text-align: center;
    margin: 0 0 8px 0;
  }
  
  .action-buttons {
    flex-wrap: wrap;
  }
  
  .btn-icon {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }
  
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  
  .metric-card {
    padding: 16px;
  }
  
  .metric-content h3 {
    font-size: 24px;
  }
  
  .date-filter-form {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  
  .date-input-group {
    width: 100%;
  }
  
  .date-input-group input {
    width: 100%;
    min-width: auto;
  }
}


/* ========================================
   PAGE-SPECIFIC STYLES
   ======================================== */

/* Dashboard Grid Layout */
.dashboard-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-top: 24px;
}

.dashboard-widget {
  background: var(--panel);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.dashboard-widget-header {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

/* Product List Styles */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

/* Orders: Search & Filters */
.search-filter-section {
  background: var(--panel);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.search-form { 
  display: flex; 
  flex-direction: column; 
  gap: 12px;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 12px;
}

.search-bar i { color: var(--text-muted); }

.search-input {
  border: 0;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 14px;
  color: var(--text-primary);
}

.filters { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 12px; 
  align-items: flex-end;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.filter-group { display: flex; flex-direction: column; gap: 6px; }

.filter-group label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.filter-input,
.filter-select {
  padding: 12px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text-primary);
  font-size: 14px;
}

/* Map utility button classes used in templates */
.btn.primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn.primary:hover { background: var(--primary-hover); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn.secondary { background: var(--bg-secondary); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn.secondary:hover { background: var(--border-light); }
.btn.danger { background: var(--danger); color: #fff; box-shadow: var(--shadow-sm); }
.btn.danger:hover { background: var(--danger-hover); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn.success { background: var(--success); color: #fff; box-shadow: var(--shadow-sm); }
.btn.success:hover { background: #059669; box-shadow: var(--shadow-md); transform: translateY(-1px); }

/* Orders Table Enhancements */
.checkbox-col { width: 44px; }
.checkbox { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }

.actions { white-space: nowrap; }

.action-buttons { display: inline-flex; gap: 8px; }

.btn-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--panel);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

/* ========================================
   AUTH PAGES (login/register)
   ======================================== */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.auth-title {
  margin: 0 0 16px 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
}

.auth-link {
  text-align: center;
  color: var(--text-secondary);
}

.auth-link a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.auth-link a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* Small helper/error text in forms */
.form-help { color: var(--text-muted); font-size: 12px; margin-top: 4px; display: block; }
.form-error { color: var(--danger); font-size: 12px; margin-top: 4px; }

/* Utilities */
.w-100 { width: 100%; }
.justify-center { justify-content: center; }

/* Row content formatting */
.customer-info { display: flex; flex-direction: column; line-height: 1.2; }
.customer-name { font-weight: 600; color: var(--text-primary); }
.customer-phone { font-size: 12px; color: var(--text-secondary); }

.items-info { display: inline-flex; align-items: center; gap: 8px; }
.item-count { font-weight: 600; color: var(--text-primary); }
.item-dots { display: inline-flex; gap: 4px; }
.item-dots .dot { width: 6px; height: 6px; background: var(--primary); border-radius: 50%; opacity: 0.5; }

.order-id { font-weight: 700; }
.order-date, .delivery-date { color: var(--text-secondary); font-size: 13px; }

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.status-confirmed { background: var(--primary-light); color: var(--primary); }
.status-delivered { background: var(--success-light); color: var(--success); }
.status-cancelled { background: var(--danger-light); color: var(--danger); }

/* Empty/No data */
.no-data { text-align: center; }
.no-data-content { padding: 40px 20px; color: var(--text-secondary); }
.no-data-content i { font-size: 28px; color: var(--text-muted); margin-bottom: 12px; }

/* Bulk actions bar (My Orders) */
.bulk-actions {
  position: sticky;
  bottom: 20px;
  background: var(--panel);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-md);
  border-radius: 999px;
  width: fit-content;
  margin: 16px auto 0;
}

.bulk-actions-content { display: flex; align-items: center; gap: 16px; padding: 10px 14px; }
.selected-count { font-size: 14px; color: var(--text-secondary); }
.bulk-buttons { display: inline-flex; gap: 8px; }

/* Pagination styling (order overview) */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.pagination-info { color: var(--text-secondary); font-size: 13px; }
.pagination-controls { display: inline-flex; gap: 8px; align-items: center; }
.pagination-controls .btn.disabled { 
    opacity: 0.5; 
    cursor: not-allowed; 
    pointer-events: none;
}
.pagination-controls .current-page { 
    padding: 8px 12px; 
    color: var(--text-primary); 
    font-weight: 500;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .filters { flex-direction: column; align-items: stretch; }
  .actions { white-space: normal; }
}

.product-card {
  background: var(--panel);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.product-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-4px);
}

.product-card-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: var(--bg-secondary);
}

.product-card-body {
  padding: 16px;
}

.product-card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 8px 0;
}

.product-card-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
}

.product-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

/* Inventory Page Styles */
.inventory-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.inventory-filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.inventory-filters select {
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  background: var(--panel);
  color: var(--text-primary);
}

/* Order Details Styles */
.order-summary {
  background: var(--panel);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.order-summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}

.order-summary-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.order-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.order-detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.order-detail-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.order-detail-value {
  font-size: 16px;
  color: var(--text-primary);
  font-weight: 500;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state-icon {
  font-size: 64px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.empty-state-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 8px 0;
}

.empty-state-message {
  color: var(--text-secondary);
  margin: 0 0 24px 0;
}

/* Loading Spinner */
.spinner {
  border: 3px solid var(--border-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }
.p-4 { padding: 32px; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }

.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }

/* Responsive Tables */
@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    margin: 20px auto;
    max-height: 90vh;
    overflow-y: auto;
  }
  
  .modal-header h2 {
    font-size: 18px;
  }
  
  .modal-body {
    padding: 16px;
  }
  
  .modal-actions {
    padding: 16px;
    flex-direction: column;
  }
  
  .modal-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ========================================
   SELECT PRODUCTS MODAL (place_order.html)
   ======================================== */

.select-product-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.select-product-modal-box {
  background: white;
  border-radius: 12px;
  max-width: 600px;
  width: 90%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.select-product-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
  background: white;
}

.select-product-modal-title {
  font-size: 20px;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
}

.select-product-modal-close {
  background: transparent;
  border: none;
  color: #6b7280;
  font-size: 20px;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.select-product-modal-close:hover {
  background: #f3f4f6;
  color: #1f2937;
}

.select-product-modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: #d1d5db #f3f4f6;
}

.select-product-modal-body::-webkit-scrollbar {
  width: 8px;
}

.select-product-modal-body::-webkit-scrollbar-track {
  background: #f3f4f6;
  border-radius: 4px;
}

.select-product-modal-body::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

.select-product-modal-body::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

.select-product-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-bottom: 20px;
}

.select-product-filter-item-full {
  grid-column: 1 / -1;
}

.select-product-filter-item label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: #374151;
  font-size: 14px;
}

.select-product-filter-item .searchable-dropdown-wrapper {
  margin-bottom: 0;
}

.select-product-filter-item .searchable-dropdown-wrapper label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: #374151;
  font-size: 14px;
}

.select-product-filter-select {
  width: 100%;
  padding: 10px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 14px;
}

.select-product-filter-select:focus {
  outline: none;
  border-color: #7c3aed;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.1);
}

.select-product-list {
  margin-bottom: 20px;
  padding-right: 5px;
}

.select-product-empty {
  text-align: center;
  padding: 40px 20px;
  color: #9ca3af;
  font-size: 14px;
}

.select-product-empty p {
  margin: 0;
}

.select-product-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

.select-product-item:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.select-product-item.selected {
  background: var(--primary-light);
  border-color: var(--primary);
}

.select-product-item-image-container {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: #f3f4f6;
}

.select-product-item-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.select-product-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e5e7eb;
  color: #9ca3af;
  font-size: 24px;
}

.select-product-item-info {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.select-product-item-name {
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
  margin: 0;
}

.select-product-item-btn {
  background: #7c3aed;
  color: white;
  border: none;
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.select-product-item-btn:hover {
  background: #6d28d9;
}

.select-product-divider {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 5px 0;
}

.select-product-modal-footer {
  padding: 16px 24px;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
  background: white;
}

.select-product-done-btn {
  background: #10b981;
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  width: 100%;
  transition: all 0.3s ease;
}

.select-product-done-btn:hover {
  background: #059669;
}

/* Checkbox styling for product selection */
.select-product-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  padding: 6px 12px;
  border: 2px solid var(--primary);
  border-radius: 6px;
  background: white;
  transition: all 0.2s ease;
}

.select-product-checkbox-label:hover {
  background: var(--primary-light);
}

.select-product-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* Remove product card button */
.new-order-delete-card-btn {
  background: var(--danger);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
  margin-bottom: 16px;
  width: 100%;
  max-width: 200px;
}

.new-order-delete-card-btn:hover {
  background: var(--danger-hover);
}

/* Responsive Design for Select Products Modal */
@media (max-width: 768px) {
  .select-product-modal-box {
    width: 95%;
    max-height: 90vh;
  }
  
  .select-product-filters {
    grid-template-columns: 1fr;
  }
  
  .select-product-item {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .select-product-item-info {
    width: 100%;
  }
}

/* ========================================
   ACCORDION STYLES (place_order.html)
   ======================================== */

/* Progress Bar */
.progress-container {
  margin-bottom: 30px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #7c3aed 0%, #6d28d9 100%);
  border-radius: 10px;
  transition: width 0.4s ease;
}

.progress-text {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: #6b7280;
}

.progress-label {
  font-weight: 600;
}

.progress-percentage {
  font-weight: 700;
  color: #7c3aed;
}

/* Accordion Container */
.accordion-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Accordion Item */
.accordion-item {
  background: white;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
}

.accordion-item.active {
  border-color: #7c3aed;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.15);
}

.accordion-item.completed {
  border-color: #10b981;
}

/* Accordion Header */
.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  cursor: pointer;
  background: #f9fafb;
  transition: all 0.3s ease;
  user-select: none;
}

.accordion-header:hover {
  background: #f3f4f6;
}

.accordion-item.active .accordion-header {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  color: white;
}

.accordion-item.completed .accordion-header {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
}

/* Accordion Title */
.accordion-title {
  display: flex;
  align-items: center;
  gap: 16px;
}

.step-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: white;
  color: #7c3aed;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  border: 2px solid #7c3aed;
  transition: all 0.3s ease;
}

.accordion-item.active .step-number {
  background: white;
  color: #7c3aed;
  border-color: white;
}

.accordion-item.completed .step-number {
  background: white;
  color: #10b981;
  border-color: white;
}

.step-number.step-completed {
  background: white;
  color: #10b981;
}

.step-title {
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
}

.accordion-item.active .step-title,
.accordion-item.completed .step-title {
  color: white;
}

/* Accordion Toggle Icon */
.accordion-toggle i {
  font-size: 18px;
  color: #6b7280;
  transition: transform 0.3s ease;
}

.accordion-item.active .accordion-toggle i,
.accordion-item.completed .accordion-toggle i {
  color: white;
}

.accordion-item.active .accordion-toggle i.fa-minus {
  transform: rotate(0deg);
}

/* Accordion Content */
.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}

.accordion-content.show {
  max-height: none;
}

.accordion-body {
  padding: 24px;
  background: white;
}

/* Form Sections */
.form-section {
  margin-bottom: 32px;
}

.form-section:last-child {
  margin-bottom: 0;
}

.form-section-title {
  font-size: 16px;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e5e7eb;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group label {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 8px;
}

.form-group input,
.form-group textarea {
  padding: 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  color: #1f2937;
  transition: all 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.form-group textarea {
  resize: vertical;
  font-family: inherit;
}

.address-group textarea {
  min-height: 80px;
}

/* Date Input Wrapper */
.date-input-wrapper {
  position: relative;
}

.date-input-wrapper input[type="date"] {
  width: 100%;
  padding-right: 40px;
}

.date-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #6b7280;
  pointer-events: none;
}

/* Radio Group */
.radio-group {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 8px 16px;
  border: 2px solid #d1d5db;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.radio-label:hover {
  border-color: #7c3aed;
  background: #f5f3ff;
}

.radio-label input[type="radio"] {
  cursor: pointer;
}

.radio-label input[type="radio"]:checked ~ .radio-text {
  color: #7c3aed;
  font-weight: 600;
}

.radio-label:has(input[type="radio"]:checked) {
  border-color: #7c3aed;
  background: #f5f3ff;
}

.radio-text {
  font-size: 14px;
  color: #374151;
  font-weight: 500;
}

/* Custom Time Wrapper */
.custom-time-wrapper {
  margin-top: 12px;
}

.custom-time-wrapper input[type="time"] {
  width: 100%;
  padding: 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
}

/* Form Actions */
.form-actions {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.btn-next {
  padding: 12px 32px;
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
  transition: none !important;
}

.btn-next:hover {
  background: linear-gradient(135deg, #6d28d9 0%, #5b21b6 100%);
  transform: none !important;
}

/* Customer Form Specific Styles */
.customer-form {
  width: 100%;
}

/* Responsive Accordion Design */
@media (max-width: 768px) {
  .accordion-header {
    padding: 16px;
  }
  
  .accordion-body {
    padding: 16px;
  }
  
  .step-number {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
  
  .step-title {
    font-size: 16px;
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
  
  .radio-group {
    flex-direction: column;
  }
  
  .form-actions {
    flex-direction: column;
  }
  
  .btn-next {
    width: 100%;
  }
}

/* ===================================
   NEW ORDER - Product Card Styles
   =================================== */

/* Product Card Container - with border to separate multiple products */
.new-order-product-card {
  border: 2px solid #D1D5DB;
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
  background: var(--panel);
  box-shadow: 0 2px 8px rgba(76, 78, 100, 0.1);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.new-order-product-card:hover {
  box-shadow: 0 4px 16px rgba(76, 78, 100, 0.15);
  border-color: #9CA3AF;
}

/* Product Details Section */
.new-order-product-details {
  display: grid;
  gap: 20px;
  margin-bottom: 24px;
}

/* Image Upload Container - Horizontal Layout */
.new-order-images-horizontal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.new-order-image-container,
.new-order-arrangement-image {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.new-order-bag-image-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.new-order-image-container label,
.new-order-arrangement-image label,
.new-order-bag-image-container label {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.new-order-product-name-label {
  font-weight: 700;
  font-size: 16px;
  color: var(--primary);
  margin-bottom: 12px;
  display: block;
}

/* Image Display Wrapper */
.new-order-image-display-wrapper {
  position: relative;
  width: 100%;
  min-height: 260px; /* medium height */
  max-height: 300px; /* medium height */
  border: 2px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s ease;
}

.new-order-image-display-wrapper.clickable-upload-area {
  cursor: pointer;
}

.new-order-image-display-wrapper.clickable-upload-area:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.new-order-image-display {
  width: 100%;
  height: 100%;
  min-height: 260px; /* medium height */
  max-height: 300px; /* medium height */
  object-fit: contain;
  cursor: pointer;
  transition: transform 0.2s ease;
  pointer-events: none; /* Image doesn't handle clicks, wrapper does */
}

.new-order-image-display:hover {
  transform: scale(1.02);
  opacity: 0.9; /* Visual feedback that clicking will upload */
}

/* Show upload hint when no image */
.new-order-image-display-wrapper.clickable-upload-area:has(.new-order-image-placeholder:not([style*="display: none"])) {
  background: var(--bg-secondary);
}

.new-order-image-display-wrapper.clickable-upload-area:has(.new-order-image-placeholder:not([style*="display: none"])):hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

/* Hidden file input */
.hidden-file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 10;
  font-size: 0;
  pointer-events: auto;
}

.new-order-image-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  padding: 40px;
}

.new-order-image-placeholder i {
  font-size: 48px;
  color: var(--text-muted);
}

.new-order-image-placeholder span {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Legacy file input styles - keeping for bag upload */
.new-order-image-input:not(.hidden-file-input),
.new-order-arrangement-input:not(.hidden-file-input) {
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s ease;
  background: var(--panel);
  cursor: pointer;
}

.new-order-image-input:not(.hidden-file-input):focus,
.new-order-arrangement-input:not(.hidden-file-input):focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.new-order-image-input:not(.hidden-file-input):hover,
.new-order-arrangement-input:not(.hidden-file-input):hover {
  border-color: var(--primary);
}


/* Product Fields Grid */
.new-order-product-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.new-order-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.new-order-field label {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
}

.new-order-qty-input,
.new-order-rate-input,
.new-order-vendor-input,
.new-order-product-name-input,
.new-order-bag-qty-input,
.new-order-bag-notes-input {
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 14px;
  transition: all 0.2s ease;
}

.new-order-qty-input:focus,
.new-order-rate-input:focus,
.new-order-vendor-input:focus,
.new-order-product-name-input:focus,
.new-order-bag-qty-input:focus,
.new-order-bag-notes-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* Product Name Wrapper */
.new-order-product-name-wrapper {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.new-order-product-name-wrapper label {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

/* Bag Section */
.new-order-bag-section {
  border-top: 1px solid var(--border-light);
  padding-top: 20px;
  margin-top: 20px;
  margin-bottom: 24px;
}

.new-order-subsection-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.order-item-heading {
  font-size: 40px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border-light);
}

.new-order-bag-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

/* Methai Section */
.new-order-methai-section {
  border-top: 1px solid var(--border-light);
  padding-top: 20px;
  margin-top: 20px;
}

.add-order-item-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 24px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}

.add-order-item-btn:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.add-order-item-btn:active {
  transform: translateY(0);
}

.add-order-item-btn i {
  font-size: 14px;
}

.new-order-add-methai-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
  margin-bottom: 16px;
}

.new-order-add-methai-btn:hover {
  background: var(--primary-hover);
}

/* Methai Table */
.new-order-methai-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-light);
}

.new-order-methai-table thead {
  background: var(--bg-main);
}

.new-order-methai-table th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border-color);
}

.new-order-methai-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
}

.new-order-methai-row:last-child td {
  border-bottom: none;
}

.new-order-methai-name-select,
.new-order-methai-unit-select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 14px;
  background: white;
  transition: border-color 0.2s ease;
}

.new-order-methai-name-select:focus,
.new-order-methai-unit-select:focus {
  outline: none;
  border-color: var(--primary);
}

.new-order-methai-qty-input,
.new-order-methai-rate-input,
.new-order-methai-note-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s ease;
}

.new-order-methai-qty-input:focus,
.new-order-methai-rate-input:focus,
.new-order-methai-note-input:focus {
  outline: none;
  border-color: var(--primary);
}

.new-order-delete-methai-btn {
  background: var(--danger);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.new-order-delete-methai-btn:hover {
  background: var(--danger-hover);
}

/* Responsive Design for Product Cards */
@media (max-width: 768px) {
  .new-order-product-card {
    padding: 16px;
    margin-bottom: 16px;
  }

  .new-order-images-horizontal {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .new-order-image-display-wrapper {
    min-height: 220px; /* medium on small screens */
    max-height: 260px;
  }

  .new-order-image-display {
    min-height: 220px; /* medium on small screens */
    max-height: 260px;
  }

  .new-order-product-fields,
  .new-order-bag-fields {
    grid-template-columns: 1fr;
  }

  .new-order-methai-table {
    font-size: 12px;
  }

  .new-order-methai-table th,
  .new-order-methai-table td {
    padding: 8px;
  }
}

/* Select2 Custom Styling */
.select2-container {
  width: 100% !important;
}

.select2-container--default .select2-selection--single {
  height: 38px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: white;
  padding: 0;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 38px;
  padding-left: 12px;
  padding-right: 30px;
  color: var(--text-primary);
}

/* Hide the clear (X) icon */
.select2-container--default .select2-selection--single .select2-selection__clear {
  display: none !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 36px;
  right: 10px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow b {
  border-color: var(--text-secondary) transparent transparent transparent;
  border-width: 5px 4px 0 4px;
  margin-top: -2px;
}

.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
  border-color: transparent transparent var(--text-secondary) transparent;
  border-width: 0 4px 5px 4px;
  margin-top: -3px;
}

.select2-dropdown {
  border: 1px solid var(--border-color);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden !important;
}

/* Fix scrollbar issues - ensure only one scrollbar */
/* Remove scrollbar from search container */
.select2-search--dropdown {
  overflow: visible !important;
  padding: 0;
  margin: 0;
}

/* Remove scrollbar from results wrapper */
.select2-results {
  overflow: hidden !important;
  max-height: none !important;
}

/* ONLY the options list should have scrollbar */
.select2-container--default .select2-results > .select2-results__options {
  overflow-y: auto !important;
  overflow-x: hidden !important;
  max-height: 300px;
}

/* Ensure no scrollbar on the dropdown wrapper itself */
.select2-dropdown--below,
.select2-dropdown--above {
  overflow: hidden !important;
}

.select2-container--default .select2-results__options::-webkit-scrollbar {
  width: 8px;
}

.select2-container--default .select2-results__options::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.select2-container--default .select2-results__options::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

.select2-container--default .select2-results__options::-webkit-scrollbar-thumb:hover {
  background: #555;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 8px 12px;
  margin: 8px;
  width: calc(100% - 16px);
}

.select2-container--default .select2-results__option {
  padding: 10px 12px;
  color: var(--text-primary);
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background-color: var(--primary);
  color: white;
}

.select2-container--default .select2-results__option[aria-selected=true] {
  background-color: var(--primary-light);
  color: var(--primary);
}

.select2-container--default .select2-results__option[aria-disabled=true] {
  color: var(--text-muted);
  cursor: not-allowed;
}

.select2-container--default .select2-results__option--empty {
  padding: 10px 12px;
  color: var(--text-muted);
  text-align: center;
}

.select2-container--default .select2-results__message {
  padding: 10px 12px;
  color: var(--text-muted);
}

/* Select2 in modals */
.modal .select2-container {
  z-index: 10050;
}

.modal .select2-dropdown {
  z-index: 10050;
}

/* Select2 in select-product-modal */
.select-product-modal-overlay .select2-container {
  z-index: 10050;
}

.select-product-modal-overlay .select2-dropdown {
  z-index: 10050;
}

/* Select2 in product cards (methai dropdowns) */
.new-order-product-card .select2-container {
  position: relative;
  z-index: 10050;
}

.new-order-product-card .select2-dropdown {
  z-index: 10051; /* Higher than container to ensure it appears on top */
}

/* Searchable dropdown wrapper in methai table */
.new-order-methai-table .searchable-dropdown-wrapper {
  position: relative;
  z-index: 10050;
}

.new-order-methai-table .searchable-dropdown-wrapper .select2-container {
  position: relative;
  z-index: 10050;
}

.new-order-methai-table .searchable-dropdown-wrapper .select2-dropdown {
  z-index: 10051;
}

/* Ensure product cards don't create stacking context issues */
.new-order-product-card {
  position: relative;
  z-index: auto; /* Changed from 1 to auto to prevent stacking context isolation */
}

/* Select2 loading state */
.select2-container--default .select2-selection--single .select2-selection__rendered::after {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-left: 8px;
  vertical-align: middle;
}

.select2-container--default.select2-container--loading .select2-selection--single .select2-selection__rendered::after {
  content: '';
  border: 2px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Mobile responsive */
@media (max-width: 768px) {
  .select2-container--default .select2-selection--single {
    height: 42px;
  }
  
  .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 42px;
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  .select2-dropdown {
    max-width: 100vw;
  }
  
  /* Mobile responsive button containers in card headers */
  .card-header > div[style*="display: flex"] {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  
  .card-header > div[style*="display: flex"] > div[style*="display: flex"] {
    width: 100% !important;
  }
  
  .card-header > div[style*="display: flex"] > div[style*="display: flex"] > .btn,
  .card-header > div[style*="display: flex"] > div[style*="display: flex"] > a.btn {
    flex: 1 1 calc(50% - 6px) !important;
    min-width: 0 !important;
    font-size: 13px !important;
    padding: 10px 8px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  
  .card-header > div[style*="display: flex"] > div[style*="display: flex"] > .btn i,
  .card-header > div[style*="display: flex"] > div[style*="display: flex"] > a.btn i {
    margin-right: 4px !important;
  }
  
  .card-header > div[style*="display: flex"] > .badge {
    align-self: flex-start !important;
    margin-top: 8px !important;
  }
}
