/* --- Base Variables & Reset --- */
:root {
  --bg-primary: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface-active: #334155;
  --accent-blue: #2563eb;
  --accent-blue-hover: #1d4ed8;
  --accent-red: #dc2626;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --status-online: #10b981;
  --status-offline: #f59e0b;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  /* Prevent pull-to-refresh page reloads */
  overscroll-behavior-y: contain;
  touch-action: manipulation;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  padding-bottom: calc(80px + var(--safe-area-bottom));
}

/* --- Header --- */
.app-header {
  background-color: var(--bg-surface);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 20px;
  background-color: rgba(255, 255, 255, 0.05);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--status-online);
}

.status-badge.offline .status-dot {
  background-color: var(--status-offline);
}

/* --- Category Navigation --- */
.category-nav {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  white-space: nowrap;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  -webkit-overflow-scrolling: touch;
}

.category-nav::-webkit-scrollbar {
  display: none;
}

.cat-btn {
  background-color: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cat-btn.active {
  background-color: var(--accent-blue);
  color: #ffffff;
  border-color: var(--accent-blue);
}

/* --- Main Drink Grid --- */
.drink-container {
  flex: 1;
  padding: 16px;
}

.drink-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}

.drink-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  position: relative;
  touch-action: manipulation;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.1s ease, border-color 0.2s ease;
}

.drink-card:active {
  transform: scale(0.96);
  background-color: var(--bg-surface-active);
}

.drink-card.selected {
  border-color: var(--accent-blue);
}

.drink-card img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  margin-bottom: 8px;
  border-radius: 8px;
  pointer-events: none;
}

.drink-card .placeholder-img {
  width: 64px;
  height: 64px;
  background-color: var(--bg-surface-active);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin-bottom: 8px;
  pointer-events: none;
}

.drink-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 4px;
  pointer-events: none;
}

.drink-tickets {
  font-size: 0.85rem;
  color: #38bdf8;
  font-weight: 700;
  pointer-events: none;
}

/* Count Badge on Drink Card */
.card-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background-color: var(--accent-blue);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.9rem;
  min-width: 26px;
  height: 26px;
  padding: 0 4px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-primary);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* --- Backdrop --- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 20;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* --- Order Section & Drawer --- */
.order-section {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.4);
  padding-bottom: var(--safe-area-bottom);
}

.order-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
}

.order-bar-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.drink-count-badge {
  background-color: var(--accent-blue);
  color: #ffffff;
  font-weight: 700;
  font-size: 1.1rem;
  min-width: 36px;
  height: 36px;
  padding: 0 6px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.order-totals {
  display: flex;
  flex-direction: column;
}

.total-tickets {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.total-euro {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.btn-drawer-toggle {
  background-color: var(--bg-surface-active);
  border: none;
  color: var(--text-main);
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.chevron {
  transition: transform 0.3s ease;
  font-size: 0.9rem;
}

.chevron.open {
  transform: rotate(180deg);
}

/* Expandable Drawer Content */
.drawer-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0, 1, 0, 1);
  background-color: var(--bg-surface);
  padding: 0 16px;
}

.drawer-content.open {
  max-height: 70vh;
  overflow-y: auto;
  transition: max-height 0.3s ease-in-out;
  padding: 16px 16px 8px 16px;
  border-bottom: 1px solid var(--border-color);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.drawer-header h2 {
  font-size: 1.1rem;
}

/* View Mode Toggle */
.view-toggle {
  display: flex;
  background-color: var(--bg-primary);
  padding: 2px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.toggle-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
}

.toggle-btn.active {
  background-color: var(--bg-surface-active);
  color: var(--text-main);
}

/* Selected Items List in Drawer */
.order-items-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.order-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--bg-primary);
  padding: 10px 12px;
  border-radius: 8px;
}

.order-item-details {
  display: flex;
  flex-direction: column;
}

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

.order-item-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.order-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-counter {
  background-color: var(--bg-surface-active);
  color: var(--text-main);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-counter:active {
  background-color: var(--accent-blue);
}

.btn-delete-item {
  background: none;
  border: none;
  color: var(--accent-red);
  font-size: 1.2rem;
  padding: 4px 8px;
  cursor: pointer;
  margin-left: 4px;
}

.drawer-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.btn-clear {
  width: 100%;
  padding: 12px;
  background-color: rgba(220, 38, 38, 0.15);
  color: #f87171;
  border: 1px solid rgba(220, 38, 38, 0.3);
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}

.btn-clear:active {
  background-color: var(--accent-red);
  color: #ffffff;
}

.card-badge.hidden {
  display: none !important;
}

/* --- Install Banner --- */
.install-banner {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  background-color: var(--accent-blue);
  color: #ffffff;
  padding: 14px 16px;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 100;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.install-banner.hidden {
  display: none !important;
}

.install-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.install-text strong {
  font-size: 1rem;
}

.install-text p {
  font-size: 0.825rem;
  margin-top: 2px;
  opacity: 0.95;
  line-height: 1.3;
}

.install-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn-install {
  background-color: #ffffff;
  color: var(--accent-blue);
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-dismiss {
  background: transparent;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}