/* Design Tokens and Pure CSS for Tiệm Bánh Mai Web App */

:root {
  --color-background: #FBF7F3;
  --color-surface: #FFFFFF;
  --color-surface-soft: #F3E1DE;
  --color-border: #E9E2DC;
  --color-text-primary: #3B2A24;
  --color-text-secondary: #5A4A44;
  --color-accent: #86592F;
  --color-primary: #2A1E1A;
  --color-on-primary: #FFFFFF;
  --color-success: #3D7A4F;
  --color-error: #B3261E;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --spacing-unit: 4px;
  --spacing-card: 12px;
  --spacing-screen: 16px;
  --spacing-section: 24px;

  --font-display: "Playfair Display", Georgia, serif;
  --font-body: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background-color: var(--color-background);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

input, select, textarea {
  font-size: 16px !important; /* Prevent iOS zoom */
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

.font-display, .font-h2, .font-h3, .font-logo {
  font-family: var(--font-display);
  font-variant-numeric: lining-nums tabular-nums;
  font-feature-settings: "lnum" 1, "tnum" 1;
}

.font-body, .font-label, .font-caption {
  font-family: var(--font-body);
}

.app-container {
  width: 100%;
  max-width: 440px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background-color: var(--color-background);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 24px rgba(42, 30, 26, 0.05);
}

.screen-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 16px));
}

.screen-view.no-bottom-nav {
  padding-bottom: env(safe-area-inset-bottom, 16px);
}

.screen-view.has-fixed-bottom {
  padding-bottom: calc(96px + env(safe-area-inset-bottom, 16px));
}

/* Header styles */
.app-header {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-background);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--color-text-primary);
  font-variant-numeric: lining-nums tabular-nums;
}

.btn-icon {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--color-text-primary);
}

.btn-icon:active {
  opacity: 0.7;
}

/* Bottom Navigation Bar */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 440px;
  height: calc(64px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 30;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  height: 100%;
  color: var(--color-text-secondary);
  font-size: 12px;
  font-weight: 600;
  position: relative;
  text-decoration: none;
}

.nav-item.active {
  color: var(--color-accent);
}

.nav-item svg {
  width: 24px;
  height: 24px;
}

.nav-badge {
  position: absolute;
  top: 8px;
  right: calc(50% - 18px);
  background: var(--color-error);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 600;
  height: 16px;
  min-width: 16px;
  border-radius: 8px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Fixed Bottom Action Container */
.fixed-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 440px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 12px)) 16px;
  background: var(--color-background);
  border-top: 1px solid var(--color-border);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Buttons */
.btn-primary {
  width: 100%;
  min-height: 48px;
  height: 52px;
  padding: 0 20px;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: var(--color-on-primary);
  border: none;
  font-weight: 600;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-primary:active {
  opacity: 0.85;
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-secondary {
  width: 100%;
  min-height: 48px;
  height: 52px;
  padding: 0 20px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  font-weight: 600;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-outline {
  min-height: 48px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  font-weight: 600;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Cards & Layout */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  overflow: hidden;
}

.card-interactive {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.card-interactive.selected {
  border: 1.5px solid var(--color-primary);
  box-shadow: 0 2px 8px rgba(42, 30, 26, 0.08);
}

/* Product Card Grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 0 16px 16px 16px;
}

.product-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  cursor: pointer;
}

.product-img-wrap {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--color-surface-soft);
  position: relative;
  overflow: hidden;
}

.product-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-info {
  padding: 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.product-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 4px;
  color: var(--color-text-primary);
}

.product-desc {
  font-size: 14px;
  color: var(--color-text-secondary);
  line-height: 1.4;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.product-price {
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text-primary);
  font-variant-numeric: lining-nums tabular-nums;
  white-space: nowrap;
}

.btn-add-mini {
  width: 48px;
  height: 48px;
  min-height: 48px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: var(--color-on-primary);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Category Tabs */
.tab-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 16px;
  scrollbar-width: none;
}
.tab-list::-webkit-scrollbar {
  display: none;
}

.tab-pill {
  white-space: nowrap;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-decoration: none;
  display: inline-block;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
}

.tab-pill.active {
  background: var(--color-primary);
  color: var(--color-on-primary);
  border-color: var(--color-primary);
}

/* Sheets & Overlays (13, 14, 26) */
.overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 50;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

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

.sheet-panel {
  background: var(--color-background);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  max-height: 85vh;
  overflow-y: auto;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 16px)) 16px;
  transform: translateY(100%);
  transition: transform 0.25s ease;
}

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

/* Toast */
.toast-notice {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(42, 30, 26, 0.95);
  color: #FFFFFF;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 600;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast-notice.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Empty states */
.empty-view {
  padding: 48px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.empty-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: var(--color-surface-soft);
  color: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Form controls */
.input-field {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 16px;
  color: var(--color-text-primary);
  outline: none;
}

.input-field:focus {
  border-color: var(--color-primary);
}

.input-field.error {
  border-color: var(--color-error);
}

.error-text {
  color: var(--color-error);
  font-size: 14px;
  margin-top: 4px;
}

/* Option chips */
.chip-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chip-btn-row {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-primary);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chip-btn-row.selected {
  border-color: var(--color-primary);
  border-width: 1.5px;
  background: var(--color-surface);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(42, 30, 26, 0.06);
}

.chip-btn-inline {
  min-height: 48px;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chip-btn-inline.selected {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-weight: 600;
}

/* Thanh nút ở đáy nằm trên thanh điều hướng dưới (giỏ hàng) */
.fixed-bottom-bar.above-nav {
  bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  padding-bottom: 12px;
}

.screen-view.has-fixed-bottom.above-nav-space {
  padding-bottom: calc(150px + env(safe-area-inset-bottom, 16px));
}
