/* ===== Design tokens ===== */
:root {
  --color-bg: #e2f4ff;
  --color-surface: #FFFFFF;
  --color-text: #1e1e1e;
  --color-text-muted: #1e1e1e;
  --color-primary: #0084d5;
  --color-primary-dark: #006bad;
  --color-accent: #0084d5;
  --color-warning-bg: #fbd8d8;
  --color-warning-text: #951a1a;
  --color-border: #d3dde8;
  --color-success: #4C7A4C;

  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 1px 3px rgba(43, 33, 26, 0.08), 0 1px 2px rgba(43, 33, 26, 0.06);

  --font-display: 'Georgia', 'Iowan Old Style', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

h1, h2 {
  font-family: var(--font-display);
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* ===== Header ===== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(16px + env(safe-area-inset-top)) 20px 16px;
  background: var(--color-primary);
  color: #fff;
}

.app-header h1 {
  font-size: 22px;
  letter-spacing: 0.3px;
}

.alert-badge {
  background: var(--color-accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}

.alert-badge.hidden {
  display: none;
}

/* ===== Layout ===== */
#view-container {
  padding: 16px;
  max-width: 560px;
  margin: 0 auto;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: fade-in 0.15s ease;
}

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

.view-heading {
  margin-bottom: 16px;
}

.view-heading h2 {
  font-size: 20px;
  color: var(--color-primary-dark);
}

.view-subtitle {
  margin: 4px 0 0;
  color: var(--color-text-muted);
  font-size: 14px;
}

/* ===== Search ===== */
.search-bar {
  margin-bottom: 16px;
}

.search-bar input,
.form input,
.form select {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
}

.search-bar input:focus,
.form input:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* ===== Cards ===== */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.product-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.product-card.low-stock {
  background: var(--color-warning-bg);
  border-color: #E8C49A;
}

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

.product-name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-brand {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.product-qty {
  display: flex;
  align-items: center;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}

.qty-value {
  font-size: 18px;
  font-weight: 700;
  min-width: 24px;
  text-align: center;
}

.qty-value.low {
  color: var(--color-accent);
}

.qty-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qty-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  font-size: 18px;
  font-weight: 700;
  color: var(--color-primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}

.qty-btn:active {
  background: var(--color-border);
}

.empty-state {
  text-align: center;
  color: var(--color-text-muted);
  padding: 0px 20px;
  font-size: 14px;
}

/* ===== Buttons ===== */
.btn {
  border: none;
  border-radius: var(--radius);
  padding: 13px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.btn-full {
  width: 100%;
  margin-bottom: 14px;
}

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

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

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-primary-dark)!important;
  border: 1px solid var(--color-border);
}

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

.scan-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.scan-actions .btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  padding: 13px 18px;
  text-align: center;
  flex-direction: initial;
  margin: 0;
}

/* ===== Form ===== */
.form {
  display: flex;
  flex-direction: column;
}

.form label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.feedback {
  font-size: 14px;
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 14px;
}

.feedback.success {
  background: #E5EFE5;
  color: var(--color-success);
}

.feedback.error {
  background: #F7E4E4;
  color: var(--color-accent);
}

.feedback.hidden {
  display: none;
}

/* ===== Product detail (vue ajustement) ===== */
.product-detail {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-top: 16px;
  text-align: center;
}

.product-detail.hidden {
  display: none;
}

.product-detail .product-name {
  font-size: 18px;
  white-space: normal;
}

.product-detail .qty-controls {
  justify-content: center;
  margin: 18px 0;
  gap: 20px;
}

.product-detail .qty-btn {
  width: 48px;
  height: 48px;
  font-size: 24px;
}

.product-detail .qty-value {
  font-size: 32px;
  min-width: 50px;
}

/* ===== Scanner overlay ===== */
.scanner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.scanner-overlay.hidden {
  display: none;
}

.scanner-box {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  width: 100%;
  max-width: 420px;
}

#scanner-viewport {
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  background: #000;
  min-height: 280px;
}

/* ===== Bottom nav ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 50;
}

.nav-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 10px 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: var(--color-text-muted);
  cursor: pointer;
}

.nav-btn.active {
  color: var(--color-primary);
  font-weight: 600;
}

.nav-icon {
  font-size: 20px;
}

/* ===== Responsive ===== */
@media (min-width: 600px) {
  #view-container {
    padding: 24px;
  }
}
