/* ============================================
   POS SYSTEM - PROFESSIONAL STYLESHEET
   ============================================ */

/* CSS Variables */
:root {
  --primary: #0B5E88;
  --primary-dark: #003B5C;
  --accent: #2AB7E6;
  --background: #F3F6FA;
  --card: #FFFFFF;
  --foreground: #1a1a2e;
  --muted: #64748b;
  --border: #e2e8f0;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --sidebar-bg: #003B5C;
  --sidebar-text: #FFFFFF;
  --sidebar-hover: #0B5E88;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px 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);
}

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

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--background);
  color: var(--foreground);
  line-height: 1.5;
  min-height: 100vh;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
}

.login-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
  padding: 2rem;
}

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

.login-logo {
  width: 80px;
  height: 80px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  color: white;
}

.login-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 0.5rem;
}

.login-header p {
  color: var(--muted);
  font-size: 0.875rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

.form-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--foreground);
}

.form-group input,
.form-group select {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(42, 183, 230, 0.2);
}

.form-group small {
  font-size: 0.75rem;
  color: var(--muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Masquer l'en-tête du tableau sur petits écrans */
@media (max-width: 600px) {
  .data-table thead {
    display: none;
  }
  /* Masquer l'en-tête "Article | Qte | Total" sur petit écran */
  .receipt-items > div:first-child {
    display: none !important;
  }
  /* Masquer aussi l'en-tête de colonne dans les reçus (ticket) */
  .receipt-item[style*="font-weight: 700"],
  .receipt-items .receipt-item:has(.item-qty:empty) {
    display: none !important;
  }
  .data-table td {
    display: block;
    padding: 0.5rem 0.75rem;
  }
  .data-table td:before {
    content: attr(data-label);
    font-weight: 600;
    margin-right: 0.5rem;
    color: #666;
  }
  .data-table td:first-child {
    padding-top: 1rem;
  }
  .data-table td:last-child {
    padding-bottom: 1rem;
  }
  .data-table tr {
    border-bottom: 1px solid #eee;
    margin-bottom: 1rem;
    display: block;
  }
}

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

.login-error {
  color: var(--danger);
  font-size: 0.875rem;
  text-align: center;
  min-height: 1.25rem;
}

.login-footer {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}

.login-footer p {
  margin-bottom: 0.25rem;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

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

.btn-secondary:hover:not(:disabled) {
  background: #d1d5db;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--border);
  color: var(--foreground);
}

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

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

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

.btn-success:hover:not(:disabled) {
  background: #059669;
}

.btn-full {
  width: 92%;
}

.btn-small {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
}

.btn-icon {
  padding: 0.5rem;
  width: 36px;
  height: 36px;
}

.btn-logout {
  background: rgba(255, 255, 255, 0.1);
  color: var(--sidebar-text);
  width: 100%;
  justify-content: flex-start;
  margin-top: 0.5rem;
}

.btn-logout:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ============================================
   MAIN APP LAYOUT
   ============================================ */
.main-app {
  display: flex;
  min-height: 100vh;
}

/* Mobile Header */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--primary-dark);
  color: white;
  padding: 0 1rem;
  align-items: center;
  gap: 1rem;
  z-index: 100;
}

.mobile-header h1 {
  font-size: 1.125rem;
  font-weight: 600;
  flex: 1;
}

.menu-toggle {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0.5rem;
}

.mobile-user-info {
  font-size: 0.75rem;
  opacity: 0.8;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--sidebar-hover);
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  background: var(--accent);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-header span {
  font-weight: 600;
  font-size: 1.125rem;
}

.close-sidebar {
  display: none;
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  margin-left: auto;
  padding: 0.5rem;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: white;
  text-decoration: none;
}

.nav-item.active {
  background: var(--accent);
  color: white;
  text-decoration: none;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--sidebar-hover);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 40px;
  height: 40px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
}

.user-details {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-weight: 500;
  font-size: 0.875rem;
}

.user-role {
  font-size: 0.75rem;
  opacity: 0.7;
}

/* Sidebar Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 150;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 1.5rem;
  min-height: 100vh;
}

/* ============================================
   PAGE STYLES
   ============================================ */
.page {
  display: none;
}

.page.active {
  display: block;
}

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

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary-dark);
}

.page-header p {
  color: var(--muted);
  font-size: 0.875rem;
}

/* ============================================
   DASHBOARD
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.blue {
  background: rgba(11, 94, 136, 0.1);
  color: var(--primary);
}

.stat-icon.green {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.stat-icon.cyan {
  background: rgba(42, 183, 230, 0.1);
  color: var(--accent);
}

.stat-icon.orange {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.stat-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--foreground);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.card-body {
  padding: 1.25rem;
}

.recent-list,
.alert-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.recent-item,
.alert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  background: var(--background);
  border-radius: var(--radius);
  font-size: 0.875rem;
}

.recent-item .time {
  color: var(--muted);
  font-size: 0.75rem;
}

.alert-item {
  border-left: 3px solid var(--warning);
}

.alert-item.critical {
  border-left-color: var(--danger);
}

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
}

/* ============================================
   CAISSE (POS)
   ============================================ */
.caisse-container {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.5rem;
  height: calc(100vh - 3rem);
}

.caisse-products {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--card);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.search-bar svg {
  color: var(--muted);
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  border: none;
  font-size: 1rem;
  outline: none;
  background: transparent;
}

/* ============================================
   CATEGORIE CAISSE
   ============================================ */
.category-select-wrapper {
  background: var(--card);
  padding: 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.category-select-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.category-select-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.category-select-label svg {
  color: var(--primary);
}

.select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.modern-select {
  width: 100%;
  padding: 0.75rem 1rem;
  padding-right: 2.5rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--foreground);
  background: var(--card);
  cursor: pointer;
  appearance: none;
  transition: all 0.2s ease;
}

.modern-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11, 94, 136, 0.15);
}

.modern-select:hover {
  border-color: var(--primary);
}

.select-arrow {
  position: absolute;
  right: 0.75rem;
  pointer-events: none;
  color: var(--muted);
  display: flex;
  align-items: center;
}

.category-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.category-tab {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.category-tab:hover {
  border-color: var(--accent);
}

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

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  overflow-y: auto;
  flex: 1;
  padding: 0.25rem;
}

.product-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 0.75rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow);
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.product-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}

.product-card.out-of-stock {
  opacity: 0.5;
  cursor: not-allowed;
}

.product-image {
  width: 80px;
  height: 80px;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 0.5rem;
  background: var(--background);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.product-card .name {
  font-weight: 500;
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
  min-height: 2.1em;
}

.product-card .price {
  color: var(--primary);
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.barcode-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  color: var(--muted);
  background: var(--background);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

/* Cart */
.caisse-cart {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 3rem);
}

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

.cart-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--background);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
}

.cart-item .info {
  flex: 1;
  min-width: 0;
}

.cart-item .name {
  font-weight: 500;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-item .price {
  color: var(--muted);
  font-size: 0.75rem;
}

.cart-item .quantity-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cart-item .quantity-controls button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.2s;
}

.cart-item .quantity-controls button:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.cart-item .quantity-controls span {
  width: 30px;
  text-align: center;
  font-weight: 500;
}

.cart-item .item-total {
  font-weight: 600;
  font-size: 0.875rem;
  min-width: 70px;
  text-align: right;
}

.cart-item .remove-item {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 0.25rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.cart-item .remove-item:hover {
  opacity: 1;
}

.cart-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  padding: 2rem;
}

.cart-empty svg {
  margin-bottom: 1rem;
  opacity: 0.5;
}

.cart-totals {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.total-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.total-row.total-final {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--foreground);
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.caisse-cart>.btn {
  margin: 0 1rem 1rem;
  padding: 1rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.caisse-cart>.btn svg {
  width: 22px;
  height: 22px;
}

/* Groupe de boutons pour Valider vente + Calculatrice */
.btn-group-valider {
  display: flex;
  gap: 8px;
  padding: 0 1rem 1rem;
}

.btn-group-valider .btn {
  margin: 0;
}

/* Calculator Toggle Radio */
.calculator-radio {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.calculator-radio input[type="checkbox"] {
  display: none;
}

.calculator-radio .calc-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  background: var(--card);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.calculator-radio input[type="checkbox"]:checked + .calc-label {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(11, 94, 136, 0.08);
}

.calculator-radio .calc-label:hover {
  border-color: var(--primary);
  color: var(--primary);
}
@media (min-width: 640px) {
  .products-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
  }
}

@media (min-width: 1024px) {
  .products-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
  }
}

@media (min-width: 1280px) {
  .products-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 0.75rem;
  }
}

.product-image {
  width: 80px;
  height: 80px;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 0.5rem;
  background: var(--background);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.product-card .name {
  font-weight: 500;
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
  min-height: 2.1em;
}

.product-card .price {
  color: var(--primary);
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.barcode-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  color: var(--muted);
  background: var(--background);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

/* Cart */
.caisse-cart {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 3rem);
}

/* Client Number Section */
.client-number-section {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.client-number-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.client-number-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.client-number-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(42, 183, 230, 0.2);
}


.cart-item .quantity-controls button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.2s;
}

.cart-item .quantity-controls button:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.cart-item .quantity-controls span {
  width: 30px;
  text-align: center;
  font-weight: 500;
}

.cart-item .item-total {
  font-weight: 600;
  font-size: 0.875rem;
  min-width: 70px;
  text-align: right;
}

.cart-item .remove-item {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 0.25rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.cart-item .remove-item:hover {
  opacity: 1;
}

.cart-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  padding: 2rem;
}

.cart-empty svg {
  margin-bottom: 1rem;
  opacity: 0.5;
}

.cart-totals {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.total-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.total-row.total-final {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--foreground);
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.caisse-cart>.btn {
  margin: 0 1rem 1rem;
  padding: 1rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.caisse-cart>.btn svg {
  width: 22px;
  height: 22px;
}

/* ============================================
   TABLES
   ============================================ */
.filters-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filters-bar input,
.filters-bar select {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  min-width: 200px;
}

.filters-bar input:focus,
.filters-bar select:focus {
  outline: none;
  border-color: var(--accent);
}

.table-container {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

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

.data-table th {
  background: var(--background);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.data-table td {
  font-size: 0.875rem;
}

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

.data-table .actions {
  display: flex;
  gap: 0.5rem;
}

/* Actions column - align buttons to the left */
.data-table th:first-child,
.data-table td:first-child {
  text-align: left;
}

.data-table td:first-child .btn {
  margin-right: 0.25rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.badge-primary {
  background: rgba(11, 94, 136, 0.1);
  color: var(--primary);
}

.table-product-image {
  width: 45px;
  height: 45px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--background);
}

.table-product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.barcode-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  background: var(--background);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

/* ============================================
   SETTINGS
   ============================================ */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 1.5rem;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ============================================
   MODALS
   ============================================ */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-header h3 {
  font-size: 1.125rem;
  font-weight: 600;
}

.close-modal {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted);
  padding: 0.25rem;
  line-height: 1;
}

.close-modal:hover {
  color: var(--foreground);
}

.modal-content form {
  padding: 1.25rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ============================================
   PREVIEW MODAL - Modern Ticket Style
   ============================================ */
#preview-modal {
  display: none;
}

#preview-modal.modal.active {
  display: flex;
}

#preview-modal .modal-content {
  max-width: 340px;
  width: 100%;
  padding: 0;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
  background: #fff;
}

#preview-modal .modal-header {
  display: none;
}

#preview-modal .modal-actions {
  margin-top: 0;
  padding: 16px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  display: flex;
  gap: 10px;
}

#preview-modal .modal-actions .btn {
  flex: 1;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
}

#preview-content {
  padding: 15px;
  overflow-y: auto;
  background: #f5f5f5;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100%;
  flex: 1;
}

/* Receipt Modal (Final) */
#receipt-modal {
  display: none;
}

#receipt-modal.modal.active {
  display: flex;
}

#receipt-modal .modal-content {
  max-width: 340px;
  width: 100%;
  padding: 0;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
  background: #fff;
}

.receipt-scrollable {
  flex: 1;
  overflow-y: auto;
  background: #f5f5f5;
  padding: 15px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

#receipt-modal .receipt-actions {
  padding: 16px;
  background: #f8fafc;
  display: flex;
  gap: 10px;
  border-top: 1px solid #e2e8f0;
}

#receipt-modal .receipt-actions .btn {
  flex: 1;
  padding: 12px 16px;
  font-size: 14px;
}

/* ============================================
   RECEIPT - Modern Thermal Ticket Style
   ============================================ */
.receipt {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.4;
  padding: 1.5rem;
  background: white;
  color: #000;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}

.receipt-header {
  text-align: center;
  border-bottom: 1px dashed #333;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
}

.receipt-header .store-name {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.receipt-header .store-info {
  font-size: 11px;
  color: #555;
  line-height: 1.5;
}

.receipt-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed #333;
}

.receipt-items {
  margin-bottom: 1rem;
  width: 100%;
}

.receipt-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.25rem;
  padding: 0.25rem 0;
  gap: 0.5rem;
  font-size: 11px;
}

.receipt-item .item-name {
  flex: 3;
  min-width: 0;
  white-space: normal;
  overflow-wrap: break-word;
}

.receipt-item .item-qty {
  flex: 0.5;
  text-align: right;
  min-width: 30px;
}

.receipt-item .item-pu {
  flex: 1;
  text-align: center;
  min-width: 50px;
}

.receipt-item .item-price {
  flex: 1;
  text-align: right;
  font-weight: 700;
  white-space: nowrap;
}

/* Etiquette du type de taxe pour le receipt preview */
.item-tax-badge {
  font-size: 9px;
  background: #e0e7ff;
  color: #3730a3;
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: 4px;
  font-weight: 600;
  white-space: nowrap;
}

.receipt-divider {
  border-top: 1px dashed #333;
  margin: 0.75rem 0;
}

.receipt-totals {
  margin-bottom: 1rem;
}

.receipt-total-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.4rem;
  font-size: 11px;
}

.receipt-total-row.grand-total {
  font-size: 16px;
  font-weight: 700;
  border-top: 2px solid #333;
  border-bottom: 2px solid #333;
  padding: 0.6rem 0;
  margin-top: 0.6rem;
}

.receipt-footer {
  text-align: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed #333;
  font-size: 11px;
}

.receipt-footer .barcode {
  font-size: 18px;
  letter-spacing: 3px;
  font-weight: 700;
  margin: 1rem 0;
}

.receipt-footer .thank-you {
  font-weight: 700;
  font-size: 13px;
  margin-top: 0.5rem;
}

.receipt-actions {
  display: flex;
  gap: 0.75rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
  background: var(--background);
}

.receipt-actions .btn {
  flex: 1;
}

.qrcode-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 1rem auto;
  width: 100%;
}

.qrcode-container>div {
  background: white;
  padding: 10px;
  border-radius: 8px;
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */
@media (max-width: 768px) {
  .mobile-header {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

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

  .close-sidebar {
    display: block;
  }

  .main-content {
    margin-left: 0;
    padding: 0.75rem;
    padding-top: 70px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .stat-card {
    padding: 1rem;
  }

  /* Products Grid - Responsive pour tablette */
  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.6rem;
  }

  .product-card {
    padding: 0.6rem;
  }

  .product-image {
    width: 70px;
    height: 70px;
  }

  .product-card .name {
    font-size: 0.75rem;
  }

  .product-card .price {
    font-size: 0.85rem;
  }

  .stat-icon {
    width: 36px;
    height: 36px;
  }

  .stat-icon svg {
    width: 18px;
    height: 18px;
  }

  .stat-value {
    font-size: 1rem;
  }

  .stat-label {
    font-size: 0.65rem;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 1rem;
  }

  .page-header h2 {
    font-size: 1.125rem;
  }

  .caisse-container {
    gap: 1rem;
  }

  .caisse-products {
    min-height: auto;
  }

  .search-bar {
    padding: 0.5rem 0.75rem;
  }

  .search-bar input {
    font-size: 0.875rem;
  }

  .products-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }

  .product-card {
    padding: 0.5rem;
  }

  .product-image {
    width: 55px;
    height: 55px;
  }

  .product-card .name {
    font-size: 0.65rem;
    min-height: 1.8em;
    -webkit-line-clamp: 2;
  }

  .product-card .price {
    font-size: 0.8rem;
  }

  .barcode-display {
    font-size: 0.55rem;
    padding: 0.15rem 0.35rem;
  }

  .category-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
    gap: 0.35rem;
  }

  .category-tab {
    flex-shrink: 0;
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
  }

  .caisse-cart {
    max-height: 50vh;
  }

  .cart-header {
    padding: 0.75rem 1rem;
  }

  .cart-header h3 {
    font-size: 0.9rem;
  }

  .cart-items {
    padding: 0.5rem;
  }

  .cart-item {
    padding: 0.5rem;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
  }

  .cart-item .info {
    flex: 1;
    min-width: 0;
  }

  .cart-item .name {
    font-size: 0.75rem;
  }

  .cart-item .price {
    font-size: 0.65rem;
  }

  .cart-item .quantity-controls button {
    width: 24px;
    height: 24px;
    font-size: 0.875rem;
  }

  .cart-item .quantity-controls span {
    width: 24px;
    font-size: 0.8rem;
  }

  .cart-item .item-total {
    font-size: 0.75rem;
    min-width: 55px;
  }

  .cart-totals {
    padding: 0.75rem 1rem;
  }

  .total-row {
    font-size: 0.8rem;
  }

  .total-row.total-final {
    font-size: 1rem;
  }

  .caisse-cart>.btn {
    margin: 0 0.75rem 0.75rem;
    padding: 0.875rem 1rem;
    font-size: 0.9rem;
  }

  .caisse-cart>.btn svg {
    width: 18px;
    height: 18px;
  }

  .filters-bar {
    flex-direction: column;
    gap: 0.5rem;
  }

  .filters-bar input,
  .filters-bar select {
    width: 100%;
    min-width: 0;
    padding: 0.6rem 0.75rem;
    font-size: 0.875rem;
  }

  .table-container {
    overflow-x: auto;
  }

  .data-table {
    min-width: 550px;
  }

  .data-table th,
  .data-table td {
    padding: 0.6rem 0.5rem;
    font-size: 0.8rem;
  }

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

  .modal-content {
    max-height: 90vh;
    margin: 0.5rem;
  }

  .modal-header {
    padding: 1rem;
  }

  .modal-content form {
    padding: 1rem;
  }

  .receipt {
    padding: 1rem;
    font-size: 11px;
  }

  .receipt-modal {
    max-width: 100%;
  }

  .receipt-actions {
    flex-direction: column;
  }
  .page.active{
    margin-block-start: 16%;
  }
}

@media (max-width: 400px) {
  .products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
  }

  .product-card {
    padding: 0.4rem;
  }

  .product-image {
    width: 50px;
    height: 50px;
  }

  .product-card .name {
    font-size: 0.6rem;
  }

  .product-card .price {
    font-size: 0.75rem;
  }

  .barcode-display {
    font-size: 0.5rem;
  }

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

  .cart-item .item-total {
    min-width: 50px;
    font-size: 0.7rem;
  }

  .caisse-cart>.btn {
    padding: 0.75rem;
    font-size: 0.85rem;
  }
}

/* Product Modal Form Inputs */
#product-form input[type="text"],
#product-form input[type="number"],
#product-form select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Product name input specific fix */
#product-name {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Hide placeholder cards on mobile */
@media (max-width: 767px) {
    .hide-on-mobile {
        display: none !important;
    }
}

/* Print Styles */
@media print {
  body * {
    visibility: hidden;
  }

  .receipt,
  .receipt * {
    visibility: visible;
  }

  .receipt {
    position: absolute;
    left: 0;
    top: 0;
    width: 80mm;
    padding: 5mm;
    font-size: 10px;
  }

  .receipt-actions {
    display: none !important;
  }
}