* { box-sizing: border-box; }

:root {
  --bg: #14161a;
  --panel: #1e2127;
  --panel-2: #262a32;
  --accent: #f5a623;
  --accent-dark: #c9820f;
  --text: #f2f2f2;
  --text-dim: #9aa0a6;
  --danger: #d9534f;
  --success: #3fb950;
  --border: #33373f;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 110px; /* misto pro bottom bar */
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 20px; margin: 0; }
.topbar nav a {
  color: var(--text-dim);
  text-decoration: none;
  margin-left: 16px;
  font-size: 14px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.topbar nav a:hover { color: var(--text); border-color: var(--accent); }

.loading { color: var(--text-dim); padding: 20px; }

.product-list {
  padding: 12px 16px 4px;
}

.category-section {
  margin-bottom: 6px;
}

.category-heading {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: var(--accent);
  margin: 20px 0 6px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--accent);
}
.category-section:first-child .category-heading { margin-top: 4px; }

.product-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}
.product-row.has-qty {
  background: rgba(245, 166, 35, 0.08);
  border-radius: 10px;
}
.product-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.product-name {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.product-price {
  font-size: 13px;
  color: var(--text-dim);
}
.qty-control {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}
.qty-btn {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: none;
  font-size: 22px;
  font-weight: bold;
  cursor: pointer;
  color: #1a1a1a;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.qty-btn.plus { background: var(--accent); color: #1a1a1a; border-color: var(--accent); }
.qty-btn.minus:disabled { opacity: 0.4; }
.qty-value {
  min-width: 28px;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
}

.order-summary {
  padding: 4px 16px 20px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.order-summary h2 {
  font-size: 16px;
  color: var(--text-dim);
  margin: 16px 0 8px;
  font-weight: 700;
}
.order-items-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.order-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
}
.order-item-qty {
  font-weight: 700;
  color: var(--accent);
  flex: 0 0 auto;
}
.order-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.order-item-price {
  flex: 0 0 auto;
  color: var(--text-dim);
}
.empty-order {
  list-style: none;
  color: var(--text-dim);
  padding: 6px 0;
  font-size: 14px;
}

.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 20;
}
.total {
  font-size: 20px;
  font-weight: 700;
}
.actions { display: flex; gap: 10px; }
.btn {
  border: none;
  border-radius: 12px;
  padding: 16px 20px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.btn-storno { background: var(--danger); color: white; }
.btn-done { background: var(--success); color: white; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 10px;
  z-index: 100;
  font-size: 15px;
  max-width: 90%;
  text-align: center;
}
.toast.error { border-color: var(--danger); }
.toast.hidden { display: none; }

/* --- Admin & Historie sdilene styly --- */
.container { max-width: 900px; margin: 0 auto; padding: 16px; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
}

/* Tabulky (historie) - scroll je uvnitr karty, aby nic nezasahovalo mimo box */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--text-dim); font-weight: 600; }

input, select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  min-width: 0; /* dulezite ve flex kontejneru - jinak input trha layout do stran */
}
.form-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.form-row input, .form-row select { flex: 1; min-width: 120px; }

/* Admin - produkty jako karty (misto tabulky), aby se na mobilu nic neposouvalo bokem */
.products-admin-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.product-admin-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.product-admin-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.product-admin-row input { flex: 1; width: 0; } /* width:0 + flex:1 = rovnomerne zmenseni, nikdy nepreteka */
.product-admin-status { margin-bottom: 10px; }
.product-admin-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-small {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}
.btn-small.primary { background: var(--accent); color: #1a1a1a; border-color: var(--accent); font-weight: 700; }
.btn-small.danger { background: var(--danger); color: white; border-color: var(--danger); }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
}
.badge.active { background: rgba(63,185,80,0.2); color: var(--success); }
.badge.inactive { background: rgba(217,83,79,0.2); color: var(--danger); }
.stat-box {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.stat-item { flex: 1; min-width: 140px; }
.stat-item .value { font-size: 26px; font-weight: 700; color: var(--accent); }
.stat-item .label { font-size: 13px; color: var(--text-dim); }
.order-row { cursor: pointer; }
.order-row:hover { background: var(--panel-2); }

/* --- Prihlasovaci stranka admin --- */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 200px);
}
.login-card {
  width: 100%;
  max-width: 320px;
}
.login-card #pinInput {
  width: 100%;
  font-size: 18px;
  text-align: center;
  letter-spacing: 0.2em;
  padding: 12px;
}
