/* Shared component library used by both the business panel and the public menu.
   Components rely on semantic custom properties (--surface-*, --text-*, --accent,
   --border) that panel.css and public.css define differently per surface. */

/* Icons */
.icon { display: inline-block; vertical-align: -0.35em; flex: none; }
.btn .icon { vertical-align: -0.3em; }
.nav-link .icon { color: var(--text-muted); }
.nav-link[aria-current="page"] .icon { color: var(--accent-strong); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: 0 var(--space-5); border-radius: var(--radius-md);
  border: 1px solid transparent; font-weight: 600; font-size: var(--text-sm);
  transition: background var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard), transform var(--duration-fast) var(--ease-standard);
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent-strong); text-decoration: none; }
.btn-secondary { background: var(--surface-raised); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-hover); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--text-primary); }
.btn-ghost:hover { background: var(--surface-hover); text-decoration: none; }
.btn-danger { background: var(--red-500); color: #fff; }
.btn-danger:hover { background: #a82121; text-decoration: none; }
.btn-sm { min-height: 36px; padding: 0 var(--space-4); font-size: var(--text-xs); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-icon { padding: 0; width: 44px; }

/* Form fields */
.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-2); margin-bottom: var(--space-4); }
.field > label, .field-label { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); }
.field-hint { font-size: var(--text-xs); color: var(--text-muted); }
.field-error { font-size: var(--text-xs); color: var(--red-500); font-weight: 600; }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface-raised); padding: var(--space-3); font-size: var(--text-base); color: var(--text-primary);
}
textarea.input { min-height: 88px; resize: vertical; }
.input:focus-visible { border-color: var(--accent); }
.input[aria-invalid="true"] { border-color: var(--red-500); }
.input-group { display: flex; gap: var(--space-2); }
.input-group .input { flex: 1; }
.checkbox-row { display: flex; align-items: center; gap: var(--space-2); min-height: 44px; }
.checkbox-row input[type="checkbox"] { width: 20px; height: 20px; }

/* Cards */
.card {
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: var(--space-5);
}
.card-flat { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-4); }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.card-title { font-size: var(--text-lg); }
.card-grid { display: grid; gap: var(--space-4); grid-template-columns: 1fr; }
@media (min-width: 720px) { .card-grid.cols-2 { grid-template-columns: 1fr 1fr; } .card-grid.cols-3 { grid-template-columns: repeat(3,1fr); } }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: var(--space-1); padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.01em;
  background: var(--neutral-100); color: var(--neutral-700);
}
.badge-success { background: var(--green-100); color: var(--green-500); }
.badge-warning { background: var(--amber-100); color: var(--amber-500); }
.badge-danger { background: var(--red-100); color: var(--red-500); }
.badge-accent { background: var(--accent-soft); color: var(--accent-strong); }
.badge-dot { width: 8px; height: 8px; border-radius: 50%; background: currentcolor; }

/* Alerts */
.alert { display: flex; gap: var(--space-3); padding: var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--border); align-items: flex-start; }
.alert-info { background: var(--blue-50); border-color: var(--blue-100); color: var(--blue-700); }
.alert-success { background: var(--green-100); border-color: var(--green-100); color: var(--green-500); }
.alert-warning { background: var(--amber-100); border-color: var(--amber-100); color: var(--amber-500); }
.alert-danger { background: var(--red-100); border-color: var(--red-100); color: var(--red-500); }
.alert-title { font-weight: 700; margin-bottom: var(--space-1); }
.alert-icon { flex: none; width: 20px; height: 20px; }

/* Tabs */
.tabs { display: flex; gap: var(--space-1); overflow-x: auto; border-bottom: 1px solid var(--border); }
.tab { padding: var(--space-3) var(--space-4); font-weight: 600; font-size: var(--text-sm); color: var(--text-muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab[aria-current="page"] { color: var(--accent); border-color: var(--accent); }
.tab:hover { color: var(--text-primary); text-decoration: none; }

/* Modal / dialog */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 18, 26, 0.5); display: none; align-items: center; justify-content: center; padding: var(--space-4); z-index: 60; }
.modal-backdrop.is-open { display: flex; }
.modal { background: var(--surface-raised); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); max-width: 32rem; width: 100%; max-height: 90vh; overflow-y: auto; padding: var(--space-6); }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); margin-bottom: var(--space-4); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--space-3); margin-top: var(--space-5); flex-wrap: wrap; }
.modal-close { background: transparent; border: none; font-size: var(--text-xl); line-height: 1; color: var(--text-muted); min-height: 44px; min-width: 44px; }

/* Drawer (mobile nav / product detail) */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(15, 18, 26, 0.5); display: none; z-index: 70; }
.drawer-backdrop.is-open { display: block; }
.drawer {
  position: fixed; right: 0; top: 0; bottom: 0; width: min(26rem, 92vw); background: var(--surface-raised);
  box-shadow: var(--shadow-lg); transform: translateX(100%); transition: transform var(--duration-base) var(--ease-standard);
  overflow-y: auto; padding: var(--space-6); z-index: 71;
}
.drawer-backdrop.is-open .drawer { transform: translateX(0); }
.drawer.from-left { right: auto; left: 0; transform: translateX(-100%); }
.drawer-backdrop.is-open .drawer.from-left { transform: translateX(0); }
.drawer-handle { display: none; }

/* Sheet drawers (product detail, info) become a bottom sheet sized to content on
   small screens instead of a full-height panel with a large empty area below. */
@media (max-width: 47.99rem) {
  .drawer.drawer-sheet {
    right: 0; left: 0; top: auto; bottom: 0; width: 100%; max-width: none;
    max-height: 85vh; height: auto; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(100%); padding-top: var(--space-3);
    padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
  }
  .drawer-backdrop.is-open .drawer.drawer-sheet { transform: translateY(0); }
  .drawer.drawer-sheet .drawer-handle { display: block; width: 2.5rem; height: 4px; border-radius: var(--radius-full); background: var(--border); margin: 0 auto var(--space-3); }
  .drawer.drawer-sheet .drawer-handle-row { position: relative; }
  .drawer.drawer-sheet .modal-close { position: absolute; right: 0; top: -0.25rem; }
}

/* Navigation */
.nav-list { display: flex; flex-direction: column; gap: var(--space-1); }
.nav-link { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); color: var(--text-primary); font-weight: 600; font-size: var(--text-sm); }
.nav-link:hover { background: var(--surface-hover); text-decoration: none; }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); }

/* Empty states */
.empty-state { text-align: center; padding: var(--space-7) var(--space-5); color: var(--text-muted); }
.empty-state-icon { display: flex; align-items: center; justify-content: center; margin: 0 auto var(--space-3); color: var(--text-muted); opacity: 0.7; }
.empty-state-title { font-size: var(--text-lg); color: var(--text-primary); margin-bottom: var(--space-2); }

/* Skeletons */
.skeleton { background: linear-gradient(90deg, var(--neutral-100) 25%, var(--neutral-200) 37%, var(--neutral-100) 63%); background-size: 400% 100%; animation: skeleton-loading 1.4s ease infinite; border-radius: var(--radius-sm); }
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.skeleton-text { height: 0.9em; margin-bottom: var(--space-2); }
.skeleton-card { height: 6rem; border-radius: var(--radius-md); }

/* Toasts */
.toast-region { position: fixed; bottom: var(--space-5); right: var(--space-5); left: var(--space-5); display: flex; flex-direction: column; gap: var(--space-2); align-items: flex-end; z-index: 80; pointer-events: none; }
.toast { pointer-events: auto; background: var(--neutral-900); color: #fff; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); font-size: var(--text-sm); max-width: 24rem; }
.toast-success { background: var(--green-500); }
.toast-danger { background: var(--red-500); }

/* Tables */
.table-scroll { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--border); }
table.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); min-width: 32rem; }
table.data-table th, table.data-table td { text-align: left; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
table.data-table th { color: var(--text-muted); font-weight: 600; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em; background: var(--surface-app); }
table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background: var(--surface-hover); }

/* Product cards (public menu) */
.product-card { display: flex; gap: var(--space-4); padding: var(--space-4) 0; border-bottom: 1px solid var(--border); }
.product-card:last-child { border-bottom: none; }
.product-card-media { flex: none; width: 5.5rem; height: 5.5rem; border-radius: var(--radius-md); overflow: hidden; background: var(--surface-hover); display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 1.5rem; }
.product-card-media img { width: 100%; height: 100%; object-fit: cover; }
.product-card-body { flex: 1; min-width: 0; }
.product-card-name { font-size: var(--text-base); font-weight: 700; }
.product-card-desc { font-size: var(--text-sm); color: var(--text-muted); margin-top: var(--space-1); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-card-price { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.product-card.is-unavailable { opacity: 0.55; }
.product-card.is-unavailable .product-card-media { filter: grayscale(0.5); }

/* Language selector */
.lang-select-trigger { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 44px; padding: 0 var(--space-4); border-radius: var(--radius-full); border: 1px solid var(--border); background: var(--surface-raised); font-weight: 600; font-size: var(--text-sm); }
.lang-menu { list-style: none; margin: 0; padding: var(--space-2); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-1); }
.lang-menu-item a { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-3); border-radius: var(--radius-sm); color: var(--text-primary); }
.lang-menu-item a:hover { background: var(--surface-hover); text-decoration: none; }
.lang-menu-item[data-active="true"] a { background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; }
.lang-menu-status { font-size: var(--text-xs); color: var(--text-muted); }

/* Utility layout */
/* grid-template-columns: minmax(0,1fr) makes the single implicit column fill 100% of
   the container and lets its content shrink/wrap instead of growing to max-content
   width and overflowing the viewport (the default "auto" track sizing would do that). */
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
.stack-sm { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-2); }
.row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.muted { color: var(--text-muted); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
