/* ------------------------------------------------------------------
   Reusable UI components
   ------------------------------------------------------------------ */

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 44px;
  padding: 10px 18px;
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  border-radius: var(--radius-full);
  background: var(--brand-primary);
  color: var(--text-inverse);
  transition: transform var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              opacity var(--dur-fast) var(--ease-out);
  white-space: nowrap;
  line-height: 1;
}
.btn:active       { transform: scale(.97); }
.btn:disabled     { opacity: .5; }
.btn:hover:not(:disabled) { background: var(--brand-primary-dark); }

.btn-secondary {
  background: var(--bg-muted);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-sunken); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-muted); }

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-success {
  background: var(--color-success);
  color: #fff;
}
.btn-success:hover:not(:disabled) { background: #15803d; }

.btn-sm { min-height: 34px; padding: 6px 12px; font-size: var(--fs-sm); }
.btn-lg { min-height: 52px; padding: 14px 24px; font-size: var(--fs-md); }
.btn-block { width: 100%; }

.btn-icon {
  width: 44px; height: 44px; padding: 0;
  border-radius: var(--radius-full);
}

/* ---------------- Icon button ---------------- */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  border-radius: var(--radius-full);
  color: var(--text);
  background: transparent;
  transition: background var(--dur-fast) var(--ease-out);
}
.icon-btn:hover { background: var(--bg-muted); }

/* ---------------- Cards ---------------- */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-body { padding: var(--s-4); }

/* ---------------- Chips ---------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  border-radius: var(--radius-full);
  background: var(--bg-muted);
  color: var(--text);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.chip-active {
  background: var(--brand-primary);
  color: var(--text-inverse);
  border-color: var(--brand-primary);
}

/* ---------------- Badges ---------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  border-radius: var(--radius-xs);
  background: var(--bg-muted);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .02em;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-veg     { color: var(--color-veg); border: 1px solid var(--color-veg); background: transparent; }
.badge-nonveg  { color: var(--color-nonveg); border: 1px solid var(--color-nonveg); background: transparent; }

/* Veg / non-veg square indicator */
.veg-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px; height: 14px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  flex-shrink: 0;
}
.veg-mark::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.veg-mark.is-veg    { color: var(--color-veg); }
.veg-mark.is-nonveg { color: var(--color-nonveg); }

/* ---------------- Form fields ---------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text);
}
.field .required { color: var(--color-danger); }

.input, .textarea, .select {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  font-size: var(--fs-md);
  color: var(--text);
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(230, 57, 70, .15);
}
.input[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: var(--color-danger);
}
.textarea { min-height: 90px; resize: vertical; font-family: inherit; }

.field-error {
  font-size: var(--fs-xs);
  color: var(--color-danger);
  min-height: 16px;
}

/* ---------------- Skeleton ---------------- */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-muted) 0%,
    var(--bg-sunken) 50%,
    var(--bg-muted) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s linear infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

/* ---------------- Toast ---------------- */
.toast-container {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + var(--s-3));
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  pointer-events: none;
  width: min(92vw, 420px);
}
.toast {
  pointer-events: auto;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: #0f172a;
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  box-shadow: var(--shadow-lg);
  animation: toast-in var(--dur-base) var(--ease-out);
}
.toast-success { background: var(--color-success); }
.toast-error   { background: var(--color-danger); }
.toast-warning { background: var(--color-warning); color: #1a1a1a; }
.toast-info    { background: var(--color-info); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------------- Modal ---------------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(2px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-4);
  animation: fade-in var(--dur-base) var(--ease-out);
}
.modal {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  max-height: 88vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
  animation: modal-in var(--dur-base) var(--ease-out);
}
.modal-header,
.modal-body,
.modal-footer { padding: var(--s-4); }
.modal-header { border-bottom: 1px solid var(--border); }
.modal-footer { border-top: 1px solid var(--border); display: flex; gap: var(--s-2); justify-content: flex-end; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
  from { opacity: 0; transform: scale(.96) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ---------------- Bottom sheet ---------------- */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .55);
  z-index: var(--z-drawer);
  animation: fade-in var(--dur-base) var(--ease-out);
}
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--bg-elevated);
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  max-height: 92vh;
  overflow: auto;
  z-index: calc(var(--z-drawer) + 1);
  padding-bottom: var(--safe-bottom);
  animation: sheet-in var(--dur-slow) var(--ease-out);
  will-change: transform;
}
.sheet-handle {
  width: 40px; height: 4px;
  background: var(--border-strong);
  border-radius: var(--radius-full);
  margin: 8px auto 4px;
}
@keyframes sheet-in {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* ---------------- Tabs ---------------- */
.tabs {
  display: flex;
  gap: var(--s-1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 10px 14px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color var(--dur-fast), border-color var(--dur-fast);
}
.tab[aria-selected="true"] {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
}

/* ---------------- Offline banner ---------------- */
.offline-banner {
  position: sticky; top: 0;
  background: var(--color-warning);
  color: #1a1a1a;
  text-align: center;
  padding: 6px 12px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  z-index: var(--z-sticky);
}

/* ---------------- Loader ---------------- */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Empty state ---------------- */
.empty-state {
  padding: var(--s-10) var(--s-4);
  text-align: center;
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 44px;
  margin-bottom: var(--s-3);
  opacity: .55;
}
.empty-state-title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  color: var(--text);
  margin-bottom: var(--s-2);
}
.empty-state-text { font-size: var(--fs-sm); max-width: 320px; margin: 0 auto var(--s-4); }