:root {
  --color-primary: #1f2937;
  --color-primary-light: #374151;
  --color-accent: #2563eb;
  --color-success: #16a34a;
  --color-error: #dc2626;
  --color-muted: #6b7280;
  --color-bg: #f3f4f6;
  --color-surface: #ffffff;
  --color-border: #d1d5db;
  --radius: 8px;
  --touch-min: 44px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: #111827;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--color-accent); }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

/* Barre de navigation */
.topbar {
  background: var(--color-primary);
  color: #fff;
}
.main-nav {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 16px;
}
.main-nav a, .main-nav .link-button {
  color: #e5e7eb;
  text-decoration: none;
  padding: 10px 14px;
  border-radius: var(--radius);
  min-height: var(--touch-min);
  display: inline-flex;
  align-items: center;
}
.main-nav a.brand {
  font-weight: 700;
  color: #fff;
}
.main-nav a:hover, .main-nav .link-button:hover {
  background: var(--color-primary-light);
  cursor: pointer;
}
.nav-spacer { flex: 1; }
.nav-user { color: #9ca3af; padding: 0 8px; font-size: 0.9rem; }
.link-button {
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
}

/* Formulaires */
form label {
  display: block;
  margin-top: 12px;
  margin-bottom: 4px;
  font-weight: 600;
}
form input, form select, form textarea {
  width: 100%;
  min-height: var(--touch-min);
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--color-surface);
}
form input:focus, form select:focus, form textarea:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}
.form-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  max-width: 480px;
}
.inline-form { display: inline-block; margin: 0; }

/* Boutons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-min);
  padding: 10px 18px;
  margin-top: 12px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--color-border);
  color: #111827;
}
.btn:hover { filter: brightness(0.95); cursor: pointer; }
.btn-primary { background: var(--color-accent); color: #fff; }
.btn-block { width: 100%; }
.btn-small { min-height: 36px; padding: 6px 12px; font-size: 0.9rem; margin-top: 0; }

/* Alertes */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin: 12px 0;
  font-weight: 500;
}
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-muted { background: #e5e7eb; color: #4b5563; }
.badge-error { background: #fee2e2; color: #991b1b; }

/* Tableaux */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border-radius: var(--radius);
  overflow: hidden;
}
.data-table th, .data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}
.data-table th { background: #eef0f3; font-weight: 700; }

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

/* Recherche et alias */
.search-form {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.search-form input[type="search"] {
  flex: 1;
  min-width: 220px;
  margin-top: 0;
}
.alias-list {
  list-style: none;
  padding: 0;
  margin: 8px 0;
}
.alias-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--color-border);
}

/* Ligne d'édition secondaire des variantes produit */
.variant-edit-row td {
  background: #f9fafb;
  padding: 6px 12px 14px;
}
.variant-edit-row input, .variant-edit-row label {
  display: inline-block;
  width: auto;
  margin: 0 6px 0 0;
  min-height: 36px;
  vertical-align: middle;
}

/* Page de connexion */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-box {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

/* Récapitulatif Messenger */
.summary-textarea {
  width: 100%;
  font-family: monospace;
  font-size: 0.95rem;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}
.messenger-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

/* Espace personnel cliente */
.portal-body {
  display: flex;
  justify-content: center;
  padding: 32px 16px 64px;
}
.portal-box {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 640px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}
.portal-gdpr { font-size: 0.85rem; margin-top: 24px; }

/* Assistant d'installation */
.install-body {
  display: flex;
  justify-content: center;
  padding: 40px 16px;
}
.install-box {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 640px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}
.install-brand { margin-top: 0; }
.install-log {
  background: #111827;
  color: #d1fae5;
  padding: 12px 16px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.9rem;
  white-space: pre-wrap;
}

@media (max-width: 640px) {
  .main-nav { padding: 8px; }
  .container { padding: 16px 12px 48px; }
}

/* Écran de caisse — interface dédiée plein écran (voir lives/_console_layout.php) */
html:has(body.pos-body-full), body.pos-body-full {
  height: 100%;
  margin: 0;
  background: #12101c;
}

.offline-banner {
  background: #991b1b;
  color: #fff;
  padding: 10px 16px;
  font-weight: 600;
  text-align: center;
}

.pos {
  --pos-bg: #eef0f6;
  --pos-panel: #ffffff;
  --pos-border: #e6e8f0;
  --pos-text-soft: #6b7280;
  --pos-accent: #5b52f6;
  --pos-accent-dark: #4338ca;
  --pos-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --pos-shadow-md: 0 8px 24px rgba(15, 23, 42, 0.10);
  --pos-radius: 16px;
  --pos-radius-sm: 10px;

  display: flex;
  flex-direction: column;
  height: 100vh;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #1e1b2e;
}

.pos-topbar {
  flex-shrink: 0;
  background: linear-gradient(135deg, #1f1b3a 0%, #2d2560 60%, #382a72 100%);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
  z-index: 10;
}
.pos-topbar-live { white-space: nowrap; font-size: 1.05rem; letter-spacing: 0.01em; }
.pos-topbar-date {
  color: #c7c2f0;
  margin-left: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(255,255,255,0.08);
  padding: 3px 9px;
  border-radius: 999px;
}
.pos-topbar-customer {
  flex: 1;
  text-align: center;
  font-weight: 700;
  font-size: 1.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pos-exit {
  margin-left: auto;
  flex-shrink: 0;
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.18);
}
.pos-exit:hover { background: rgba(255,255,255,0.2); }

.pos-body {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr 360px;
  gap: 14px;
  background: var(--pos-bg);
  padding: 14px;
  overflow: hidden;
}
@media (max-width: 900px) {
  html:has(body.pos-body-full), body.pos-body-full { height: auto; overflow: visible; }
  .pos { height: auto; }
  .pos-body { grid-template-columns: 1fr; overflow: visible; }
  .pos-pane { max-height: 60vh; }
}

.pos-pane {
  background: var(--pos-panel);
  border-radius: var(--pos-radius);
  box-shadow: var(--pos-shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.pos-pane-header {
  flex-shrink: 0;
  padding: 14px;
  border-bottom: 1px solid var(--pos-border);
  display: flex;
  gap: 8px;
}
.pos-pane-header input[type="search"] {
  flex: 1;
  margin: 0;
  border-radius: 999px;
  border: 1px solid var(--pos-border);
  background: #f7f7fb;
  padding-left: 16px;
}
.pos-pane-header input[type="search"]:focus {
  background: #fff;
  outline: 2px solid var(--pos-accent);
  outline-offset: 1px;
}
.pos-pane-header .btn-small {
  border-radius: 999px;
  background: var(--pos-accent);
  color: #fff;
  font-weight: 700;
  border: none;
}
.pos-pane-header .btn-small:hover { background: var(--pos-accent-dark); }

.pos-list, .pos-grid {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.console-empty { padding: 8px 0; color: var(--pos-text-soft); }

.pos-customer-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
  text-align: left;
  background: #f7f7fb;
  border: 1px solid transparent;
  border-radius: var(--pos-radius-sm);
  padding: 10px 12px 10px 16px;
  min-height: var(--touch-min);
  cursor: pointer;
  font: inherit;
  transition: background 0.12s ease, transform 0.05s ease;
}
.pos-customer-item::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 2px;
  background: transparent;
}
.pos-customer-item:hover { background: #edecfe; }
.pos-customer-item:active { transform: scale(0.99); }
.pos-customer-item.selected { background: #e8e5ff; }
.pos-customer-item.selected::before { background: var(--pos-accent); }
.pos-customer-item-title { font-weight: 700; font-size: 0.95rem; }
.pos-customer-item-sub { color: var(--pos-text-soft); font-size: 0.85rem; }

.product-card {
  background: #fbfbfd;
  border: 1px solid var(--pos-border);
  border-radius: var(--pos-radius-sm);
  padding: 10px 12px;
  box-shadow: var(--pos-shadow-sm);
}
.product-card-title { font-size: 0.94rem; margin-bottom: 8px; }
.product-card-title strong { color: var(--pos-accent-dark); }
.product-card-variants { display: flex; flex-wrap: wrap; gap: 6px; }

.variant-btn {
  position: relative;
  min-height: var(--touch-min);
  padding: 7px 14px 7px 22px;
  border-radius: 999px;
  border: 1px solid #d9d5ff;
  background: #f1efff;
  color: #372f8f;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.05s ease;
}
.variant-btn::before {
  content: "";
  position: absolute;
  left: 10px; top: 50%;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--color-success);
  transform: translateY(-50%);
}
.variant-btn.variant-low::before { background: #d97706; }
.variant-btn:hover { background: #e3defe; }
.variant-btn:active { transform: scale(0.97); }
.variant-btn-disabled, .variant-btn:disabled {
  background: #f3f4f6;
  border-color: var(--pos-border);
  color: var(--pos-text-soft);
  cursor: not-allowed;
}
.variant-btn-disabled::before, .variant-btn:disabled::before { background: var(--color-error); }
.variant-stock { font-weight: 400; font-size: 0.8rem; opacity: 0.7; }

.pos-cart-header {
  flex-shrink: 0;
  padding: 16px;
  background: linear-gradient(135deg, #201c3d, #372f8f);
  color: #fff;
}
.pos-cart-total { font-weight: 800; font-size: 1.9rem; letter-spacing: -0.01em; }

.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: #fbfbfd;
  border: 1px solid var(--pos-border);
  border-radius: var(--pos-radius-sm);
  padding: 10px 12px;
}
.cart-item-controls { display: flex; align-items: center; gap: 6px; }
.cart-item-controls .btn-small {
  border-radius: 999px;
  min-width: 32px;
  padding: 6px 10px;
}
.cart-qty { min-width: 20px; text-align: center; font-weight: 700; }
.cart-item-price { font-weight: 700; min-width: 70px; text-align: right; color: var(--pos-accent-dark); }

/* Modale de création rapide */
.pos-modal {
  position: fixed;
  inset: 0;
  background: rgba(17, 16, 33, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}
.pos-modal[hidden] { display: none; }
.pos-modal-box {
  background: var(--color-surface);
  border-radius: var(--pos-radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  padding: 22px;
  width: 100%;
  max-width: 380px;
}
.pos-modal-box h3 { margin-top: 0; }
.pos-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* Aide / raccourcis, discrets */
.pos-help-btn {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #372f8f;
  color: #fff;
  border: none;
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  z-index: 1500;
  box-shadow: 0 4px 14px rgba(55, 47, 143, 0.5);
}
.pos-help-btn:hover { background: var(--pos-accent-dark, #4338ca); }
.pos-help-popover {
  position: fixed;
  bottom: 74px;
  left: 20px;
  background: #201c3d;
  color: #e5e7eb;
  padding: 14px 18px;
  border-radius: var(--pos-radius-sm, 10px);
  font-size: 0.85rem;
  z-index: 1500;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}
.pos-help-popover p { margin: 5px 0; }
.pos-help-popover kbd {
  background: rgba(255,255,255,0.12);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: monospace;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: 999px;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  z-index: 2500;
}
.toast-success { background: var(--color-success); }
.toast-error { background: var(--color-error); }
