@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;700&display=swap');

:root {
  --bg: #0f0f14;
  --surface: #1a1a24;
  --surface-hover: #22222e;
  --accent: #ff6b35;
  --accent-hover: #ff8555;
  --text: #e8e8ed;
  --text-muted: #8888a0;
  --border: #2a2a38;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Manrope', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  flex: 1;
}

.subtitle {
  width: 100%;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: -4px;
}

/* Main */
.main {
  padding: 20px 16px 100px;
}

/* Нижняя панель корзины: одна кнопка на весь экран, фиксирована при скролле */
.cart-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  width: 100%;
  padding: 14px 20px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
  background: var(--accent);
  color: #fff;
  border: none;
  border-top: 1px solid rgba(0, 0, 0, 0.15);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
  transition: background 0.2s;
}

.cart-bar:hover {
  background: var(--accent-hover);
}

.cart-bar.hidden {
  display: none;
}

.cart-bar-text {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
}

#cartBarTotal {
  font-weight: 700;
}

.menu h2,
.cart-header h2,
.checkout-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text-muted);
}

/* Categories */
.categories {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 14px;
  margin-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}

.categories::-webkit-scrollbar {
  height: 4px;
}

.categories::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.cat-btn {
  flex-shrink: 0;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.cat-btn:hover,
.cat-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Menu grid */
.menu-grid {
  display: grid;
  gap: 16px;
}

.menu-item {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  display: grid;
  grid-template-columns: 100px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  transition: border-color 0.2s;
}

.menu-item:hover {
  border-color: var(--accent);
}

.menu-item-image {
  display: block;
  width: 100px;
  min-width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.menu-item-image--placeholder {
  background: var(--border);
}

/* На мобильных фиксируем колонку с картинкой, чтобы не схлопывалась */
@media (max-width: 480px) {
  .menu-item {
    grid-template-columns: minmax(80px, 100px) 1fr auto;
  }
  .menu-item-image {
    width: 100%;
    max-width: 100px;
  }
}

.menu-item-info {
  min-width: 0;
}

.menu-item-name {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 4px;
}

.menu-item-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.menu-item-footer {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.menu-item-price {
  font-weight: 700;
  color: var(--accent);
  font-size: 1.05rem;
}

.add-btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

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

.add-btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.menu-item.out-of-stock {
  opacity: 0.75;
}

.menu-item-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Cart panel */
.cart-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  box-shadow: var(--shadow);
}

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

.close-cart {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
}

.cart-items {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}

.cart-item {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  border: 1px solid var(--border);
}

.cart-item-image {
  display: block;
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg);
}

.cart-item-image--placeholder {
  background: var(--border);
}

.cart-item-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.cart-item-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

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

.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.qty-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: var(--surface-hover);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
}

.qty-btn:hover {
  background: var(--accent);
  color: #fff;
}

.cart-item-qty span {
  min-width: 24px;
  text-align: center;
  font-weight: 600;
}

.cart-footer {
  padding: 16px 20px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.cart-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  font-size: 1.1rem;
}

.cart-total strong {
  color: var(--accent);
  font-size: 1.25rem;
}

/* Cart item action buttons (Изменить / Удалить) */
.cart-item-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.cart-action-btn {
  padding: 6px 12px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
}

.cart-action-btn:hover {
  background: var(--accent);
  color: #fff;
}

.cart-action-btn--danger {
  background: var(--accent);
  color: #fff;
}

.cart-action-btn--danger:hover {
  background: var(--accent-hover);
  color: #fff;
}

/* Buttons */
.btn {
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
}

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

.btn-block {
  display: block;
  width: 100%;
}

/* Checkout */
.checkout,
.order-done {
  padding: 20px 16px;
}

.checkout-header,
.checkout-form {
  margin-bottom: 20px;
}

.back-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  margin-bottom: 16px;
  padding: 0;
}

.pickup-info {
  background: var(--surface);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

.checkout-form label {
  display: block;
  margin-bottom: 16px;
}

.checkout-form label span {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.checkout-form input,
.checkout-form textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}

.checkout-form input::placeholder,
.checkout-form textarea::placeholder {
  color: var(--text-muted);
}

.checkout-form textarea {
  resize: vertical;
  min-height: 70px;
}

.order-summary {
  background: var(--surface);
  padding: 16px;
  border-radius: var(--radius-sm);
  margin: 20px 0;
  border: 1px solid var(--border);
}

.order-summary .row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.order-summary .total-row {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-weight: 700;
  font-size: 1.1rem;
}

.order-summary .total-row span:last-child {
  color: var(--accent);
}

/* Order done */
.order-done {
  text-align: center;
  padding: 40px 20px;
}

.done-icon {
  font-size: 4rem;
  margin-bottom: 20px;
}

.order-done h2 {
  font-size: 1.5rem;
  margin-bottom: 10px;
}

.order-done p {
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

#newOrderBtn {
  max-width: 280px;
}

/* Admin panel */
.admin-section { margin-bottom: 20px; }
.admin-hint { font-size: 0.85rem; color: var(--text-muted); margin: 8px 0 12px; }
.admin-stats { display: grid; gap: 10px; }
.admin-category-block { margin-top: 16px; }
.admin-category-block .cart-item { margin-bottom: 12px; }
.admin-item-card .cart-item-name { margin-bottom: 4px; }
.admin-image-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.admin-image-row input[type="url"] { flex: 1; min-width: 120px; }
.admin-upload-btn { max-width: 140px; font-size: 0.85rem; }

/* Utility */
[hidden] {
  display: none !important;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  max-width: 480px;
  margin: 0 auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.modal-card {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 12vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

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

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.modal-close {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
}

.modal-body {
  padding: 14px 16px;
  display: grid;
  gap: 14px;
  overflow-y: auto;
}

.modal-section {
  display: grid;
  gap: 10px;
}

.modal-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.modal-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  cursor: pointer;
}

.modal-option.active {
  border-color: var(--accent);
}

.modal-option .name {
  font-weight: 600;
}

.modal-option .price {
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
}

.modal-label span {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.modal-label select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}

.modal-footer {
  padding: 14px 16px 16px;
  border-top: 1px solid var(--border);
}
