/* ==========================================================================
   DESIGN SYSTEM & VARIABLES - Débrouill'Stock
   ========================================================================== */
:root {
  /* Harmonious Color Palette */
  --primary-color: #f37022;      /* Petits Débrouillards Orange */
  --primary-glow: rgba(243, 112, 34, 0.2);
  --secondary-color: #009ee0;    /* Petits Débrouillards Blue */
  --secondary-glow: rgba(0, 158, 224, 0.2);
  
  --bg-app: #f4f6fa;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-nav: #ffffff;
  
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-white: #ffffff;
  
  --border-color: rgba(226, 232, 240, 0.8);
  --border-focus: #cbd5e1;
  
  /* Status Colors */
  --status-instock-bg: #dcfce7;
  --status-instock-text: #166534;
  --status-instock-border: #bbf7d0;
  
  --status-warning-bg: #fef9c3;
  --status-warning-text: #854d0e;
  --status-warning-border: #fef08a;
  
  --status-danger-bg: #fee2e2;
  --status-danger-text: #991b1b;
  --status-danger-border: #fecaca;
  
  --status-borrow-bg: #e0f2fe;
  --status-borrow-text: #075985;
  --status-borrow-border: #bae6fd;
  
  /* UI Tokens */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;
  --font-family: 'Outfit', 'Plus Jakarta Sans', sans-serif;
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  --glass-effect: saturate(180%) blur(12px);
}

/* Dark Mode Overrides (Optional / Sleek Modern feel) */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-app: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.75);
    --bg-nav: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(51, 65, 85, 0.5);
    --border-focus: #475569;
    --glass-effect: saturate(180%) blur(20px);
  }
}

/* ==========================================================================
   RESET & GLOBAL STYLES
   ========================================================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background-color 0.4s ease;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a {
  text-decoration: none;
  color: inherit;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-focus);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==========================================================================
   NAVBAR (HEADER / MOBILE BOTTOM NAV)
   ========================================================================== */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--bg-nav);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: var(--glass-effect);
  -webkit-backdrop-filter: var(--glass-effect);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.5px;
}

.nav-logo .logo-icon {
  animation: bounce 2s infinite alternate;
}

.nav-logo span {
  color: var(--primary-color);
}
.nav-logo span span {
  color: var(--secondary-color);
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 0.5rem;
  align-items: center;
}

.nav-btn {
  background: none;
  border: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 500;
  transition: var(--transition-smooth);
}

.nav-btn i {
  width: 20px;
  height: 20px;
}

.nav-btn:hover {
  color: var(--text-main);
  background-color: rgba(0, 0, 0, 0.04);
}

.nav-btn.active {
  color: var(--primary-color);
  background-color: var(--primary-glow);
  box-shadow: inset 0 0 0 1px rgba(243, 112, 34, 0.15);
}

/* Profile summary card on Navbar */
.nav-profile-summary {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.4rem 1rem 0.4rem 0.5rem;
  border-radius: 40px;
  background-color: var(--bg-app);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.nav-profile-summary:hover {
  border-color: var(--primary-color);
  transform: translateY(-2px);
}

.avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  box-shadow: 0 4px 10px var(--primary-glow);
}

.profile-details {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.profile-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.profile-name-val {
  font-size: 0.85rem;
  font-weight: 600;
}

/* ==========================================================================
   APP LAYOUT & WORKSPACES
   ========================================================================== */
.main-content {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
}

.tab-panel {
  display: none;
  animation: fadeIn 0.4s ease forwards;
}

.tab-panel.active {
  display: block;
}

/* ==========================================================================
   TYPOGRAPHY & BUTTONS
   ========================================================================== */
h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 0.2rem;
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.8rem;
}

p {
  color: var(--text-muted);
  line-height: 1.5;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition-smooth);
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
  box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-secondary {
  background-color: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--border-color);
  transform: translateY(-2px);
}

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

.btn-danger:hover {
  background-color: #dc2626;
  transform: translateY(-2px);
}

/* ==========================================================================
   PANEL HEADER
   ========================================================================== */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  gap: 2rem;
}

.header-stats {
  display: flex;
  gap: 1rem;
}

.stat-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.8rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 100px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
}

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

.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--secondary-color);
}

.stat-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.stat-card.alert .stat-value { color: var(--primary-color); }
.stat-card.danger .stat-value { color: #ef4444; }

/* ==========================================================================
   FILTER BAR
   ========================================================================== */
.filter-bar {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
  backdrop-filter: var(--glass-effect);
  -webkit-backdrop-filter: var(--glass-effect);
}

.search-box {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 20px;
  height: 20px;
}

.search-box input {
  width: 100%;
  padding: 0.8rem 1rem 0.8rem 2.8rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-app);
  outline: none;
  transition: var(--transition-smooth);
}

.search-box input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.category-filters {
  display: flex;
  overflow-x: auto;
  gap: 0.4rem;
  padding-bottom: 0.3rem;
  scrollbar-width: none; /* Firefox */
}

.category-filters::-webkit-scrollbar {
  display: none; /* Safari & Chrome */
}

.cat-btn {
  background-color: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 30px;
  padding: 0.5rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-smooth);
}

.cat-btn:hover {
  background-color: var(--border-color);
}

.cat-btn.active {
  background-color: var(--text-main);
  color: var(--text-white);
  border-color: var(--text-main);
}

.filter-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.filter-actions select {
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-app);
  outline: none;
  cursor: pointer;
  font-weight: 500;
}

/* ==========================================================================
   ITEMS GRID & CARD DESIGN (PREMIUM GLOSSY LOOK)
   ========================================================================== */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.item-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
  cursor: pointer;
}

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

/* Background colored glow for quick identification */
.item-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  background-color: var(--secondary-color);
}

.item-card.cat-Régie::before { background-color: #a855f7; }
.item-card.cat-Bureau::before { background-color: #3b82f6; }
.item-card.cat-Verrerie::before { background-color: #06b6d4; }
.item-card.cat-Jeux::before { background-color: #10b981; }
.item-card.cat-Outillage::before { background-color: #f59e0b; }
.item-card.cat-Secours::before { background-color: #ef4444; }
.item-card.cat-Numérique::before { background-color: #6366f1; }
.item-card.cat-Bibliothèque::before { background-color: #ec4899; }

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.8rem;
  gap: 0.5rem;
}

.item-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
}

.badge-regie { background-color: rgba(168, 85, 247, 0.15); color: #7e22ce; }
.badge-bureau { background-color: rgba(59, 130, 246, 0.15); color: #1d4ed8; }
.badge-verrerie { background-color: rgba(6, 182, 212, 0.15); color: #0891b2; }
.badge-jeux { background-color: rgba(16, 185, 129, 0.15); color: #047857; }
.badge-outillage { background-color: rgba(245, 158, 11, 0.15); color: #b45309; }
.badge-secours { background-color: rgba(239, 68, 68, 0.15); color: #b91c1c; }
.badge-numerique { background-color: rgba(99, 102, 241, 0.15); color: #4338ca; }
.badge-bibliotheque { background-color: rgba(236, 72, 153, 0.15); color: #be185d; }

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 8px;
  border: 1px solid transparent;
}

.status-instock {
  background-color: var(--status-instock-bg);
  color: var(--status-instock-text);
  border-color: var(--status-instock-border);
}
.status-warning {
  background-color: var(--status-warning-bg);
  color: var(--status-warning-text);
  border-color: var(--status-warning-border);
}
.status-danger {
  background-color: var(--status-danger-bg);
  color: var(--status-danger-text);
  border-color: var(--status-danger-border);
}
.status-borrow {
  background-color: var(--status-borrow-bg);
  color: var(--status-borrow-text);
  border-color: var(--status-borrow-border);
}

.item-name {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

.item-details-line {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

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

.qty-counter {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.qty-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background-color: var(--bg-app);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
  transition: var(--transition-smooth);
}

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

.qty-value {
  font-weight: 700;
  font-size: 1.1rem;
  min-width: 20px;
  text-align: center;
}

.card-actions {
  display: flex;
  gap: 0.4rem;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition-smooth);
}

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

/* ==========================================================================
   SCANNER PANELS
   ========================================================================== */
.scanner-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  max-width: 1000px;
  margin: 0 auto;
  align-items: flex-start;
}

.scanner-box {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.scanner-title-box h2 {
  margin-bottom: 0.3rem;
}

.scan-area {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background-color: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.scan-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scan-laser {
  position: absolute;
  width: 100%;
  height: 3px;
  background-color: #ef4444;
  box-shadow: 0 0 12px 3px #ef4444;
  top: 0;
  animation: scanLaser 3s ease-in-out infinite alternate;
}

.scan-overlay .corner {
  position: absolute;
  width: 30px;
  height: 30px;
  border: 4px solid var(--primary-color);
}

.scan-overlay .top-left { top: 20px; left: 20px; border-right: none; border-bottom: none; }
.scan-overlay .top-right { top: 20px; right: 20px; border-left: none; border-bottom: none; }
.scan-overlay .bottom-left { bottom: 20px; left: 20px; border-right: none; border-top: none; }
.scan-overlay .bottom-right { bottom: 20px; right: 20px; border-left: none; border-top: none; }

.camera-simulation {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
}

.spinning-icon {
  animation: spin 3s linear infinite;
  width: 36px;
  height: 36px;
}

.scanner-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.input-group {
  display: flex;
  gap: 0.5rem;
}

.select-field {
  flex: 1;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-app);
  outline: none;
  font-weight: 500;
}

.scan-result-card {
  background-color: var(--bg-card);
  border: 2px solid var(--primary-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.scan-result-card.hidden {
  display: none;
}

.instant-qty-control {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  background-color: var(--bg-app);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.instant-qty-control .qty-counter {
  gap: 1.5rem;
}

.instant-qty-control .qty-btn {
  width: 48px;
  height: 48px;
  font-size: 1.5rem;
}

.instant-qty-control .qty-value {
  font-size: 2rem;
}

/* ==========================================================================
   GENERATOR & PRINT GRID
   ========================================================================== */
.generator-config {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.config-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.selection-count {
  font-weight: 600;
  color: var(--primary-color);
}

.generator-workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 2rem;
  align-items: flex-start;
}

.generator-checklist {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-height: 600px;
  display: flex;
  flex-direction: column;
}

.checklist-items {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.5rem;
  padding-right: 0.3rem;
}

.chk-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.chk-label:hover {
  background-color: var(--bg-app);
}

.chk-label input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary-color);
}

.generator-preview-pane {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Dynamic QR sheet styling */
.qr-print-sheet {
  display: grid;
  gap: 1rem;
  background-color: white;
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-focus);
}

.qr-card-item {
  border: 1px solid #cbd5e1;
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background-color: white;
  border-radius: 6px;
  color: black;
}

.qr-card-item img {
  width: 100%;
  max-width: 100px;
  aspect-ratio: 1;
  margin-bottom: 0.4rem;
}

.qr-card-item .qr-item-name {
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.2;
}

.qr-card-item .qr-item-cat {
  font-size: 0.55rem;
  text-transform: uppercase;
  color: #64748b;
  margin-top: 0.2rem;
}

/* Configurable Grid Columns */
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid-cols-6 { grid-template-columns: repeat(6, 1fr); }
.grid-cols-8 { grid-template-columns: repeat(8, 1fr); }

/* ==========================================================================
   HISTORY & LOGS
   ========================================================================== */
.history-workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

.history-section {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.8rem;
  box-shadow: var(--shadow-sm);
}

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

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

.data-table th {
  padding: 0.8rem 1rem;
  border-bottom: 2px solid var(--border-color);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-muted);
}

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

.logs-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.log-entry {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 0.8rem;
  background-color: var(--bg-app);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--secondary-color);
}

.log-entry.log-add { border-left-color: var(--primary-color); }
.log-entry.log-danger { border-left-color: #ef4444; }

.log-icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-color);
  flex-shrink: 0;
}

.log-body {
  flex: 1;
}

.log-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  margin-top: 0.2rem;
}

/* ==========================================================================
   SYNC & CONFIG LABELS
   ========================================================================== */
.sync-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.sync-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.8rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.sync-card.full-width {
  grid-column: span 2;
}

.guide-list {
  padding-left: 1.2rem;
  line-height: 1.6;
}

.guide-list li {
  margin-bottom: 0.6rem;
}

.sheet-url-setting {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.input-field {
  width: 100%;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-app);
  outline: none;
  transition: var(--transition-smooth);
}

.input-field:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.settings-actions {
  display: flex;
  gap: 0.6rem;
}

.code-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.code-block {
  background-color: #1e293b;
  color: #f8fafc;
  padding: 1rem;
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.8rem;
  line-height: 1.4;
  max-height: 300px;
}

.csv-actions {
  display: flex;
  gap: 1rem;
}

.hidden-file-input {
  display: none;
}

.btn-file-label {
  display: inline-flex;
  cursor: pointer;
}

/* ==========================================================================
   MODAL WINDOW STYLING
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.3s ease;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

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

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

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.modal-desc {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

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

.form-group label {
  font-weight: 600;
  font-size: 0.9rem;
}

.modal-footer {
  padding: 1.2rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.8rem;
}

/* ==========================================================================
   TOASTS & ALERTS
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  z-index: 300;
}

.toast {
  background-color: var(--text-main);
  color: var(--bg-app);
  padding: 0.8rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-weight: 600;
  animation: slideInLeft 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes popIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes slideInLeft {
  from { transform: translateX(120%); }
  to { transform: translateX(0); }
}

@keyframes scanLaser {
  0% { top: 5%; }
  100% { top: 92%; }
}

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

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-4px); }
}

/* ==========================================================================
   RESPONSIVENESS (MOBILE FRIENDLY)
   ========================================================================== */
@media (max-width: 768px) {
  body {
    padding-bottom: 70px; /* Make space for mobile bottom nav bar */
  }
  
  .navbar {
    position: fixed;
    bottom: 0;
    top: auto;
    left: 0;
    width: 100%;
    border-top: 1px solid var(--border-color);
    border-bottom: none;
    padding: 0.5rem 1rem;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .nav-logo, .nav-profile-summary {
    display: none; /* Hide top headers in mobile bottom navigation */
  }
  
  .nav-links {
    width: 100%;
    justify-content: space-around;
  }
  
  .nav-btn {
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.5rem;
    font-size: 0.7rem;
  }
  
  .nav-btn span {
    display: block;
  }
  
  .main-content {
    padding: 1.2rem;
  }
  
  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
  }
  
  .header-stats {
    width: 100%;
    justify-content: space-between;
  }
  
  .stat-card {
    flex: 1;
    min-width: 0;
    padding: 0.5rem;
  }
  
  .scanner-container, .generator-workspace, .sync-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .sync-card.full-width {
    grid-column: span 1;
  }
}

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

/* ==========================================================================
   LOGIN SCREEN OVERLAY
   ========================================================================== */
.login-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--bg-app);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 1.5rem;
  background-image: radial-gradient(circle at 10% 20%, rgba(243, 112, 34, 0.08) 0%, transparent 40%),
                    radial-gradient(circle at 90% 80%, rgba(0, 158, 224, 0.08) 0%, transparent 40%);
}

.login-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: var(--glass-effect);
  -webkit-backdrop-filter: var(--glass-effect);
  text-align: center;
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.login-logo h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0;
}

.login-logo h1 span {
  color: var(--primary-color);
}
.login-logo h1 span span {
  color: var(--secondary-color);
}

.login-subtitle {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 2.5rem;
}

/* ==========================================================================
   PRINT STYLES (EXCLUSIVELY FOR QR CODE LABELS WITH LEGENDS)
   ========================================================================== */
@media print {
  /* Hide all app layers */
  body * {
    visibility: hidden;
  }
  
  /* Make the modal backdrop and modal card print-visible */
  #item-modal, #item-modal *, #item-modal-body, #item-modal-body * {
    visibility: visible;
  }
  
  #item-modal {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: auto;
    background: white;
    backdrop-filter: none;
    box-shadow: none;
  }
  
  #item-modal .modal-card {
    border: none;
    box-shadow: none;
    background: white;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
  }
  
  #item-modal .modal-header, 
  #item-modal .btn, 
  #item-modal p:not(.print-legend) {
    display: none !important; /* Hide close buttons and instructions */
  }
  
  /* Frame the printable label */
  .printable-qr-label {
    visibility: visible !important;
    border: 2px dashed #000;
    padding: 2cm;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    width: 10cm;
    height: 10cm;
    margin: 2cm auto;
    background: white !important;
    box-shadow: none !important;
  }
  
  .printable-qr-label img {
    visibility: visible !important;
    width: 5cm !important;
    height: 5cm !important;
    margin-bottom: 1cm !important;
  }
  
  .printable-qr-label .print-legend {
    visibility: visible !important;
    font-size: 1.4rem !important;
    font-weight: 800 !important;
    color: black !important;
    margin-top: 0.5cm !important;
    display: block !important;
  }
  
  .printable-qr-label .print-sublegend {
    visibility: visible !important;
    font-size: 0.9rem !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    color: #475569 !important;
    margin-top: 0.2cm !important;
    display: block !important;
  }
}

/* ==========================================================================
   QR CAMERA READER
   ========================================================================== */
#qr-reader {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid var(--border-color);
}
/* Masquer les boutons natifs html5-qrcode qu'on ne veut pas */
#qr-reader__dashboard_section_csr button,
#qr-reader__status_span,
#qr-reader__camera_selection {
  display: none !important;
}
#qr-reader img {
  display: none !important;
}
#qr-reader video {
  width: 100% !important;
  border-radius: var(--radius-md);
}

/* ==========================================================================
   BOUTON SETTINGS DANS LE PROFIL
   ========================================================================== */
.btn-settings {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  transition: var(--transition-smooth);
  padding: 0;
  margin-left: 0.2rem;
}
.btn-settings:hover {
  color: var(--primary-color);
  background-color: var(--primary-glow);
}
.btn-settings i {
  width: 16px;
  height: 16px;
}

/* ==========================================================================
   QR LABEL CARD (modal + impression)
   ========================================================================== */
.qr-label-card {
  border: 3px solid var(--primary-color);
  border-radius: 14px;
  padding: 1.2rem 1.4rem 1rem;
  text-align: center;
  background: #ffffff;
  width: 240px;
  box-shadow: var(--shadow-md);
}
.qr-product-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: #1a1a1a;
  margin-top: 0.7rem;
  line-height: 1.2;
}
.qr-product-cat {
  font-size: 0.72rem;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.35rem;
}

