/*
 * Fresh Connects - Proprietary Software
 * Copyright (c) 2025 Fresh Connects. All rights reserved.
 *
 * NOTICE: Unauthorized copying, modification, distribution, or use
 * of this software is strictly prohibited without express written permission.
 */

/* Fresh Connects - Streamlit-inspired Design */

:root {
  /* Primary Colors */
  --primary-red: #ff4b4b;
  --primary-green: #4caf50;
  --primary-blue: #1e88e5;

  /* Light Theme (Default) */
  --sidebar-bg: #f0f2f6;
  --main-bg: #ffffff;
  --card-bg: #ffffff;
  --input-bg: #ffffff;
  --text-dark: #262730;
  --text-medium: #31333f;
  --text-light: #808495;
  --border-color: #e6eaf0;
  --hover-bg: #e8eaed;

  /* Shadows */
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md:
    0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg:
    0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

  /* Z-Index Hierarchy System
     * Use these variables instead of arbitrary z-index values
     * Layer order (lowest to highest):
     * base < dropdown < sticky < sidebar < overlay < modal < toast < tooltip < critical < impersonation < tour
     */
  --z-base: 1;
  --z-dropdown: 100;
  --z-sticky: 500;
  --z-sidebar: 900;
  --z-sidebar-overlay: 998;
  --z-sidebar-active: 999;
  --z-header: 1000;
  --z-overlay: 1001;
  --z-modal: 5000;
  --z-toast: 9000;
  --z-toast-below: 8999;
  --z-tooltip: 9500;
  --z-critical: 9999;
  --z-impersonation: 10000;
  --z-tour-overlay: 10001;
  --z-tour-highlight: 10002;

  /* Theme Transition */
  --theme-transition:
    background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease,
    box-shadow 0.3s ease;
}

/* Dark Theme */
[data-theme="dark"] {
  --primary-red: #ff6b6b;
  --primary-green: #66bb6a;
  --primary-blue: #42a5f5;
  --sidebar-bg: #1e1e2e;
  --main-bg: #121218;
  --card-bg: #1e1e2e;
  --input-bg: #27272a;
  --text-dark: #e4e4e7;
  --text-medium: #a1a1aa;
  --text-light: #71717a;
  --border-color: #27272a;
  --hover-bg: #27272a;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

/* Dark Mode - Only apply when user explicitly sets data-theme="dark" */
/* Light mode is always the default, regardless of system preference */
:root[data-theme="dark"] {
  --primary-red: #ff6b6b;
  --primary-green: #66bb6a;
  --primary-blue: #42a5f5;
  --sidebar-bg: #1e1e2e;
  --main-bg: #121218;
  --card-bg: #1e1e2e;
  --input-bg: #27272a;
  --text-dark: #e4e4e7;
  --text-medium: #a1a1aa;
  --text-light: #71717a;
  --border-color: #27272a;
  --hover-bg: #27272a;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

/* Explicit dark mode body and content styles */
[data-theme="dark"] body,
[data-theme="dark"] .main-content {
  background-color: var(--main-bg);
  color: var(--text-dark);
}

[data-theme="dark"] .sidebar {
  background-color: var(--sidebar-bg);
}

[data-theme="dark"] .card,
[data-theme="dark"] .fc-card {
  background-color: var(--card-bg);
  border-color: var(--border-color);
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background-color: var(--input-bg);
  color: var(--text-dark);
  border-color: var(--border-color);
}

[data-theme="dark"] .page-header,
[data-theme="dark"] .page-title,
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3 {
  color: var(--text-dark);
}

/* Honeypot field - hidden from users, visible to bots */
/* Do not remove this style - it's for anti-scraping protection */
.hp-field,
.website_url_field {
  position: absolute !important;
  left: -9999px !important;
  top: -9999px !important;
  visibility: hidden !important;
  height: 0 !important;
  width: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

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

body {
  font-family:
    "Source Sans Pro",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
  background-color: var(--main-bg);
  color: var(--text-dark);
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
  width: 280px;
  background-color: var(--sidebar-bg);
  padding: 2rem 0;
  border-right: 1px solid var(--border-color);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for better mobile support */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  display: flex;
  flex-direction: column;
}

.sidebar-logo {
  padding: 0 1.5rem;
  margin-bottom: 2rem;
}

.sidebar-logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-dark);
}

.sidebar-logo p {
  font-size: 0.875rem;
  color: var(--text-light);
  margin-top: 0.25rem;
}

/* Sidebar Header (admin pages) */
.sidebar-header {
  padding: 0 1.5rem;
  margin-bottom: 1.5rem;
}

.sidebar-header .logo {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-dark);
  text-decoration: none;
  display: block;
  line-height: 1.3;
}

.sidebar-header .logo:hover {
  color: var(--primary-red);
}

.sidebar-subtitle {
  font-size: 0.75rem;
  color: var(--text-light);
  margin: 0.25rem 0 0 0;
  letter-spacing: 0.02em;
}

/* Mobile: Hide subtitle on very small screens */
@media (max-width: 480px) {
  .sidebar-subtitle {
    font-size: 0.7rem;
  }
}

.sidebar-nav {
  flex: 1;
  padding: 0 0.5rem;
  overflow-y: auto;
  min-height: 0; /* Allow flex item to shrink for scrolling */
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.nav-section {
  margin-bottom: 1.5rem;
}

.nav-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  padding: 0.5rem 1rem;
  margin-bottom: 0.25rem;
}

.nav-item {
  display: block;
  padding: 0.75rem 1rem;
  color: var(--text-medium);
  text-decoration: none;
  border-radius: 8px;
  margin-bottom: 0.25rem;
  transition: all 0.2s;
  font-size: 0.95rem;
}

.nav-item:hover {
  background-color: var(--hover-bg);
}

.nav-item.active {
  background-color: var(--primary-red);
  color: white;
  font-weight: 600;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}

.user-profile {
  margin-bottom: 1rem;
}

.user-profile p {
  font-size: 0.875rem;
  color: var(--text-light);
  margin-bottom: 0.25rem;
}

.user-profile .username {
  font-weight: 600;
  color: var(--text-dark);
  font-size: 1rem;
}

.user-profile .role {
  color: var(--text-light);
  font-size: 0.875rem;
}

.btn-signout {
  width: 100%;
  padding: 0.5rem;
  background-color: transparent;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-medium);
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s;
}

.btn-signout:hover {
  background-color: var(--hover-bg);
  border-color: var(--text-light);
}

/* Main Content */
.main-content {
  margin-left: 280px;
  flex: 1;
  padding: 2rem 3rem;
  max-width: none; /* Allow full width - grids manage layout */
}

/* Page Header */
.page-header {
  margin-bottom: 2rem;
}

.page-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-subtitle {
  font-size: 1rem;
  color: var(--text-light);
  margin-bottom: 1.5rem;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 2rem;
}

.tab {
  padding: 0.75rem 1.5rem;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-medium);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s;
  margin-bottom: -2px;
}

.tab:hover {
  color: var(--text-dark);
  background-color: var(--hover-bg);
}

.tab.active {
  color: var(--primary-red);
  border-bottom-color: var(--primary-red);
  font-weight: 600;
}

/* Cards */
.card {
  background-color: var(--main-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  margin-bottom: 1.5rem;
}

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

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-dark);
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.metric-card {
  background-color: var(--main-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  transition: all 0.3s ease;
  cursor: pointer;
}

.metric-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  border-color: var(--primary-red);
}

.metric-label {
  font-size: 0.875rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.metric-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 0.25rem;
  transition: color 0.2s;
}

.metric-card:hover .metric-value {
  color: var(--primary-red);
}

.metric-subtitle {
  font-size: 0.875rem;
  color: var(--text-light);
}

/* Action Cards */
.action-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.action-card {
  background-color: var(--main-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: var(--text-dark);
}

.action-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
}

.action-card.primary {
  background-color: var(--primary-red);
  color: white;
  border-color: var(--primary-red);
}

.action-card.primary:hover {
  background-color: #e63946;
}

.action-card-icon {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.action-card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.action-card-desc {
  font-size: 0.875rem;
  opacity: 0.9;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.25rem;
  min-height: 44px; /* Touch target accessibility */
  border: none;
  border-radius: 4px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-block;
}

.btn-primary {
  background-color: var(--primary-red);
  color: white;
}

.btn-primary:hover {
  background-color: #e63946;
}

.btn-secondary {
  background-color: var(--border-color);
  color: var(--text-dark);
}

.btn-secondary:hover {
  background-color: var(--hover-bg);
}

.btn-success {
  background-color: var(--primary-green);
  color: white;
}

.btn-success:hover {
  background-color: #45a049;
}

.btn-danger {
  background-color: #ef4444;
  color: white;
}

.btn-danger:hover {
  background-color: #dc2626;
}

/* Alert Messages */
.alert {
  padding: 1rem 1.25rem;
  border-radius: 4px;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.alert-success {
  background-color: #d4edda;
  border: 1px solid #c3e6cb;
  color: #155724;
}

.alert-info {
  background-color: #d1ecf1;
  border: 1px solid #bee5eb;
  color: #0c5460;
}

.alert-warning {
  background-color: #fff3cd;
  border: 1px solid #ffeaa7;
  color: #856404;
}

.alert-error {
  background-color: #f8d7da;
  border: 1px solid #f5c6cb;
  color: #721c24;
}

/* Inline Errors (for forms and containers) */
.inline-error {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #fff5f5 0%, #fed7d7 100%);
  border: 1px solid #fc8181;
  border-radius: 8px;
  color: #c53030;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  animation: slideIn 0.3s ease;
}

.inline-error .error-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.inline-error .error-message {
  flex: 1;
}

.inline-error .error-dismiss {
  background: none;
  border: none;
  color: #c53030;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.inline-error .error-dismiss:hover {
  opacity: 1;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Loading State for Buttons */
button.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.8;
}

button.loading::after {
  content: "";
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

button.error {
  animation: shake 0.5s ease;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--main-bg);
}

.table thead {
  background-color: var(--sidebar-bg);
}

.table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-medium);
  border-bottom: 2px solid var(--border-color);
}

.table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

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

/* Status Badges */
.status-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-pending {
  background-color: #fff3e0;
  color: #e65100;
}

.status-scheduled {
  background-color: #e8f5e9;
  color: #2e7d32;
}

.status-in_progress {
  background-color: #e3f2fd;
  color: #1565c0;
}

.status-approved {
  background-color: #e8f5e9;
  color: #2e7d32;
}

.status-completed {
  background-color: #c8e6c9;
  color: #1b5e20;
}

.status-cancelled {
  background-color: #ffebee;
  color: #c62828;
}

.status-active {
  background-color: #e8f5e9;
  color: #2e7d32;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-dark);
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  min-height: 44px; /* Touch target accessibility */
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  background-color: var(--input-bg);
  transition: all 0.2s ease;
}

.form-control:hover {
  border-color: #d1d5db;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-red);
  background-color: white;
  box-shadow: 0 0 0 3px rgba(255, 75, 75, 0.1);
}

.form-control::placeholder {
  color: #9ca3af;
}

/* Login Page */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-color: var(--sidebar-bg);
  padding: 2rem;
}

.login-card {
  background-color: var(--main-bg);
  border-radius: 12px;
  padding: 3rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 420px;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-red);
  margin-bottom: 0.5rem;
}

.login-logo p {
  color: var(--text-light);
  font-size: 1rem;
}

/* Loading */
.loading {
  text-align: center;
  padding: 3rem;
}

.spinner {
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--primary-red);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Product Grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* 3 columns on desktop */
  gap: 1.5rem;
}

.product-card {
  background-color: var(--main-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  transition: all 0.2s;
}

.product-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.product-image {
  width: 100%;
  height: 150px;
  background-color: var(--sidebar-bg);
  border-radius: 4px;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}

.product-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 0.5rem;
}

.product-vendor {
  font-size: 0.875rem;
  color: var(--text-light);
  margin-bottom: 1rem;
}

.product-price {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary-blue);
  margin-bottom: 1rem;
}

.product-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.quantity-input {
  width: 60px;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  text-align: center;
}

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: var(--z-overlay);
  background-color: var(--primary-red);
  color: white;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.3s;
}

.mobile-menu-toggle:hover {
  background-color: #e63946;
}

.mobile-menu-toggle:active {
  transform: scale(0.95);
}

.hamburger {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  justify-content: center;
}

.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background-color: white;
  transition: all 0.3s;
}

.mobile-menu-toggle.active .hamburger span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.active .hamburger span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle.active .hamburger span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* Mobile Overlay */
.mobile-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: var(--z-sidebar-active);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s,
    visibility 0.3s;
}

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

/* Responsive */
@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    width: 280px;
    height: 100vh;
    z-index: var(--z-overlay); /* Must be higher than mobile-overlay */
    transition: left 0.3s ease;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
  }

  .sidebar.mobile-open {
    left: 0;
  }

  .main-content {
    margin-left: 0;
    padding: 4rem 1.5rem 1.5rem;
    width: 100%;
  }

  .main-content.with-filter {
    margin-left: 0;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .page-title {
    font-size: 1.75rem;
  }

  /* Filter sidebar is controlled via transform/visibility in products.html */
  /* Mobile bottom sheet styles are applied there */
}

@media (max-width: 640px) {
  .page-title {
    font-size: 1.5rem;
  }

  .main-content {
    padding: 4rem 1rem 1rem;
  }

  .card {
    padding: 1rem;
  }
}

/* ========================================
   MODAL STYLES
   ======================================== */

.modal {
  position: fixed;
  z-index: var(--z-modal);
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: white;
  margin: auto;
  padding: 0;
  border-radius: 12px;
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

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

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--text-dark);
}

.modal-close {
  background: none;
  border: none;
  font-size: 2rem;
  color: var(--text-medium);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.modal-close:hover {
  background-color: var(--sidebar-bg);
  color: var(--text-dark);
}

.modal-body {
  padding: 1.5rem;
}

/* ========================================
   THEME TOGGLE
   ======================================== */

.theme-toggle-container {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}

.theme-toggle-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-medium);
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--theme-transition);
}

.theme-toggle-btn:hover {
  background-color: var(--hover-bg);
  color: var(--text-dark);
}

.theme-toggle-btn .theme-icon {
  font-size: 1.2rem;
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */

.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: var(
    --z-impersonation
  ); /* Above modals, below impersonation banner */
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 400px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background-color: var(--card-bg);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--border-color);
  pointer-events: auto;
  animation: toast-slide-in 0.3s ease-out;
  transition: var(--theme-transition);
}

.toast.toast-exiting {
  animation: toast-slide-out 0.3s ease-in forwards;
}

.toast-success {
  border-left-color: var(--primary-green);
}

.toast-error {
  border-left-color: var(--primary-red);
}

.toast-info {
  border-left-color: var(--primary-blue);
}

.toast-warning {
  border-left-color: #f59e0b;
}

.toast-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 0.25rem;
}

.toast-message {
  color: var(--text-medium);
  font-size: 0.9rem;
  word-wrap: break-word;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 0.25rem;
  font-size: 1.25rem;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.toast-close:hover {
  opacity: 1;
}

@keyframes toast-slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toast-slide-out {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Mobile: Toast at bottom */
@media (max-width: 768px) {
  .toast-container {
    top: auto;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    max-width: none;
  }

  @keyframes toast-slide-in {
    from {
      transform: translateY(100%);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  @keyframes toast-slide-out {
    from {
      transform: translateY(0);
      opacity: 1;
    }
    to {
      transform: translateY(100%);
      opacity: 0;
    }
  }
}

/* ========================================
   SKELETON LOADERS
   ======================================== */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--border-color) 25%,
    var(--hover-bg) 50%,
    var(--border-color) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
}

.skeleton-text {
  height: 1rem;
  margin-bottom: 0.5rem;
}

.skeleton-text-sm {
  height: 0.75rem;
  width: 60%;
}

.skeleton-title {
  height: 1.5rem;
  width: 40%;
  margin-bottom: 1rem;
}

.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.skeleton-card {
  height: 120px;
  border-radius: 8px;
}

.skeleton-metric {
  height: 80px;
  border-radius: 8px;
}

.skeleton-table-row {
  height: 48px;
  margin-bottom: 0.5rem;
}

.skeleton-button {
  height: 40px;
  width: 100px;
  border-radius: 6px;
}

.skeleton-image {
  aspect-ratio: 16/9;
  border-radius: 8px;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ========================================
   MICRO-INTERACTIONS & ANIMATIONS
   ======================================== */

/* Button press effect */
.btn,
button[type="submit"],
.sidebar-link {
  transition:
    transform 0.1s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease;
}

.btn:active,
button[type="submit"]:active {
  transform: scale(0.97);
}

/* Card hover lift */
.card,
.metric-card,
.product-card {
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    var(--theme-transition);
}

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

/* Focus visible outlines (accessibility) */
:focus-visible {
  outline: 2px solid var(--primary-blue);
  outline-offset: 2px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
  outline: none;
}

/* Screen reader only - visually hidden but accessible to assistive tech */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip to main content link - visible on focus for keyboard users */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  padding: 8px 16px;
  background: var(--primary-blue);
  color: white;
  text-decoration: none;
  z-index: var(--z-critical);
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
}

/* Fade-in animation for dynamic content */
.fade-in {
  animation: fade-in 0.3s ease-out;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Slide-up animation */
.slide-up {
  animation: slide-up 0.3s ease-out;
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Tab underline animation */
.tab-button::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background-color: var(--primary-red);
  transition:
    width 0.3s ease,
    left 0.3s ease;
}

.tab-button.active::after,
.tab-button:hover::after {
  width: 100%;
  left: 0;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .skeleton {
    animation: none;
    background: var(--border-color);
  }
}

/* ========================================
   THEME TRANSITIONS
   ======================================== */

body,
.sidebar,
.main-content,
.card,
.metric-card,
input,
select,
textarea,
.toast,
.modal-content {
  transition: var(--theme-transition);
}

/* ========================================
   AI CHAT WIDGET
   ======================================== */

#ai-chat-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: var(--z-critical);
  font-family: inherit;
}

/* Floating chat button */
.ai-chat-button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-red), #ff6b6b);
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  position: relative;
}

.ai-chat-button:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 25px rgba(255, 75, 75, 0.4);
}

.ai-chat-button:active {
  transform: scale(0.95);
}

.ai-chat-button.hidden {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}

.ai-chat-icon {
  font-size: 1.75rem;
}

.ai-chat-tooltip {
  position: absolute;
  right: 70px;
  background: var(--card-bg);
  color: var(--text-dark);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateX(10px);
  transition:
    opacity 0.2s,
    transform 0.2s;
  pointer-events: none;
}

.ai-chat-button:hover .ai-chat-tooltip {
  opacity: 1;
  transform: translateX(0);
}

/* Chat panel */
.ai-chat-panel {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 380px;
  height: 550px;
  max-height: calc(100vh - 3rem);
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.ai-chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Chat header */
.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: linear-gradient(135deg, var(--primary-red), #ff6b6b);
  color: white;
}

.ai-chat-header-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ai-chat-avatar {
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
}

.ai-chat-title {
  font-weight: 600;
  font-size: 1rem;
}

.ai-chat-status {
  font-size: 0.75rem;
  opacity: 0.9;
}

.ai-chat-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.ai-chat-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Messages container */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--main-bg);
}

/* Welcome message */
.ai-chat-welcome {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-medium);
}

.ai-chat-welcome-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.ai-chat-welcome h3 {
  color: var(--text-dark);
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.ai-chat-welcome p {
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Message bubbles */
.ai-message {
  display: flex;
  gap: 0.5rem;
  max-width: 90%;
  animation: fade-in 0.3s ease-out;
}

.ai-message-user {
  flex-direction: row-reverse;
  align-self: flex-end;
}

.ai-message-assistant {
  align-self: flex-start;
}

.ai-message-avatar {
  width: 28px;
  height: 28px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ai-message-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ai-message-text {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  line-height: 1.5;
  font-size: 0.9rem;
}

.ai-message-user .ai-message-text {
  background: var(--primary-red);
  color: white;
  border-bottom-right-radius: 4px;
}

.ai-message-assistant .ai-message-text {
  background: var(--card-bg);
  color: var(--text-dark);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
}

.ai-message-text ul {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
}

.ai-message-text li {
  margin-bottom: 0.25rem;
}

/* Quick actions */
.ai-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ai-quick-action {
  padding: 0.5rem 0.75rem;
  background: var(--hover-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--text-medium);
  cursor: pointer;
  transition: all 0.2s;
}

.ai-quick-action:hover {
  background: var(--primary-red);
  color: white;
  border-color: var(--primary-red);
}

/* Feedback buttons */
.ai-feedback {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-color);
}

.ai-feedback-label {
  font-size: 0.75rem;
  color: var(--text-light);
}

.ai-feedback-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: var(--hover-bg);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
}

.ai-feedback-btn:hover {
  transform: scale(1.1);
}

.ai-feedback-up:hover {
  background: #d4edda;
  border-color: #28a745;
}

.ai-feedback-down:hover {
  background: #f8d7da;
  border-color: #dc3545;
}

.ai-feedback-submitted {
  border-top: none;
  padding-top: 0;
}

.ai-feedback-thanks {
  font-size: 0.75rem;
  color: var(--text-light);
  font-style: italic;
}

/* Typing indicator */
.ai-typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ai-typing-dots {
  display: flex;
  gap: 4px;
  padding: 0.75rem 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
}

.ai-typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--text-light);
  border-radius: 50%;
  animation: typing-bounce 1.4s ease-in-out infinite;
}

.ai-typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.ai-typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-4px);
  }
}

/* Suggestions */
.ai-chat-suggestions {
  padding: 0.5rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  background: var(--main-bg);
  border-top: 1px solid var(--border-color);
}

.ai-suggestion-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--text-medium);
  cursor: pointer;
  transition: all 0.2s;
}

.ai-suggestion-btn:hover {
  background: var(--hover-bg);
  color: var(--text-dark);
}

.ai-suggestion-icon {
  font-size: 1rem;
}

/* Input area */
.ai-chat-input-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--card-bg);
  border-top: 1px solid var(--border-color);
}

.ai-chat-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 24px;
  background: var(--input-bg);
  color: var(--text-dark);
  font-size: 0.9rem;
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.ai-chat-input:focus {
  border-color: var(--primary-red);
  box-shadow: 0 0 0 3px rgba(255, 75, 75, 0.1);
}

.ai-chat-input::placeholder {
  color: var(--text-light);
}

.ai-chat-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary-red);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.2s,
    transform 0.1s;
  flex-shrink: 0;
}

.ai-chat-send:hover {
  background: #e53e3e;
}

.ai-chat-send:active {
  transform: scale(0.95);
}

/* AI Chat Rich Components */
.ai-context-badge {
  font-size: 0.7rem;
  vertical-align: super;
  margin-left: 2px;
}

/* Product Cards in Chat */
.ai-product-cards {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.ai-product-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.ai-product-info {
  flex: 1;
  min-width: 0;
}

.ai-product-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-product-vendor {
  font-size: 0.75rem;
  color: var(--text-medium);
  margin-top: 2px;
}

.ai-product-price {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary-green);
  white-space: nowrap;
}

.ai-add-cart-btn {
  padding: 0.4rem 0.75rem;
  background: var(--primary-red);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.ai-add-cart-btn:hover {
  background: #e53e3e;
}

/* Price Comparison Table */
.ai-price-table {
  margin-top: 0.75rem;
  overflow-x: auto;
}

.ai-price-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.ai-price-table th,
.ai-price-table td {
  padding: 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.ai-price-table th {
  font-weight: 600;
  color: var(--text-medium);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.ai-price-table .ai-best-price {
  background: rgba(72, 187, 120, 0.1);
}

.ai-price-table .ai-best-price td {
  color: var(--primary-green);
  font-weight: 600;
}

/* Reorder Reminders */
.ai-reminders {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.ai-reminder-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  border-left: 3px solid var(--primary-green);
}

.ai-reminder-item.ai-urgent {
  border-left-color: #e53e3e;
  background: rgba(229, 62, 62, 0.05);
}

.ai-reminder-item.ai-warning {
  border-left-color: #ecc94b;
  background: rgba(236, 201, 75, 0.05);
}

.ai-reminder-icon {
  font-size: 1rem;
}

.ai-reminder-info {
  flex: 1;
  min-width: 0;
}

.ai-reminder-product {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-dark);
}

.ai-reminder-action {
  font-size: 0.75rem;
  color: var(--text-medium);
  margin-top: 2px;
}

.ai-reorder-btn {
  padding: 0.4rem 0.75rem;
  background: var(--primary-red);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.ai-reorder-btn:hover {
  background: #e53e3e;
}

/* Stats Grid */
.ai-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.ai-stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem;
  text-align: center;
}

.ai-stat-value {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary-red);
}

.ai-stat-label {
  font-size: 0.7rem;
  color: var(--text-medium);
  text-transform: uppercase;
  margin-top: 0.25rem;
}

/* Step-by-step Guide Styles */
.ai-guide-message {
  border-left: 3px solid var(--primary-blue);
}

.ai-guide-header {
  color: var(--primary-blue);
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.ai-guide-progress {
  background: var(--border-color);
  border-radius: 4px;
  height: 6px;
  margin: 0.75rem 0 0.5rem;
  overflow: hidden;
}

.ai-guide-progress-bar {
  background: linear-gradient(90deg, var(--primary-blue), var(--primary-green));
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.ai-guide-progress-text {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-bottom: 0.75rem;
}

.ai-guide-message .ai-quick-action {
  font-size: 0.75rem;
  padding: 0.4rem 0.6rem;
}

.ai-guide-message .ai-quick-action:first-child {
  background: var(--primary-blue);
  color: white;
  border-color: var(--primary-blue);
}

.ai-guide-message .ai-quick-action:first-child:hover {
  background: var(--primary-red);
  border-color: var(--primary-red);
}

/* Guide card for suggestions */
.ai-guide-card {
  background: linear-gradient(135deg, var(--card-bg), var(--hover-bg));
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  margin: 0.5rem 0;
  cursor: pointer;
  transition: all 0.2s;
}

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

.ai-guide-card-title {
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 0.25rem;
}

.ai-guide-card-steps {
  font-size: 0.8rem;
  color: var(--text-light);
}

/* AI Order Generator Styles */
.ai-order-form {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  margin-top: 0.5rem;
}

.ai-order-header {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  color: var(--text-dark);
}

.ai-order-input {
  width: 100%;
  min-height: 80px;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  resize: vertical;
  background: var(--input-bg);
  color: var(--text-dark);
}

.ai-order-input:focus {
  outline: none;
  border-color: var(--primary-blue);
}

.ai-order-options {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.ai-order-options input,
.ai-order-options select {
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.8rem;
  background: var(--input-bg);
  color: var(--text-dark);
}

.ai-order-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  justify-content: flex-end;
}

.ai-order-cancel {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--text-medium);
  cursor: pointer;
  font-size: 0.8rem;
}

.ai-order-generate {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
}

.ai-order-generate:hover {
  opacity: 0.9;
}

.ai-order-explanation {
  background: var(--hover-bg);
  padding: 0.75rem;
  border-radius: 8px;
  margin: 0.75rem 0;
  font-size: 0.85rem;
  color: var(--text-medium);
  border-left: 3px solid var(--primary-blue);
}

.ai-vendor-orders {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.ai-vendor-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem;
  border-left: 3px solid var(--primary-blue);
}

.ai-vendor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.ai-vendor-items {
  font-size: 0.8rem;
  color: var(--text-medium);
}

.ai-vendor-item {
  display: flex;
  justify-content: space-between;
  padding: 0.25rem 0;
  border-bottom: 1px dashed var(--border-color);
}

.ai-vendor-item:last-child {
  border-bottom: none;
}

.ai-add-vendor-btn {
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.5rem;
  background: var(--primary-green);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.ai-add-vendor-btn:hover {
  background: #38a169;
}

.ai-add-vendor-btn:disabled {
  background: var(--text-light);
  cursor: default;
}

.ai-order-total {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 8px;
  text-align: center;
  font-size: 1rem;
}

/* ============================================
   AI ONBOARDING TOUR STYLES
   ============================================ */

/* Tour Prompt */
.ai-tour-prompt {
  position: fixed;
  bottom: 100px;
  right: 20px;
  z-index: var(--z-impersonation);
  animation: slide-up 0.4s ease-out;
}

.ai-tour-prompt-content {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  padding: 1.25rem;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ai-tour-prompt-icon {
  font-size: 2.5rem;
  text-align: center;
}

.ai-tour-prompt-text h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.1rem;
  color: var(--text-dark);
}

.ai-tour-prompt-text p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-medium);
  line-height: 1.5;
}

.ai-tour-prompt-actions {
  display: flex;
  gap: 0.75rem;
}

.ai-tour-prompt-actions .btn {
  flex: 1;
}

.ai-tour-prompt.fade-out {
  animation: fade-out 0.3s ease-out forwards;
}

/* Tour Overlay */
.ai-tour-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-tooltip);
  animation: fade-in 0.3s ease-out;
}

/* Highlighted Element */
/* !important needed to override element-specific z-index for tour overlay */
.ai-tour-highlight {
  position: relative;
  z-index: var(--z-critical) !important;
  box-shadow:
    0 0 0 4px var(--primary-red),
    0 0 0 8px rgba(255, 75, 75, 0.3) !important;
  border-radius: 8px;
}

/* Tour Tooltip */
.ai-tour-tooltip {
  position: fixed;
  z-index: var(--z-tour-overlay);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  padding: 1rem 1.25rem;
  max-width: 320px;
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 0.3s,
    transform 0.3s;
}

.ai-tour-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.ai-tour-tooltip-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.ai-tour-step-count {
  font-size: 0.75rem;
  color: var(--text-medium);
  background: var(--sidebar-bg);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.ai-tour-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-medium);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.ai-tour-close:hover {
  color: var(--text-dark);
}

.ai-tour-tooltip-title {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  color: var(--text-dark);
}

.ai-tour-tooltip-content {
  margin: 0 0 1rem 0;
  font-size: 0.875rem;
  color: var(--text-medium);
  line-height: 1.5;
}

.ai-tour-tooltip-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* Tooltip Arrow */
.ai-tour-tooltip-arrow {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  transform: rotate(45deg);
}

.ai-tour-arrow-top {
  bottom: -7px;
  left: 50%;
  margin-left: -6px;
  border-top: none;
  border-left: none;
}

.ai-tour-arrow-bottom {
  top: -7px;
  left: 50%;
  margin-left: -6px;
  border-bottom: none;
  border-right: none;
}

.ai-tour-arrow-left {
  right: -7px;
  top: 50%;
  margin-top: -6px;
  border-bottom: none;
  border-left: none;
}

.ai-tour-arrow-right {
  left: -7px;
  top: 50%;
  margin-top: -6px;
  border-top: none;
  border-right: none;
}

/* Tour Complete Message */
.ai-tour-complete {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: var(--z-tour-highlight);
  animation: pop-in 0.4s ease-out;
}

.ai-tour-complete-content {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
  padding: 2rem;
  text-align: center;
  max-width: 300px;
}

.ai-tour-complete-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.ai-tour-complete h3 {
  margin: 0 0 0.5rem 0;
  color: var(--text-dark);
}

.ai-tour-complete p {
  margin: 0 0 1.5rem 0;
  color: var(--text-medium);
  font-size: 0.9rem;
}

.ai-tour-complete.fade-out {
  animation: fade-out 0.3s ease-out forwards;
}

/* Animations */
@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pop-in {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
  }
  70% {
    transform: translate(-50%, -50%) scale(1.05);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* Mobile responsive */
@media (max-width: 768px) {
  .ai-tour-prompt {
    bottom: 80px;
    right: 10px;
    left: 10px;
  }

  .ai-tour-prompt-content {
    max-width: none;
  }

  .ai-tour-tooltip {
    max-width: calc(100vw - 40px);
    left: 20px !important;
    right: 20px;
  }
}

/* Mobile responsive */
@media (max-width: 768px) {
  #ai-chat-widget {
    bottom: 1rem;
    right: 1rem;
  }

  .ai-chat-button {
    width: 56px;
    height: 56px;
  }

  .ai-chat-tooltip {
    display: none;
  }

  .ai-chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }

  .ai-chat-panel.open {
    position: fixed;
    top: 0;
  }

  .ai-chat-header {
    padding: 1rem;
    padding-top: env(safe-area-inset-top, 1rem);
  }

  .ai-chat-messages {
    padding: 1rem;
  }

  .ai-chat-input-container {
    padding: 0.75rem 1rem;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  }

  .ai-chat-suggestions {
    padding: 0.5rem;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .ai-suggestion-btn {
    flex-shrink: 0;
  }
}

/* Small mobile */
@media (max-width: 380px) {
  .ai-chat-input {
    padding: 0.625rem 0.875rem;
    font-size: 1rem; /* Prevent iOS zoom */
  }

  .ai-chat-send {
    width: 40px;
    height: 40px;
  }

  .ai-suggestion-btn {
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
  }
}

/* ========================================
   AI CHAT MOBILE ENHANCEMENTS
   ======================================== */

/* Mobile AI Chat - Better touch targets and responsiveness */
@media (max-width: 768px) {
  /* Quick action buttons - larger touch targets */
  .ai-quick-actions {
    gap: 0.625rem;
    margin-top: 0.75rem;
  }

  .ai-quick-action {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    min-height: 44px;
    border-radius: 22px;
    flex: 1 1 auto;
    text-align: center;
    justify-content: center;
  }

  /* Message content - better readability */
  .ai-message {
    max-width: 95%;
  }

  .ai-message-text {
    padding: 0.875rem 1rem;
    font-size: 0.95rem;
    line-height: 1.6;
  }

  .ai-message-avatar {
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
  }

  /* Product cards - stack better on mobile */
  .ai-product-card {
    flex-wrap: wrap;
    padding: 0.875rem;
    gap: 0.5rem;
  }

  .ai-product-info {
    flex: 1 1 60%;
    min-width: 120px;
  }

  .ai-product-name {
    font-size: 0.9rem;
    white-space: normal;
    word-break: break-word;
  }

  .ai-product-vendor {
    font-size: 0.8rem;
  }

  .ai-product-price {
    font-size: 1rem;
    flex-shrink: 0;
  }

  .ai-add-cart-btn {
    padding: 0.625rem 1rem;
    font-size: 0.85rem;
    min-height: 40px;
    flex-shrink: 0;
  }

  /* Reminder items - better mobile layout */
  .ai-reminder-item {
    flex-wrap: wrap;
    padding: 0.875rem;
    gap: 0.5rem;
  }

  .ai-reminder-info {
    flex: 1 1 70%;
    min-width: 120px;
  }

  .ai-reminder-product {
    font-size: 0.9rem;
  }

  .ai-reorder-btn {
    padding: 0.625rem 1rem;
    font-size: 0.85rem;
    min-height: 40px;
  }

  /* Stats grid - 2 columns on mobile */
  .ai-stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.625rem;
  }

  .ai-stat-card {
    padding: 0.875rem;
  }

  .ai-stat-value {
    font-size: 1.2rem;
  }

  .ai-stat-label {
    font-size: 0.75rem;
  }

  /* Price table - horizontal scroll friendly */
  .ai-price-table {
    margin-top: 0.75rem;
    border-radius: 8px;
    overflow: hidden;
  }

  .ai-price-table th,
  .ai-price-table td {
    padding: 0.625rem 0.5rem;
    font-size: 0.85rem;
  }

  /* Suggestions - larger buttons */
  .ai-suggestion-btn {
    padding: 0.625rem 0.875rem;
    font-size: 0.85rem;
    min-height: 44px;
  }

  .ai-suggestion-icon {
    font-size: 1.1rem;
  }

  /* Welcome message */
  .ai-chat-welcome {
    padding: 1.5rem 1rem;
  }

  .ai-chat-welcome-icon {
    font-size: 2.5rem;
  }

  .ai-chat-welcome h3 {
    font-size: 1.15rem;
  }

  .ai-chat-welcome p {
    font-size: 0.95rem;
  }

  /* Guide messages */
  .ai-guide-header {
    font-size: 0.95rem;
  }

  .ai-guide-progress-text {
    font-size: 0.8rem;
  }
}

/* Very small mobile - extra adjustments */
@media (max-width: 380px) {
  .ai-quick-actions {
    flex-direction: column;
  }

  .ai-quick-action {
    width: 100%;
  }

  .ai-product-card {
    padding: 0.75rem;
  }

  .ai-product-info {
    flex: 1 1 100%;
    order: 1;
  }

  .ai-product-price {
    order: 2;
    flex: 0 0 auto;
  }

  .ai-add-cart-btn {
    order: 3;
    flex: 0 0 auto;
  }

  .ai-reminder-item {
    padding: 0.75rem;
  }

  .ai-stats-grid {
    grid-template-columns: 1fr;
  }
}

/* Touch optimizations for AI chat */
.ai-quick-action,
.ai-suggestion-btn,
.ai-add-cart-btn,
.ai-reorder-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* Active states for touch feedback */
.ai-quick-action:active,
.ai-suggestion-btn:active {
  transform: scale(0.97);
  opacity: 0.9;
}

.ai-add-cart-btn:active,
.ai-reorder-btn:active {
  background: #c53030;
  transform: scale(0.97);
}

/* ========================================
   PROFESSIONAL MOBILE ENHANCEMENTS
   ======================================== */

/* Table Responsive Wrapper */
.table-responsive,
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
}

.table-responsive::-webkit-scrollbar,
.table-wrapper::-webkit-scrollbar {
  height: 6px;
}

.table-responsive::-webkit-scrollbar-track,
.table-wrapper::-webkit-scrollbar-track {
  background: var(--border-color);
  border-radius: 3px;
}

.table-responsive::-webkit-scrollbar-thumb,
.table-wrapper::-webkit-scrollbar-thumb {
  background: var(--text-light);
  border-radius: 3px;
}

.table-responsive .table,
.table-wrapper .table {
  min-width: 600px;
}

/* Mobile-friendly touch targets (44px minimum per Apple/Google HIG) */
.btn,
.btn-sm,
button,
.nav-item,
.tab,
select {
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation; /* Improves touch responsiveness by disabling double-tap zoom */
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1); /* Visual feedback on tap */
}

/* Checkboxes and radios should not be oversized - use their label for touch target instead */
input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  cursor: pointer;
}

.btn-sm {
  padding: 0.5rem 1rem;
  min-height: 36px; /* Slightly smaller but still touch-friendly */
  font-size: 0.875rem;
}

/* Badge improvements */
.badge,
.status-badge {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success {
  background-color: #d4edda;
  color: #155724;
}
.badge-warning {
  background-color: #fff3cd;
  color: #856404;
}
.badge-danger {
  background-color: #f8d7da;
  color: #721c24;
}
.badge-info {
  background-color: #d1ecf1;
  color: #0c5460;
}
.badge-primary {
  background-color: #e3f2fd;
  color: #1565c0;
}

/* Tabs - horizontal scrolling on mobile */
.tabs {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  flex-wrap: nowrap;
  gap: 0;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex-shrink: 0;
  white-space: nowrap;
}

/* Grid utilities for mobile */
.grid {
  display: grid;
  gap: 1rem;
}

/* Improved form controls for mobile */
.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="date"],
input[type="search"],
select,
textarea {
  font-size: 16px; /* Prevents iOS zoom on focus */
  -webkit-appearance: none;
  appearance: none;
}

/* ========================================
   TABLET BREAKPOINT (1024px)
   ======================================== */
@media (max-width: 1024px) {
  .main-content {
    padding: 2rem;
    max-width: 100%;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .action-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .product-grid {
    grid-template-columns: repeat(3, 1fr); /* Keep 3 columns on tablets */
  }
}

/* ========================================
   MOBILE BREAKPOINT (768px)
   ======================================== */
@media (max-width: 768px) {
  /* Typography scaling */
  html {
    font-size: 15px;
  }

  .page-title {
    font-size: 1.5rem;
    line-height: 1.3;
  }

  .page-subtitle {
    font-size: 0.9rem;
  }

  /* Metric cards - stack on mobile */
  .metric-value {
    font-size: 1.75rem;
  }

  .metric-card {
    padding: 1rem;
  }

  .metric-card:hover {
    transform: none; /* Disable hover lift on touch */
  }

  /* Cards */
  .card {
    border-radius: 8px;
    margin-bottom: 1rem;
  }

  .card:hover {
    transform: none; /* Disable hover effects on touch */
  }

  /* Action cards */
  .action-cards {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .action-card {
    padding: 1.25rem;
  }

  .action-card:hover {
    transform: none;
  }

  /* Buttons - full width on mobile when in flex containers */
  .btn-group-mobile {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .btn-group-mobile .btn {
    width: 100%;
    justify-content: center;
  }

  /* Table improvements */
  .table th,
  .table td {
    padding: 0.75rem 0.5rem;
    font-size: 0.875rem;
  }

  .table-responsive .table {
    min-width: 500px;
  }

  /* Product grid - 2 columns on mobile */
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .product-card {
    padding: 1rem;
  }

  .product-price {
    font-size: 1.25rem;
  }

  .product-actions {
    flex-direction: column;
  }

  .product-actions .btn {
    width: 100%;
  }

  /* Modal - bottom sheet style */
  .modal-content {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 100%;
    width: 100%;
    max-height: 90vh;
    border-radius: 16px 16px 0 0;
    margin: 0;
    animation: slide-up-modal 0.3s ease-out;
  }

  .modal-header {
    padding: 1.25rem 1rem;
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 10;
  }

  .modal-header::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
  }

  .modal-body {
    padding: 1rem;
    padding-bottom: env(safe-area-inset-bottom, 1rem);
  }

  /* Tabs - larger touch targets */
  .tab {
    padding: 0.875rem 1.25rem;
    font-size: 0.9rem;
  }

  /* Forms */
  .form-group {
    margin-bottom: 1rem;
  }

  .form-control {
    padding: 0.875rem 1rem;
  }

  /* Login page */
  .login-card {
    padding: 2rem 1.5rem;
    margin: 1rem;
    border-radius: 16px;
  }

  .login-logo h1 {
    font-size: 1.75rem;
  }

  /* Alerts */
  .alert {
    padding: 0.875rem 1rem;
    font-size: 0.9rem;
  }

  /* Hide hover-only elements */
  .show-on-hover {
    opacity: 1 !important;
    visibility: visible !important;
  }
}

@keyframes slide-up-modal {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* ========================================
   SMALL MOBILE BREAKPOINT (480px)
   ======================================== */
@media (max-width: 480px) {
  html {
    font-size: 14px;
  }

  .main-content {
    padding: 3.5rem 0.75rem 1rem;
  }

  .page-title {
    font-size: 1.35rem;
  }

  /* Metric cards - single column */
  .metrics-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .metric-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
  }

  .metric-icon {
    font-size: 1.5rem;
  }

  .metric-value {
    font-size: 1.5rem;
    margin-bottom: 0;
  }

  .metric-label {
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
  }

  /* Cards */
  .card {
    padding: 0.875rem;
    border-radius: 8px;
  }

  .card-title {
    font-size: 1rem;
  }

  /* Tables - card view option */
  .table-card-view .table thead {
    display: none;
  }

  .table-card-view .table tbody tr {
    display: block;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
  }

  .table-card-view .table tbody td {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
  }

  .table-card-view .table tbody td:last-child {
    border-bottom: none;
  }

  .table-card-view .table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-medium);
  }

  /* Product grid */
  .product-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .product-card {
    padding: 0.75rem;
  }

  .product-name {
    font-size: 0.9rem;
  }

  .product-price {
    font-size: 1.1rem;
  }

  .product-image {
    height: 100px;
  }

  /* Buttons - ensure 48px minimum touch target for accessibility */
  .btn {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Tabs - scrollable pills */
  .tabs {
    padding: 0.5rem 0;
    gap: 0.5rem;
  }

  .tab {
    padding: 0.625rem 1rem;
    border-radius: 20px;
    background: var(--sidebar-bg);
    border: none;
    margin-bottom: 0;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .tab.active {
    background: var(--primary-red);
    color: white;
    border-bottom: none;
  }

  /* Status badges - smaller */
  .status-badge,
  .badge {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
  }

  /* Forms */
  .form-label {
    font-size: 0.875rem;
  }

  .form-control {
    padding: 0.75rem;
  }

  /* Login */
  .login-card {
    padding: 1.5rem 1rem;
  }

  .login-logo h1 {
    font-size: 1.5rem;
  }
}

/* ========================================
   EXTRA SMALL MOBILE (360px)
   ======================================== */
@media (max-width: 360px) {
  html {
    font-size: 13px;
  }

  .main-content {
    padding: 3.5rem 0.5rem 0.75rem;
  }

  .page-title {
    font-size: 1.25rem;
  }

  .card {
    padding: 0.75rem;
  }

  .product-grid {
    grid-template-columns: 1fr;
  }

  .tab {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }
}

/* ========================================
   LANDSCAPE MOBILE
   ======================================== */
@media (max-width: 768px) and (orientation: landscape) {
  .main-content {
    padding-top: 1rem;
  }

  .mobile-menu-toggle {
    top: 0.5rem;
  }

  .modal-content {
    max-height: 95vh;
  }

  .ai-chat-panel {
    max-height: 100vh;
  }
}

/* ========================================
   TOUCH DEVICE OPTIMIZATIONS
   ======================================== */
@media (hover: none) and (pointer: coarse) {
  /* Remove hover effects on touch devices */
  .card:hover,
  .metric-card:hover,
  .product-card:hover,
  .action-card:hover,
  .btn:hover {
    transform: none;
    box-shadow: var(--card-shadow);
  }

  /* Active states for touch feedback - subtle, no transform to prevent bounce */
  .btn:active,
  .nav-item:active {
    opacity: 0.85;
  }

  /* Cards shouldn't scale on touch - causes bouncy effect */
  .card,
  .product-card {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .card:active {
    opacity: 0.95;
  }

  /* Ensure touch targets are large enough */
  .nav-item {
    padding: 0.875rem 1rem;
  }

  /* Scrollable areas get momentum scrolling */
  .table-responsive,
  .tabs,
  .modal-body,
  .ai-chat-messages {
    -webkit-overflow-scrolling: touch;
  }
}

/* ========================================
   SAFE AREA INSETS (notched phones)
   ======================================== */
@supports (padding: env(safe-area-inset-bottom)) {
  .main-content {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  }

  .sidebar {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .modal-body {
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  }

  .mobile-menu-toggle {
    top: calc(1rem + env(safe-area-inset-top));
    left: calc(1rem + env(safe-area-inset-left));
  }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
  .sidebar,
  .mobile-menu-toggle,
  .mobile-overlay,
  #ai-chat-widget,
  .toast-container,
  .btn-signout,
  .theme-toggle-container {
    display: none !important;
  }

  .main-content {
    margin-left: 0;
    padding: 0;
    max-width: 100%;
  }

  .card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }

  .table-responsive {
    overflow: visible;
  }

  .table-responsive .table {
    min-width: 0;
  }
}

/* ========================================
   ENHANCED MOBILE IMPROVEMENTS
   ======================================== */

/* Horizontally scrollable tabs on mobile */
@media (max-width: 768px) {
  .tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 0.5rem;
    gap: 0.25rem;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    flex-shrink: 0;
    white-space: nowrap;
    min-width: fit-content;
  }

  /* Improved filter toggle button on mobile */
  .filter-toggle-mobile {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-dark);
    font-size: 0.9rem;
    width: 100%;
    justify-content: center;
    margin-bottom: 1rem;
  }

  /* Better spacing for form elements */
  .form-row {
    flex-direction: column;
    gap: 1rem;
  }

  .form-row > * {
    flex: 1 1 100%;
  }

  /* Improved button groups on mobile */
  .btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .btn-group .btn {
    flex: 1 1 auto;
    min-width: 100px;
  }

  /* Better search bar on mobile */
  .search-container {
    width: 100%;
  }

  .search-input {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 16px; /* Prevents iOS zoom */
  }

  /* Improved order cards for mobile */
  .order-card {
    flex-direction: column;
    gap: 1rem;
  }

  .order-card-header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* Product cards - compact view on mobile */
  .product-card .product-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .product-card .product-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* Vendor badges - horizontally scrollable */
  .vendor-badges {
    display: flex;
    overflow-x: auto;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
  }

  .vendor-badge {
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* Cart summary sticky on mobile */
  .cart-summary {
    position: sticky;
    bottom: 0;
    background: var(--card-bg);
    padding: 1rem;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    z-index: var(--z-dropdown);
    margin: 0 -0.75rem -1rem;
    border-radius: 16px 16px 0 0;
  }

  /* Improved pagination on mobile */
  .pagination {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem;
  }

  .pagination .btn {
    padding: 0.5rem 0.75rem;
    min-width: 44px;
    min-height: 44px;
  }

  /* Dashboard metrics - horizontal scroll option */
  .metrics-scroll-container {
    display: flex;
    overflow-x: auto;
    gap: 1rem;
    padding-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
  }

  .metrics-scroll-container .metric-card {
    flex: 0 0 auto;
    min-width: 160px;
  }

  /* Quick action buttons - grid on mobile */
  .quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .quick-actions-grid .btn {
    padding: 1rem;
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
    height: auto;
  }

  /* Notification badge positioning */
  .notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    font-size: 0.7rem;
  }

  /* Better select dropdowns */
  select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
    -webkit-appearance: none;
    appearance: none;
  }
}

/* Extra small screens - further optimizations */
@media (max-width: 380px) {
  .page-header {
    padding: 0 0.25rem;
  }

  .page-title {
    font-size: 1.15rem;
  }

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

  /* Compact metric cards */
  .metric-card {
    padding: 0.75rem;
  }

  .metric-value {
    font-size: 1.25rem;
  }

  .metric-label {
    font-size: 0.7rem;
  }

  /* Compact buttons */
  .btn-sm-mobile {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }

  /* Tighter table cells */
  .table th,
  .table td {
    padding: 0.5rem 0.25rem;
    font-size: 0.8rem;
  }
}

/* Landscape mode adjustments */
@media (max-width: 850px) and (orientation: landscape) {
  .main-content {
    padding: 3rem 1rem 1rem;
  }

  .metrics-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .modal-content {
    max-height: 90vh;
    max-width: 80%;
  }

  .ai-chat-panel {
    height: 100%;
    max-height: 100vh;
  }
}

/* ========================================
   MOBILE POLISH - Extra Small Screens
   ======================================== */

/* Extra small devices (320-380px) */
@media (max-width: 380px) {
  .main-content {
    padding: 3rem 0.75rem 1rem;
  }

  .card {
    padding: 0.75rem;
  }

  .modal-content {
    margin: 0.5rem;
    padding: 1rem;
  }

  .metrics-grid {
    gap: 0.5rem;
  }

  .metric-card {
    padding: 0.5rem;
  }

  .metric-value {
    font-size: 1.1rem;
  }

  h1,
  .page-title {
    font-size: 1.25rem;
  }

  h2 {
    font-size: 1.1rem;
  }
}

/* ========================================
   MOBILE POLISH - Touch Target Sizes
   Ensure minimum 44px touch targets for accessibility
   ======================================== */

@media (max-width: 768px) {
  /* Buttons and interactive elements */
  .btn,
  button,
  .filter-toggle-mobile,
  .tab,
  .nav-link,
  .dropdown-item {
    min-height: 44px;
    min-width: 44px;
  }

  /* Tags and small interactive items */
  .vendor-tag,
  .badge-clickable,
  .chip {
    min-height: 36px;
    padding: 0.5rem 0.75rem;
  }

  /* Form inputs */
  input,
  select,
  textarea {
    min-height: 44px;
  }
}

/* ========================================
   MOBILE POLISH - Overlay Z-Index Stacking
   Prevent overlays from conflicting
   ======================================== */

@media (max-width: 768px) {
  /* Lower toast z-index on mobile to not block modals */
  .toast-container {
    z-index: var(--z-modal);
  }

  /* Hide AI chat when sidebar is open */
  .sidebar-open #ai-chat-widget {
    opacity: 0.3;
    pointer-events: none;
  }

  /* Hide AI chat when bottom sheet filter is open */
  .bottom-sheet-open #ai-chat-widget {
    opacity: 0.3;
    pointer-events: none;
  }

  /* Ensure modals are above everything */
  .modal {
    z-index: var(--z-toast);
  }

  .modal-backdrop {
    z-index: var(--z-toast-below);
  }
}

/* ========================================
   MOBILE COMPREHENSIVE ENHANCEMENTS
   Feature C: Mobile Optimization
   ======================================== */

/* Notification Bell Icon */
.notification-bell {
  position: relative;
  cursor: pointer;
  padding: 0.5rem;
  margin-right: 0.5rem;
  color: var(--text-medium);
  transition: color 0.2s ease;
}

.notification-bell:hover {
  color: var(--primary-red);
}

.notification-bell .badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 18px;
  height: 18px;
  background-color: var(--primary-red);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.notification-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  width: 320px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  z-index: var(--z-header);
  display: none;
}

.notification-dropdown.active {
  display: block;
}

.notification-item {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.notification-item:hover {
  background-color: var(--hover-bg);
}

.notification-item.unread {
  background-color: rgba(255, 75, 75, 0.05);
}

.notification-item .title {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-dark);
  margin-bottom: 0.25rem;
}

.notification-item .message {
  font-size: 0.8rem;
  color: var(--text-light);
}

.notification-item .time {
  font-size: 0.7rem;
  color: var(--text-light);
  margin-top: 0.5rem;
}

/* Mobile: Notification Dropdown Full Width */
@media (max-width: 768px) {
  .notification-dropdown {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    width: 100%;
    max-height: calc(100vh - 120px);
    border-radius: 0;
  }
}

/* Header Actions Container */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Mobile: Collapsible Filter Panels */
.filter-panel-mobile {
  display: none;
}

@media (max-width: 768px) {
  .filter-panel {
    display: none;
  }

  .filter-panel-mobile {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.1);
    z-index: var(--z-dropdown);
    padding: 1rem;
    transform: translateY(calc(100% - 50px));
    transition: transform 0.3s ease;
  }

  .filter-panel-mobile.expanded {
    transform: translateY(0);
  }

  .filter-panel-mobile .filter-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem;
    color: var(--text-dark);
    font-weight: 600;
    cursor: pointer;
  }

  .filter-panel-mobile .filter-content {
    display: none;
    padding-top: 1rem;
  }

  .filter-panel-mobile.expanded .filter-content {
    display: block;
  }
}

/* Mobile: Horizontal Scroll Tables */
.table-container {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  .table-container {
    margin: 0 -1rem;
    padding: 0 1rem;
    width: calc(100% + 2rem);
  }

  .table-container table {
    min-width: 600px;
  }

  /* Scrollbar styling for mobile */
  .table-container::-webkit-scrollbar {
    height: 6px;
  }

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

  .table-container::-webkit-scrollbar-thumb {
    background: var(--text-light);
    border-radius: 3px;
  }
}

/* Mobile: Product Cards Single Column */
@media (max-width: 768px) {
  .products-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }

  .product-card {
    margin-bottom: 0;
  }

  .product-card .actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .product-card .actions button {
    width: 100%;
    min-height: 44px;
  }
}

/* Mobile: Two-column layouts stack vertically */
@media (max-width: 768px) {
  .two-column-layout {
    flex-direction: column !important;
  }

  .two-column-layout > .left-panel,
  .two-column-layout > .right-panel,
  .two-column-layout > .column,
  .two-column-layout > div {
    width: 100% !important;
    max-width: none !important;
    flex: none !important;
  }
}

/* Mobile: Tools page layouts */
@media (max-width: 768px) {
  .tool-section {
    flex-direction: column;
  }

  .tool-section .input-area,
  .tool-section .results-area {
    width: 100%;
  }

  /* Delivery Calculator */
  .delivery-calc-container {
    flex-direction: column;
  }

  .delivery-calc-container .input-panel,
  .delivery-calc-container .results-panel {
    width: 100%;
  }

  /* Order Builder */
  .order-builder-container {
    flex-direction: column;
  }

  /* AI Order */
  .ai-order-container {
    flex-direction: column;
  }
}

/* Mobile: Improved Card Layouts */
@media (max-width: 768px) {
  .card {
    padding: 1rem;
    margin-bottom: 1rem;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .card-header .actions {
    width: 100%;
    display: flex;
    gap: 0.5rem;
  }

  .card-header .actions button {
    flex: 1;
  }
}

/* Mobile: Stats Cards Row */
@media (max-width: 768px) {
  .stats-row {
    flex-direction: column;
    gap: 0.75rem;
  }

  .stat-card {
    width: 100%;
  }
}

/* Mobile: Dashboard Tabs */
@media (max-width: 768px) {
  .tab-navigation {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    padding-bottom: 0.5rem;
  }

  .tab-navigation::-webkit-scrollbar {
    display: none;
  }

  .tab-button {
    display: inline-flex;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }
}

/* Mobile: Saved Carts & Recurring Lists UI */
.saved-carts-list,
.recurring-lists-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.saved-cart-item,
.recurring-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: all 0.2s ease;
}

.saved-cart-item:hover,
.recurring-list-item:hover {
  border-color: var(--primary-blue);
  box-shadow: var(--shadow-sm);
}

.saved-cart-item .info,
.recurring-list-item .info {
  flex: 1;
}

.saved-cart-item .name,
.recurring-list-item .name {
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 0.25rem;
}

.saved-cart-item .meta,
.recurring-list-item .meta {
  font-size: 0.8rem;
  color: var(--text-light);
}

.saved-cart-item .actions,
.recurring-list-item .actions {
  display: flex;
  gap: 0.5rem;
}

@media (max-width: 768px) {
  .saved-cart-item,
  .recurring-list-item {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .saved-cart-item .actions,
  .recurring-list-item .actions {
    width: 100%;
    justify-content: stretch;
  }

  .saved-cart-item .actions button,
  .recurring-list-item .actions button {
    flex: 1;
    min-height: 44px;
  }
}

/* Mobile: Checkout Flow UI */
.checkout-summary {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.checkout-vendor {
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 0;
}

.checkout-vendor:last-child {
  border-bottom: none;
}

.checkout-vendor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.checkout-vendor-name {
  font-weight: 600;
  color: var(--text-dark);
}

.checkout-vendor-total {
  font-weight: 700;
  color: var(--primary-green);
}

.checkout-vendor-status {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.checkout-vendor-status.meets-minimum {
  background-color: rgba(76, 175, 80, 0.1);
  color: var(--primary-green);
}

.checkout-vendor-status.below-minimum {
  background-color: rgba(255, 75, 75, 0.1);
  color: var(--primary-red);
}

.checkout-totals {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 2px solid var(--border-color);
}

.checkout-total-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
}

.checkout-total-row.grand-total {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-dark);
}

.checkout-actions {
  margin-top: 1.5rem;
  display: flex;
  gap: 1rem;
}

@media (max-width: 768px) {
  .checkout-actions {
    flex-direction: column;
  }

  .checkout-actions button {
    width: 100%;
    min-height: 48px;
  }
}

/* Vendor Preferences UI */
.vendor-preferences {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.vendor-pref-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.vendor-pref-item .vendor-name {
  font-weight: 500;
}

.vendor-pref-item .pref-toggle {
  display: flex;
  gap: 0.5rem;
}

.vendor-pref-item .pref-btn {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.vendor-pref-item .pref-btn.preferred {
  background-color: rgba(76, 175, 80, 0.1);
  color: var(--primary-green);
  border-color: var(--primary-green);
}

.vendor-pref-item .pref-btn.blocked {
  background-color: rgba(255, 75, 75, 0.1);
  color: var(--primary-red);
  border-color: var(--primary-red);
}

@media (max-width: 768px) {
  .vendor-preferences {
    grid-template-columns: 1fr;
  }
}

/* Mobile: Fixed Bottom Action Bar */
.mobile-action-bar {
  display: none;
}

@media (max-width: 768px) {
  .mobile-action-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    gap: 0.5rem;
    z-index: 90;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  }

  .mobile-action-bar button {
    flex: 1;
    min-height: 44px;
  }

  /* Add padding to main content when action bar is present */
  .main-content-with-action-bar {
    padding-bottom: 80px;
  }
}

/* Touch-friendly improvements */
@media (max-width: 768px) {
  /* Larger touch targets */
  .btn,
  button,
  .nav-item,
  input,
  select,
  textarea {
    min-height: 44px;
  }

  /* More spacing for touch */
  .btn-group button {
    margin: 0 2px;
  }

  /* Improved link spacing */
  a {
    padding: 0.25rem 0;
  }

  /* Better form spacing */
  .form-group {
    margin-bottom: 1rem;
  }

  /* Checkbox and radio larger */
  input[type="checkbox"],
  input[type="radio"] {
    width: 22px;
    height: 22px;
  }

  /* Toggle switches */
  .toggle-switch {
    min-width: 52px;
    min-height: 28px;
  }
}

/* ============================================================
   TOGGLE SWITCH COMPONENT
   ============================================================ */

.fc-toggle-switch {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  position: relative;
}

.fc-toggle-switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.fc-toggle-switch .toggle-slider {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  background: var(--border-color, #ccc);
  border-radius: 26px;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.fc-toggle-switch .toggle-slider::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.fc-toggle-switch input[type="checkbox"]:checked + .toggle-slider {
  background: var(--accent-color, #22c55e);
}

.fc-toggle-switch input[type="checkbox"]:checked + .toggle-slider::after {
  transform: translateX(22px);
}

.fc-toggle-switch .toggle-label {
  font-size: 0.95rem;
  color: var(--text-primary);
}

/* ============================================================
   MOBILE UX POLISH - Hardening Pass
   ============================================================ */

/* Table containers: horizontal scroll on overflow */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
}

.table-container table {
  min-width: 600px;
}

/* Mobile-specific UX improvements */
@media (max-width: 768px) {
  /* Increased button/toggle padding for touch */
  .btn {
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
  }

  .btn-sm {
    padding: 0.5rem 0.875rem;
    min-height: 40px;
  }

  /* Product cards - full width with consistent margins */
  .product-card,
  .grouped-product-card,
  .offer-card,
  .vendor-card {
    width: 100%;
    margin: 0 0 1rem 0;
  }

  /* Product grid - single column on mobile */
  .product-grid,
  .offers-grid,
  .grouped-products-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  /* Expand/collapse chevrons - 44x44px touch area */
  .expand-toggle,
  .collapse-toggle,
  .chevron-toggle,
  .accordion-toggle,
  [data-toggle="collapse"],
  .expand-btn,
  .collapse-btn {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }

  /* Card headers with toggles */
  .card-header-toggle,
  .expandable-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
    padding: 0.5rem 0.75rem;
  }

  /* Dashboard tables - ensure scrollable */
  .dashboard-table-container,
  .stats-table-container,
  .orders-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Improve spacing in card bodies */
  .card-body {
    padding: 1rem;
  }

  /* Filter buttons and tags */
  .filter-btn,
  .filter-tag,
  .tag {
    padding: 0.5rem 0.75rem;
    min-height: 36px;
  }

  /* Action buttons in lists/tables */
  .action-btn,
  .row-action {
    min-width: 40px;
    min-height: 40px;
    padding: 0.5rem;
  }

  /* Dropdown menus - larger touch targets */
  .dropdown-item {
    padding: 0.75rem 1rem;
    min-height: 44px;
  }

  /* Navigation tabs */
  .nav-tabs .nav-link,
  .tab-link {
    padding: 0.75rem 1rem;
    min-height: 44px;
  }

  /* Search inputs */
  .search-input,
  .search-box input {
    padding: 0.75rem 1rem;
    font-size: 16px; /* Prevents iOS zoom */
  }

  /* Modal improvements */
  .modal-content {
    margin: 0.5rem;
    max-height: calc(100vh - 1rem);
    overflow-y: auto;
  }

  /* Bottom spacing for pages with action bars */
  .page-content {
    padding-bottom: 100px;
  }
}

/* ============================================
   FreshConnects Component System (.fc-*)
   Standard component classes for UX consistency
   ============================================ */

/* FC Card - Standard card container */
.fc-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  transition: all 0.2s ease;
}

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

.fc-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.fc-card-body {
  color: var(--text-dark);
}

/* FC Card Grid - Responsive grid for cards */
.fc-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
}

/* FC CTA Grid - Primary action buttons grid */
.fc-cta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

/* FC Button Primary - Main action button */
.fc-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, var(--primary-red) 0%, #c73e1d 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  min-height: 56px;
  box-shadow: 0 4px 12px rgba(247, 37, 52, 0.3);
}

.fc-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(247, 37, 52, 0.4);
}

/* FC Button Secondary - Secondary action button */
.fc-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: var(--card-bg);
  color: var(--text-dark);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  min-height: 56px;
}

.fc-btn-secondary:hover {
  border-color: var(--primary-red);
  background: var(--hover-bg);
}

/* FC Section Title */
.fc-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 2rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

/* FC Badge - Status/category badges */
.fc-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.fc-badge.success {
  background: #e8f5e9;
  color: #2e7d32;
}
.fc-badge.warning {
  background: #fff3e0;
  color: #e65100;
}
.fc-badge.info {
  background: #e3f2fd;
  color: #1565c0;
}
.fc-badge.error {
  background: #ffebee;
  color: #c62828;
}

/* FC Layout Grid - Standard grid layout */
.fc-layout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

/* FC Layout Column - Single column layout */
.fc-layout-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Vendor-specific button variant */
.fc-btn-primary.vendor {
  background: linear-gradient(135deg, var(--primary-green) 0%, #388e3c 100%);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.fc-btn-primary.vendor:hover {
  box-shadow: 0 6px 16px rgba(76, 175, 80, 0.4);
}

/* Admin-specific button variant */
.fc-btn-primary.admin {
  background: linear-gradient(135deg, var(--primary-blue) 0%, #1565c0 100%);
  box-shadow: 0 4px 12px rgba(30, 136, 229, 0.3);
}

.fc-btn-primary.admin:hover {
  box-shadow: 0 6px 16px rgba(30, 136, 229, 0.4);
}

/* Mobile responsiveness for FC components */
@media (max-width: 768px) {
  .fc-cta-grid {
    grid-template-columns: 1fr;
  }

  .fc-card-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .fc-btn-primary,
  .fc-btn-secondary {
    width: 100%;
    min-height: 48px;
  }
}

@media (max-width: 480px) {
  .fc-card-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   PHASE 4: Stripe + Shopify + Notion UI Polish
   Modern SaaS styling system
   ============================================ */

/* --- Typography System --- */
.fc-h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0;
}

.fc-h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-dark);
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 0;
}

.fc-h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-dark);
  line-height: 1.4;
  margin: 0;
}

.fc-body {
  font-size: 0.9375rem;
  color: var(--text-medium);
  line-height: 1.6;
}

.fc-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.fc-muted {
  color: var(--text-light);
}

/* --- Spacing Utilities (8px scale) --- */
.fc-mb-4 {
  margin-bottom: 4px;
}
.fc-mb-8 {
  margin-bottom: 8px;
}
.fc-mb-12 {
  margin-bottom: 12px;
}
.fc-mb-16 {
  margin-bottom: 16px;
}
.fc-mb-24 {
  margin-bottom: 24px;
}
.fc-mb-32 {
  margin-bottom: 32px;
}

.fc-mt-4 {
  margin-top: 4px;
}
.fc-mt-8 {
  margin-top: 8px;
}
.fc-mt-12 {
  margin-top: 12px;
}
.fc-mt-16 {
  margin-top: 16px;
}
.fc-mt-24 {
  margin-top: 24px;
}
.fc-mt-32 {
  margin-top: 32px;
}

.fc-p-8 {
  padding: 8px;
}
.fc-p-12 {
  padding: 12px;
}
.fc-p-16 {
  padding: 16px;
}
.fc-p-24 {
  padding: 24px;
}
.fc-p-32 {
  padding: 32px;
}

.fc-gap-8 {
  gap: 8px;
}
.fc-gap-12 {
  gap: 12px;
}
.fc-gap-16 {
  gap: 16px;
}
.fc-gap-24 {
  gap: 24px;
}

/* --- Form Width Utilities --- */
.fc-form-max-width {
  max-width: 600px;
}
.fc-form-max-width-lg {
  max-width: 800px;
}

/* --- Callout Boxes --- */
.fc-callout {
  padding: 1rem;
  border-radius: 8px;
  border-left: 4px solid var(--border-color);
  background: var(--hover-bg);
}
.fc-callout-info {
  background: #e3f2fd;
  border-left-color: #2196f3;
}
.fc-callout-success {
  background: #e8f5e9;
  border-left-color: #4caf50;
}
.fc-callout-warning {
  background: #fff3e0;
  border-left-color: #ff9800;
}
.fc-callout-danger {
  background: #ffebee;
  border-left-color: #f44336;
}

/* --- Count/Summary Box --- */
.fc-count-box {
  background: var(--hover-bg);
  padding: 1rem;
  border-radius: 8px;
}

/* --- Button Variants --- */
.fc-btn-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.fc-btn-pill {
  border-radius: 20px;
}

.fc-btn-danger {
  background: #ef4444;
  color: white;
}

.fc-btn-danger:hover {
  background: #dc2626;
}

.fc-btn-warning {
  background: #f59e0b;
  color: white;
}

.fc-btn-warning:hover {
  background: #d97706;
}

.fc-btn-success {
  background: #22c55e;
  color: white;
}

.fc-btn-success:hover {
  background: #16a34a;
}

.fc-btn-ghost {
  background: transparent;
  color: var(--text-medium);
  border: 1px solid var(--border-color);
}

.fc-btn-ghost:hover {
  background: var(--hover-bg);
  border-color: var(--text-light);
}

/* --- KPI / Metric Cards --- */
.fc-kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  transition: all 0.2s ease;
}

.fc-kpi-card:hover {
  box-shadow: var(--shadow-md);
}

.fc-kpi-card.clickable {
  cursor: pointer;
}

.fc-kpi-card.clickable:hover {
  transform: translateY(-2px);
  border-color: var(--primary-blue);
}

.fc-kpi-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.fc-kpi-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1;
  margin-bottom: 0.25rem;
}

.fc-kpi-trend {
  font-size: 0.75rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.fc-kpi-trend.positive {
  color: #22c55e;
}
.fc-kpi-trend.negative {
  color: #ef4444;
}
.fc-kpi-trend.neutral {
  color: var(--text-light);
}

.fc-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

/* --- Enhanced Tables (Stripe-style) --- */
.fc-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.fc-table th,
.fc-table td {
  padding: 0.875rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.fc-table th {
  background: var(--sidebar-bg);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  position: sticky;
  top: 0;
  z-index: 10;
}

.fc-table tbody tr {
  transition: background 0.15s ease;
}

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

.fc-table tbody tr:last-child td {
  border-bottom: none;
}

/* Alternating row colors (optional) */
.fc-table.striped tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .fc-table.striped tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

/* Table actions column */
.fc-table-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* --- Impersonation Banner (Stripe-style notification bar) --- */
.fc-impersonation-banner {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  color: white;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.fc-impersonation-banner .banner-icon {
  font-size: 1.25rem;
}

.fc-impersonation-banner .banner-text {
  font-size: 0.9rem;
  font-weight: 500;
}

.fc-impersonation-banner .banner-text strong {
  font-weight: 700;
}

.fc-impersonation-banner .banner-exit-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 0.375rem 0.875rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.fc-impersonation-banner .banner-exit-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* --- Filter / Search Areas --- */
.fc-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 0;
  flex-wrap: wrap;
}

.fc-search-input {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
  padding: 0.625rem 1rem;
  padding-left: 2.5rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text-dark);
  font-size: 0.9rem;
  transition: all 0.15s ease;
}

.fc-search-input:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.1);
}

.fc-search-wrapper {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

.fc-search-wrapper::before {
  content: "🔍";
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  opacity: 0.5;
}

.fc-filter-select {
  padding: 0.625rem 2rem 0.625rem 0.875rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text-dark);
  font-size: 0.875rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
}

.fc-filter-select:focus {
  outline: none;
  border-color: var(--primary-blue);
}

/* Pill-style filter buttons */
.fc-filter-pills {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.fc-filter-pill {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  background: var(--card-bg);
  color: var(--text-medium);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.fc-filter-pill:hover {
  border-color: var(--primary-blue);
  color: var(--primary-blue);
}

.fc-filter-pill.active {
  background: var(--primary-blue);
  border-color: var(--primary-blue);
  color: white;
}

/* --- Page Header --- */
.fc-page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.fc-page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0;
}

.fc-page-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

/* --- Dividers --- */
.fc-divider {
  height: 1px;
  background: var(--border-color);
  margin: 1.5rem 0;
}

.fc-divider-light {
  height: 1px;
  background: var(--border-color);
  opacity: 0.5;
  margin: 1rem 0;
}

/* --- Empty State --- */
.fc-empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-light);
}

.fc-empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.fc-empty-state h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 0.5rem;
}

.fc-empty-state p {
  font-size: 0.9rem;
  color: var(--text-light);
}

/* --- Status Badges (Enhanced) --- */
.fc-status {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.fc-status-active {
  background: #dcfce7;
  color: #166534;
}
.fc-status-pending {
  background: #fef3c7;
  color: #92400e;
}
.fc-status-suspended {
  background: #fee2e2;
  color: #dc2626;
}
.fc-status-inactive {
  background: #f3f4f6;
  color: #6b7280;
}

[data-theme="dark"] .fc-status-active {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
}
[data-theme="dark"] .fc-status-pending {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
}
[data-theme="dark"] .fc-status-suspended {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}
[data-theme="dark"] .fc-status-inactive {
  background: rgba(107, 114, 128, 0.2);
  color: #9ca3af;
}

/* --- Role Badges --- */
.fc-role {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.fc-role-admin {
  background: #dbeafe;
  color: #1e40af;
}
.fc-role-retail {
  background: #f3e8ff;
  color: #7c3aed;
}
.fc-role-wholesaler {
  background: #fef3c7;
  color: #b45309;
}

[data-theme="dark"] .fc-role-admin {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}
[data-theme="dark"] .fc-role-retail {
  background: rgba(139, 92, 246, 0.2);
  color: #c4b5fd;
}
[data-theme="dark"] .fc-role-wholesaler {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
}

/* --- Generic Badges (for flexibility) --- */
.fc-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.fc-badge-success {
  background: #dcfce7;
  color: #166534;
}
.fc-badge-warning {
  background: #fef3c7;
  color: #92400e;
}
.fc-badge-danger {
  background: #fee2e2;
  color: #dc2626;
}
.fc-badge-info {
  background: #dbeafe;
  color: #1e40af;
}
.fc-badge-muted {
  background: #f3f4f6;
  color: #6b7280;
}

[data-theme="dark"] .fc-badge-success {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
}
[data-theme="dark"] .fc-badge-warning {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
}
[data-theme="dark"] .fc-badge-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}
[data-theme="dark"] .fc-badge-info {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}
[data-theme="dark"] .fc-badge-muted {
  background: rgba(107, 114, 128, 0.2);
  color: #9ca3af;
}

/* --- Text Utilities --- */
.fc-text-muted {
  color: var(--text-light);
  font-size: 0.875rem;
}

.fc-text-small {
  font-size: 0.8rem;
}

.fc-text-center {
  text-align: center;
}
.fc-text-right {
  text-align: right;
}

/* --- Empty State --- */
.fc-empty-state {
  color: var(--text-light);
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.875rem;
}

.fc-empty-state-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  opacity: 0.5;
}

/* --- Modal System --- */
.fc-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: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

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

.fc-modal {
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow: hidden;
  transform: scale(0.95) translateY(20px);
  transition: transform 0.2s ease;
}

.fc-modal-overlay.active .fc-modal {
  transform: scale(1) translateY(0);
}

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

.fc-modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-dark);
  margin: 0;
}

.fc-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-light);
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: color 0.2s;
}

.fc-modal-close:hover {
  color: var(--text-dark);
}

.fc-modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  max-height: calc(90vh - 140px);
}

.fc-modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* --- Form Components --- */
.fc-form-group {
  margin-bottom: 1rem;
}

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

.fc-input,
.fc-select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text-dark);
  font-size: 0.9375rem;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.fc-input:focus,
.fc-select:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.15);
}

.fc-input::placeholder {
  color: var(--text-light);
}

.fc-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23808495' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.875rem center;
  padding-right: 2.5rem;
}

/* --- Mobile Cards (for table conversion) --- */
.fc-mobile-cards {
  display: none;
}

.fc-mobile-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.fc-mobile-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.fc-mobile-card-title {
  font-weight: 600;
  color: var(--text-dark);
  font-size: 1rem;
}

.fc-mobile-card-body {
  display: grid;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.fc-mobile-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.fc-mobile-card-label {
  color: var(--text-light);
  font-size: 0.8rem;
}

.fc-mobile-card-value {
  color: var(--text-dark);
  font-weight: 500;
}

.fc-mobile-card-footer {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
}

.fc-mobile-card-footer .fc-btn-small {
  flex: 1;
  justify-content: center;
}

/* --- Toast Notifications --- */
.fc-toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.fc-toast {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 280px;
  max-width: 400px;
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.fc-toast-success {
  border-left: 4px solid #22c55e;
}
.fc-toast-error {
  border-left: 4px solid #ef4444;
}
.fc-toast-warning {
  border-left: 4px solid #f59e0b;
}
.fc-toast-info {
  border-left: 4px solid #3b82f6;
}

.fc-toast-icon {
  font-size: 1.25rem;
}

.fc-toast-message {
  flex: 1;
  font-size: 0.9rem;
  color: var(--text-dark);
}

.fc-toast-close {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 0.25rem;
}

/* --- Mobile Hamburger Menu --- */
.fc-mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  color: var(--text-dark);
  font-size: 1.5rem;
}

.fc-mobile-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-sidebar-overlay);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.fc-mobile-overlay.show {
  display: block;
  opacity: 1;
}

/* Hamburger Button (added by NavManager) */
.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: var(--z-header);
  transition: all 0.2s ease;
}

.hamburger-btn:hover {
  background: var(--hover-bg);
  border-color: var(--primary-blue);
}

.hamburger-line {
  width: 100%;
  height: 2px;
  background: var(--text-dark);
  border-radius: 2px;
  transition: all 0.3s ease;
}

/* Sidebar Overlay (added by NavManager) */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-sidebar-overlay);
  opacity: 0;
  transition: opacity 0.3s ease;
}

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

/* Sidebar open state */
.sidebar.mobile-open {
  transform: translateX(0) !important;
}

/* Body when sidebar is open - prevent scroll */
body.sidebar-open {
  overflow: hidden;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 1024px) {
  .fc-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  /* Show hamburger menu buttons */
  .fc-mobile-menu-btn,
  .hamburger-btn {
    display: flex;
  }

  /* Main content padding for hamburger button */
  .main-content {
    padding-top: 4rem;
  }

  /* Sidebar slide-out behavior */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: var(
      --z-overlay
    ); /* Must be higher than mobile-overlay and sidebar-overlay */
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    padding-bottom: env(
      safe-area-inset-bottom,
      20px
    ); /* Account for iPhone notch/home indicator */
  }

  .sidebar.open,
  .sidebar.mobile-open {
    transform: translateX(0);
  }

  /* Larger nav items on mobile for easier tapping */
  .sidebar .nav-item {
    font-size: 1.1rem;
    padding: 1rem 1.25rem;
    min-height: 48px; /* Touch target size */
  }

  .sidebar .nav-section-title {
    font-size: 0.85rem;
    padding: 0.75rem 1.25rem;
  }

  /* Ensure footer is visible */
  .sidebar-footer {
    padding: 1.25rem 1.5rem;
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 20px));
  }

  .sidebar-footer .btn {
    font-size: 1rem;
    padding: 0.875rem 1rem;
    min-height: 48px;
  }

  /* Page header stacks */
  .fc-page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .fc-page-actions {
    width: 100%;
  }

  .fc-page-actions .fc-btn-primary,
  .fc-page-actions .fc-btn-secondary {
    flex: 1;
  }

  /* Filter bar stacks */
  .fc-filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .fc-search-wrapper {
    max-width: none;
  }

  .fc-search-input {
    max-width: none;
    width: 100%;
  }

  .fc-filter-select {
    width: 100%;
  }

  /* KPI grid stacks */
  .fc-kpi-grid {
    grid-template-columns: 1fr;
  }

  /* Tables become card-style on mobile */
  .fc-table-responsive {
    display: block;
  }

  .fc-table-mobile-card {
    display: none;
  }

  /* Show mobile cards, hide desktop table */
  .fc-mobile-cards {
    display: block;
  }

  .fc-table-wrapper.hide-on-mobile,
  .fc-table.hide-on-mobile {
    display: none;
  }

  /* Modal adjusts for mobile */
  .fc-modal {
    width: 95%;
    max-height: 85vh;
  }

  .fc-modal-body {
    max-height: calc(85vh - 140px);
  }

  /* Toast position for mobile */
  .fc-toast-container {
    left: 1rem;
    right: 1rem;
    top: auto;
    bottom: 1rem;
  }

  .fc-toast {
    min-width: auto;
    width: 100%;
  }

  /* Impersonation banner adjusts */
  .fc-impersonation-banner {
    flex-direction: column;
    text-align: center;
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .fc-h1 {
    font-size: 1.5rem;
  }
  .fc-h2 {
    font-size: 1.25rem;
  }
  .fc-kpi-value {
    font-size: 1.5rem;
  }

  .fc-btn-primary,
  .fc-btn-secondary {
    width: 100%;
    justify-content: center;
  }

  /* Make filter pills scroll horizontally */
  .fc-filter-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
  }

  .fc-filter-pill {
    flex-shrink: 0;
  }
}

/* --- Utility Classes --- */
.fc-flex {
  display: flex;
}
.fc-flex-col {
  flex-direction: column;
}
.fc-items-center {
  align-items: center;
}
.fc-justify-between {
  justify-content: space-between;
}
.fc-justify-center {
  justify-content: center;
}
.fc-flex-wrap {
  flex-wrap: wrap;
}
.fc-flex-1 {
  flex: 1;
}
.fc-text-center {
  text-align: center;
}
.fc-text-right {
  text-align: right;
}
.fc-w-full {
  width: 100%;
}
.fc-hidden {
  display: none;
}
.fc-visible {
  display: block;
}

/* Focus ring for accessibility */
.fc-focus-ring:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.3);
}

/* ========================================
   MOBILE BOTTOM NAVIGATION
   DISABLED - Using sidebar hamburger menu instead
   ======================================== */
.mobile-bottom-nav {
  display: none !important;
}

/* ========================================
   SIDEBAR AUTO-HIDE (Desktop only)
   Hides after 4 seconds, reappears on hover
   ======================================== */

/* Sidebar trigger zone - invisible area on left edge */
.sidebar-trigger {
  display: none;
}

@media (min-width: 769px) {
  .sidebar-trigger {
    display: block;
    position: fixed;
    left: 0;
    top: 0;
    width: 20px;
    height: 100vh;
    z-index: var(--z-sidebar-active);
    background: transparent;
  }

  /* Collapsed sidebar state */
  .sidebar.collapsed {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  /* Sidebar visible state */
  .sidebar {
    transition: transform 0.3s ease;
    z-index: var(--z-header);
  }

  .sidebar:hover,
  .sidebar.visible {
    transform: translateX(0);
  }

  /* Main content adjusts when sidebar is collapsed */
  .main-content.sidebar-collapsed {
    margin-left: 0;
    transition: margin-left 0.3s ease;
  }

  .main-content {
    transition: margin-left 0.3s ease;
  }
}

/* ========================================
   MOBILE OPTIMIZATIONS - Settings & Forms
   ======================================== */
@media (max-width: 768px) {
  /* Settings tabs - scrollable on mobile */
  .settings-tabs {
    display: flex;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    gap: 0.5rem;
    padding: 0.5rem;
  }

  .settings-tab {
    flex-shrink: 0;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }

  /* Page header - stack on mobile */
  .page-header {
    padding: 1rem 0;
  }

  .page-title {
    font-size: 1.5rem;
  }

  .page-subtitle {
    font-size: 0.9rem;
  }

  /* Form groups - full width */
  .fc-form-max-width,
  .fc-form-max-width-lg {
    max-width: 100%;
  }

  /* Compact form spacing */
  .form-group {
    margin-bottom: 1rem;
  }

  .form-control {
    font-size: 16px; /* Prevent iOS zoom */
  }

  /* Cards - reduce padding */
  .card,
  .fc-card {
    padding: 1rem;
    margin-bottom: 1rem;
  }

  .card-title {
    font-size: 1.1rem;
  }

  /* Service areas - collapse checkboxes */
  .region-container {
    margin-bottom: 0.75rem;
  }

  .region-header {
    padding: 0.75rem;
  }

  .cities-grid {
    grid-template-columns: 1fr;
    padding: 0.5rem;
  }

  /* Buttons - full width on mobile */
  .btn-primary,
  .fc-btn-primary,
  .btn {
    width: 100%;
    justify-content: center;
  }

  /* Two-column button layouts */
  .button-group,
  .fc-page-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  /* Table responsiveness */
  .fc-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 600px;
  }

  /* PDF Profile Builder - wizard steps */
  .wizard-steps {
    flex-direction: column;
    gap: 0.5rem;
  }

  .wizard-step {
    width: 100%;
    text-align: left;
    padding: 1rem;
  }

  /* Filter pills - wrap on mobile */
  .fc-filter-pills {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* Stats cards - single column */
  .stats-grid,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  /* Main content - add bottom padding */
  .main-content {
    padding-bottom: 2rem;
  }
}

/* ========================================
   MOBILE TOUCH IMPROVEMENTS
   ======================================== */
@media (max-width: 768px) {
  /* Larger touch targets */
  input[type="checkbox"],
  input[type="radio"] {
    width: 22px;
    height: 22px;
  }

  /* Better checkbox labels */
  label {
    padding: 0.25rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  /* Improve dropdown usability */
  select {
    font-size: 16px;
    padding: 0.75rem;
  }

  /* Full-width inputs */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  textarea {
    font-size: 16px;
    padding: 0.75rem;
  }
}

/* ========================================
   RESPONSIVE TABLE - CARD LAYOUT FOR MOBILE
   ======================================== */
.responsive-table {
  width: 100%;
  border-collapse: collapse;
}

@media (max-width: 768px) {
  .responsive-table,
  .responsive-table thead,
  .responsive-table tbody,
  .responsive-table th,
  .responsive-table td,
  .responsive-table tr {
    display: block;
  }

  .responsive-table thead {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  .responsive-table tr {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 1rem;
    padding: 1rem;
    box-shadow: var(--shadow-sm);
  }

  .responsive-table td {
    border: none;
    position: relative;
    padding: 0.5rem 0;
    padding-left: 45%;
    text-align: left;
    min-height: 2rem;
  }

  .responsive-table td::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    width: 40%;
    padding-right: 10px;
    font-weight: 600;
    color: var(--text-medium);
    font-size: 0.85rem;
  }

  .responsive-table td:last-child {
    border-bottom: none;
  }

  /* Actions column - full width buttons */
  .responsive-table td.actions {
    padding-left: 0;
    margin-top: 0.5rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .responsive-table td.actions::before {
    display: none;
  }

  .responsive-table td.actions .btn {
    flex: 1;
    min-width: 100px;
  }
}

/* ========================================
   ENHANCED TOUCH TARGETS (44x44px minimum)
   ======================================== */
.btn,
button,
.nav-item,
.clickable {
  min-height: 44px;
  min-width: 44px;
}

.btn-sm {
  min-height: 36px;
  padding: 0.5rem 1rem;
}

@media (max-width: 768px) {
  .btn,
  button:not(.mobile-menu-toggle) {
    min-height: 48px;
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
  }

  .nav-item {
    min-height: 48px;
    padding: 0.875rem 1.5rem;
  }

  /* Icon-only buttons */
  .btn-icon {
    width: 48px;
    height: 48px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* List items as touch targets */
  .list-item,
  .card-clickable {
    min-height: 48px;
    padding: 0.75rem;
  }
}

/* ========================================
   SWIPE-FRIENDLY SIDEBAR
   ======================================== */
.sidebar {
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar.swiping {
    transition: none;
  }

  /* Swipe indicator */
  .swipe-indicator {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 60px;
    background: linear-gradient(
      90deg,
      var(--primary-blue) 0%,
      transparent 100%
    );
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    border-radius: 0 30px 30px 0;
    z-index: var(--z-sidebar-overlay);
  }

  .swipe-indicator.visible {
    opacity: 0.5;
  }
}

/* ========================================
   IMPROVED FORM INPUTS FOR MOBILE
   ======================================== */
@media (max-width: 768px) {
  .form-group {
    margin-bottom: 1.25rem;
  }

  .form-label {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    display: block;
  }

  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  input[type="date"],
  input[type="search"],
  textarea,
  select {
    font-size: 16px !important; /* Prevents iOS zoom */
    padding: 0.875rem 1rem;
    border-radius: 8px;
    min-height: 48px;
    width: 100%;
  }

  textarea {
    min-height: 120px;
    resize: vertical;
  }

  /* Search inputs */
  .search-input {
    padding-left: 2.75rem;
  }

  .search-icon {
    left: 1rem;
    font-size: 1.1rem;
  }

  /* Form actions - stack on mobile */
  .form-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .form-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ========================================
   KEYBOARD SHORTCUT HINTS
   ======================================== */
.kbd {
  display: inline-block;
  padding: 0.2em 0.5em;
  font-family: monospace;
  font-size: 0.85em;
  background: var(--hover-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.shortcut-hint {
  display: none;
  color: var(--text-light);
  font-size: 0.8rem;
  margin-left: 0.5rem;
}

/* Show keyboard hints on desktop */
@media (min-width: 769px) and (hover: hover) {
  .shortcut-hint {
    display: inline;
  }
}

/* Command palette styles */
.command-palette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-critical);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.2s,
    visibility 0.2s;
}

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

.command-palette {
  background: var(--card-bg);
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.2s;
}

.command-palette-overlay.open .command-palette {
  transform: scale(1);
}

.command-palette-input {
  width: 100%;
  padding: 1rem 1.25rem;
  border: none;
  border-bottom: 1px solid var(--border-color);
  background: transparent;
  font-size: 1.1rem;
  color: var(--text-dark);
  outline: none;
}

.command-palette-results {
  max-height: 400px;
  overflow-y: auto;
}

.command-item {
  display: flex;
  align-items: center;
  padding: 0.875rem 1.25rem;
  cursor: pointer;
  transition: background 0.15s;
}

.command-item:hover,
.command-item.selected {
  background: var(--hover-bg);
}

.command-item-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 0.75rem;
  background: var(--hover-bg);
  border-radius: 6px;
  font-size: 1rem;
}

.command-item-text {
  flex: 1;
}

.command-item-title {
  font-weight: 500;
  color: var(--text-dark);
}

.command-item-desc {
  font-size: 0.85rem;
  color: var(--text-light);
}

.command-item-shortcut {
  margin-left: 1rem;
}

/* ========================================
   SKELETON LOADING ENHANCEMENTS
   ======================================== */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--hover-bg) 25%,
    var(--border-color) 50%,
    var(--hover-bg) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: 4px;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton-text {
  height: 1rem;
  margin-bottom: 0.5rem;
}

.skeleton-text-sm {
  height: 0.75rem;
  margin-bottom: 0.375rem;
}

.skeleton-title {
  height: 1.5rem;
  margin-bottom: 0.75rem;
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.skeleton-button {
  height: 40px;
  width: 100px;
  border-radius: 6px;
}

.skeleton-image {
  height: 150px;
  border-radius: 8px;
}

.skeleton-metric {
  height: 100px;
  border-radius: 8px;
}

/* ========================================
   LAZY LOADING IMAGE PLACEHOLDERS
   ======================================== */
img[loading="lazy"] {
  opacity: 0;
  transition: opacity 0.3s;
}

img[loading="lazy"].loaded,
img[loading="lazy"]:not([src=""]) {
  opacity: 1;
}

.img-placeholder {
  background: var(--hover-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */
/* GPU acceleration for animations */
.animate-gpu {
  transform: translateZ(0);
  will-change: transform;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .skeleton {
    animation: none;
    background: var(--hover-bg);
  }
}

/* Content visibility for off-screen elements */
.lazy-section {
  content-visibility: auto;
  contain-intrinsic-size: 0 500px;
}

/* ========================================
   DATA DENSITY TOGGLE (Desktop)
   ======================================== */
[data-density="compact"] .card {
  padding: 0.75rem;
}

[data-density="compact"] .table td,
[data-density="compact"] .table th {
  padding: 0.5rem 0.75rem;
}

[data-density="compact"] .btn {
  min-height: 36px;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
}

[data-density="compact"] .nav-item {
  padding: 0.5rem 1rem;
  min-height: 36px;
}

[data-density="compact"] .form-group {
  margin-bottom: 0.75rem;
}

/* ========================================
   ENHANCED AI CHAT WIDGET STYLES
   ======================================== */

/* Capabilities list in welcome */
.ai-capabilities {
  text-align: left;
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  background: var(--hover-bg);
  border-radius: 8px;
}

.ai-capabilities-title {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-medium);
  margin-bottom: 0.5rem;
}

.ai-capabilities-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ai-capabilities-list li {
  font-size: 0.85rem;
  color: var(--text-dark);
  padding: 0.25rem 0;
  padding-left: 1.25rem;
  position: relative;
}

.ai-capabilities-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--primary-green);
  font-weight: bold;
}

/* Quick start section */
.ai-quick-start {
  margin-top: 1rem;
  text-align: center;
}

.ai-quick-start p {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

.ai-quick-start-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.ai-quick-start-btn {
  padding: 0.5rem 0.875rem;
  font-size: 0.8rem;
  background: var(--primary-blue);
  color: white;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.ai-quick-start-btn:hover {
  background: var(--primary-red);
  transform: scale(1.02);
}

/* Welcome subtitle */
.ai-welcome-subtitle {
  color: var(--text-light);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* Role-specific chat button colors */
.ai-chat-button[data-role="admin"] {
  background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
}

.ai-chat-button[data-role="wholesaler"] {
  background: linear-gradient(135deg, var(--primary-green) 0%, #388e3c 100%);
}

.ai-chat-button[data-role="retailer"] {
  background: linear-gradient(135deg, var(--primary-blue) 0%, #1565c0 100%);
}

.ai-chat-button[data-role="services"] {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

/* Improved suggestion buttons */
.ai-suggestion-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--text-dark);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.ai-suggestion-btn:hover {
  border-color: var(--primary-blue);
  background: var(--hover-bg);
  transform: translateY(-1px);
}

/* Chat messages container improvements */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  scroll-behavior: smooth;
}

/* Improved welcome screen */
.ai-chat-welcome {
  text-align: center;
  padding: 1.5rem 1rem;
}

.ai-chat-welcome h3 {
  margin: 0.75rem 0 0.25rem;
  font-size: 1.1rem;
  color: var(--text-dark);
}

.ai-chat-welcome-icon {
  font-size: 2.5rem;
  line-height: 1;
}

/* Mobile adjustments for enhanced chat */
@media (max-width: 768px) {
  .ai-capabilities {
    padding: 0.625rem 0.875rem;
  }

  .ai-capabilities-list li {
    font-size: 0.8rem;
  }

  .ai-quick-start-buttons {
    flex-direction: column;
    align-items: stretch;
  }

  .ai-quick-start-btn {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }
}

/* AI Chat Alerts */
.ai-alerts {
  margin: 1rem 0;
  text-align: left;
}

.ai-alerts-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-medium);
  margin-bottom: 0.5rem;
}

.ai-alert {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.ai-alert-action_required {
  background: #fef3c7;
  border-left: 3px solid #f59e0b;
}

.ai-alert-info {
  background: #dbeafe;
  border-left: 3px solid var(--primary-blue);
}

.ai-alert-opportunity {
  background: #fee2e2;
  border-left: 3px solid var(--primary-red);
}

.ai-alert-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.ai-alert-message {
  flex: 1;
  color: var(--text-dark);
}

.ai-alert-action {
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.ai-alert-action:hover {
  background: var(--primary-blue);
  color: white;
  border-color: var(--primary-blue);
}

/* Dark mode alert styles */
[data-theme="dark"] .ai-alert-action_required {
  background: rgba(245, 158, 11, 0.15);
}

[data-theme="dark"] .ai-alert-info {
  background: rgba(59, 130, 246, 0.15);
}

[data-theme="dark"] .ai-alert-opportunity {
  background: rgba(239, 68, 68, 0.15);
}

[data-theme="dark"] .ai-alert-action {
  background: var(--card-bg);
}

/* ==========================================
   Quick Reorder FAB (Floating Action Button)
   ========================================== */

.quick-reorder-fab {
  position: fixed;
  bottom: 100px;
  right: 20px;
  z-index: 1000;
  opacity: 0;
  transform: scale(0.8) translateY(20px);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.quick-reorder-fab.visible {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.quick-reorder-fab .fab-main {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1.25rem;
  background: linear-gradient(135deg, var(--primary-red) 0%, #c73e1d 100%);
  color: white;
  border: none;
  border-radius: 50px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(247, 37, 52, 0.4);
  transition: all 0.2s ease;
}

.quick-reorder-fab .fab-main:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(247, 37, 52, 0.5);
}

.quick-reorder-fab .fab-main:active {
  transform: translateY(0);
}

.quick-reorder-fab .fab-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.quick-reorder-fab .fab-label {
  white-space: nowrap;
}

.quick-reorder-fab .fab-tooltip {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 8px;
  padding: 0.5rem 0.75rem;
  background: var(--text-dark);
  color: white;
  font-size: 0.75rem;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transform: translateY(5px);
  transition: all 0.2s ease;
}

.quick-reorder-fab:hover .fab-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.quick-reorder-fab.loading .fab-main {
  pointer-events: none;
  opacity: 0.7;
}

.quick-reorder-fab.loading .fab-icon {
  animation: fab-spin 1s linear infinite;
}

@keyframes fab-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Mobile: Move FAB above bottom nav */
@media (max-width: 768px) {
  .quick-reorder-fab {
    bottom: 80px;
    right: 16px;
  }

  .quick-reorder-fab .fab-label {
    display: none;
  }

  .quick-reorder-fab .fab-main {
    width: 56px;
    height: 56px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
  }

  .quick-reorder-fab .fab-icon {
    font-size: 1.5rem;
  }
}

/* Dark mode FAB */
[data-theme="dark"] .quick-reorder-fab .fab-tooltip {
  background: var(--card-bg);
  color: var(--text-dark);
  border: 1px solid var(--border-color);
}
