/* frontend/css/components.css */
/* Базовые компоненты «Ателье» (Вариант B) */

/* ── КНОПКИ (BUTTONS) ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 16px;
  height: var(--touch-button-h);
  border-radius: var(--radius-pill);
  border: var(--border-width) solid transparent;
  padding: 0 24px;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
  transition: transform 0.08s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 12px rgba(15, 59, 46, 0.08);
}

.btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

.btn:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Главная кнопка (Малиновая) */
.btn-primary {
  background-color: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
}

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

/* Кнопка на всю ширину (закрепленная внизу) */
.btn-primary-pinned {
  height: var(--touch-primary-btn-h);
  font-size: 18px;
  width: 100%;
}

/* Вторичная кнопка */
.btn-secondary {
  background-color: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-color);
}

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

/* Опасная / Пересчет кнопка (Янтарная) */
.btn-warning {
  background-color: var(--color-warning);
  color: #ffffff;
  border-color: var(--color-warning);
}

.btn-danger {
  background-color: var(--color-error);
  color: #ffffff;
  border-color: var(--color-error);
}

/* Кнопки плюс/минус */
.btn-pm {
  width: var(--touch-pm-btn-h);
  height: var(--touch-pm-btn-h);
  border-radius: 50%;
  font-family: var(--font-headings);
  font-size: 26px;
  font-weight: 700;
  background-color: var(--bg-card);
  color: var(--text-primary);
  border: var(--border-width) solid var(--border-color);
}

/* Быстрые кнопки количества (10, 50, 100, 500, 1000) */
.btn-quick-qty {
  height: 48px;
  padding: 0 16px;
  font-size: 15px;
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-radius: var(--radius-pill);
  border: var(--border-width) solid var(--border-color);
}

.btn-quick-qty:hover {
  background-color: var(--scan-highlight);
  border-color: var(--accent-primary);
}

/* ── ПЛИТКА ЯЧЕЙКИ (CELL TILE) ── */
.cell-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 500px) {
  .cell-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 800px) {
  .cell-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.cell-tile {
  min-height: var(--touch-tile-h);
  border-radius: var(--radius-tile);
  border: var(--border-width) solid var(--cell-free-border);
  background-color: var(--cell-free-bg);
  color: var(--cell-free-text);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  text-decoration: none;
  transition: transform 0.08s ease, box-shadow 0.15s ease;
}

.cell-tile:active {
  transform: translateY(2px);
  box-shadow: none;
}

.cell-tile-code {
  font-family: var(--font-headings);
  font-size: 24px;
  font-weight: 700;
}

.cell-tile-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  margin-top: 8px;
}

.cell-tile-status {
  font-weight: 800;
  text-transform: capitalize;
}

.cell-tile-qty {
  font-family: var(--font-headings);
  font-weight: 700;
  font-size: 15px;
}

/* Статусы ячейки */
.cell-tile.status-free, .cell-chip.status-free {
  background-color: var(--cell-free-bg);
  border-color: var(--cell-free-border);
  color: var(--cell-free-text);
}

.cell-tile.status-in_progress, .cell-chip.status-in_progress {
  background-color: var(--cell-progress-bg);
  border-color: var(--cell-progress-border);
  color: var(--cell-progress-text);
}

.cell-tile.status-closed, .cell-chip.status-closed {
  background-color: var(--cell-closed-bg);
  border-color: var(--cell-closed-border);
  color: var(--cell-closed-text);
}

.cell-tile.status-accepted, .cell-chip.status-accepted {
  background-color: var(--cell-accepted-bg);
  border-color: var(--cell-accepted-border);
  color: var(--cell-accepted-text);
}

.cell-tile.status-recount, .cell-chip.status-recount {
  background-color: var(--cell-recount-bg);
  border-color: var(--cell-recount-border);
  color: var(--cell-recount-text);
}

/* ── ПОЛОСА ПРОГРЕССА ── */
.progress-bar-container {
  width: 100%;
  height: 12px;
  background-color: var(--bg-surface);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin: 10px 0;
}

.progress-bar-fill {
  height: 100%;
  background-color: var(--accent-primary);
  border-radius: var(--radius-pill);
  transition: width 0.3s ease;
}

/* ── БАННЕР ПРЕДУПРЕЖДЕНИЯ (ПЕРЕСЧЁТ) ── */
.banner-warning {
  background-color: var(--color-warning);
  color: #ffffff;
  padding: 16px 20px;
  border-radius: var(--radius-card);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(180, 83, 9, 0.25);
}

/* ── СЕТЕВОЙ ЧИП (ONLINE/OFFLINE) ── */
.chip-network {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 800;
}

.chip-network.online {
  background-color: var(--cell-accepted-bg);
  color: var(--cell-accepted-text);
  border: 1px solid var(--cell-accepted-border);
}

.chip-network.offline {
  background-color: var(--cell-recount-bg);
  color: var(--cell-recount-text);
  border: 1px solid var(--cell-recount-border);
}

/* ── КАРТОЧКА ПОСЛЕДНЕГО ТОВАРА ── */
.last-product-card {
  background-color: var(--bg-card);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
  transition: background-color 0.35s ease;
}

.last-product-card.flash-highlight {
  background-color: var(--scan-highlight) !important;
}

.last-product-card.flash-unknown {
  background-color: #fde2e2 !important;
}

.product-name {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.product-meta {
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  gap: 12px;
}

/* ── ЦЕНТРАЛЬНЫЙ СЧЁТЧИК (108 PX) ── */
.center-counter-box {
  text-align: center;
  margin: 14px 0 18px;
}

.counter-number {
  font-family: var(--font-headings);
  font-size: 108px;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
  transition: transform 0.15s ease;
}

.counter-number.bump {
  transform: scale(1.08);
}

.counter-sub {
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 800;
  margin-top: 4px;
}

/* ── ВИДОИСКАТЕЛЬ КАМЕРЫ ── */
.scanner-viewfinder {
  position: relative;
  width: 100%;
  height: 160px;
  background-color: #10141c;
  border-radius: var(--radius-card);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.viewfinder-laser {
  position: absolute;
  width: 80%;
  height: 2px;
  background-color: #ff8fbf;
  box-shadow: 0 0 8px #ff8fbf;
  animation: laserScan 2s infinite ease-in-out alternate;
}

@keyframes laserScan {
  0% { transform: translateY(-50px); }
  100% { transform: translateY(50px); }
}

.viewfinder-hint {
  position: absolute;
  bottom: 10px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  font-weight: 600;
}

/* ── ВЫЕЗЖАЮЩИЕ СНИЗУ ОКНА (SHEETS) ── */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 59, 46, 0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  display: flex;
  align-items: flex-end;
}

.sheet-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  width: 100%;
  max-height: 85vh;
  background-color: var(--bg-card);
  border-top-left-radius: var(--radius-app);
  border-top-right-radius: var(--radius-app);
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 20px));
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.2);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
}

.sheet-overlay.active .bottom-sheet {
  transform: translateY(0);
}

.sheet-handle {
  width: 44px;
  height: 5px;
  background-color: var(--border-color);
  border-radius: var(--radius-pill);
  margin: 0 auto 18px;
}

/* ── ПОЛЯ ВВОДА (INPUTS) ── */
.input-pill {
  width: 100%;
  height: 60px;
  border-radius: var(--radius-pill);
  border: var(--border-width) solid var(--border-color);
  background-color: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 700;
  padding: 0 24px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-pill:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--scan-highlight);
}

/* ── TOAST УВЕДОМЛЕНИЯ ── */
#toast-container {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom, 20px));
  left: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 999;
  pointer-events: none;
}

@media (min-width: 768px) {
  #toast-container {
    top: 24px;
    bottom: auto;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
  }
}

.toast {
  background-color: #101c16;
  color: #ffffff;
  padding: 14px 20px;
  border-radius: var(--radius-pill);
  font-size: 15px;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  animation: toastIn 0.25s ease;
}

.toast.error {
  background-color: var(--color-error);
}

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

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── ФИКСИРОВАННЫЙ НИЖНИЙ БАР ДЕЙСТВИЯ ── */
.pinned-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--bg-app);
  border-top: var(--border-width) solid var(--border-color);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 16px));
  display: flex;
  gap: 10px;
  z-index: 50;
}
