/* ─── Reusable components: buttons, cards, forms, modals, toasts, badges ─── */

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 48px; padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 700; font-size: var(--font-size-base);
    transition: transform .1s ease, opacity .15s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--color-primary); color: #fff; box-shadow: var(--shadow-btn); }
.btn-outline { border: 1.5px solid var(--color-primary); color: var(--color-primary-dark); background: transparent; }
.btn-ghost   { color: var(--color-primary-dark); }
.btn-danger  { background: var(--color-error); color: #fff; }
.btn-block   { display: flex; width: 100%; }
.btn-sm      { min-height: 36px; padding: 6px 14px; font-size: var(--font-size-sm); border-radius: var(--radius-sm); }

/* Cards */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: var(--space-md);
}

/* Product card (menu grid) */
.product-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-md); }
.product-card {
    background: var(--color-surface); border-radius: var(--radius-md);
    box-shadow: var(--shadow-card); overflow: hidden;
    display: flex; flex-direction: column; position: relative;
}
.product-card .p-img { aspect-ratio: 1; object-fit: cover; width: 100%; background: var(--color-secondary); }
.product-card .p-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.product-card .p-name { font-weight: 700; font-size: var(--font-size-sm); line-height: 1.3; }
.product-card .p-desc {
    font-size: var(--font-size-xs); color: var(--color-text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.product-card .p-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 6px; }
.p-add {
    width: 34px; height: 34px; border-radius: var(--radius-full);
    background: var(--color-primary); color: #fff; font-size: 20px; line-height: 1;
    display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-btn);
}
.wish-btn { position: absolute; top: 8px; right: 8px; font-size: 18px; background: rgba(255,255,255,.85); width: 32px; height: 32px; border-radius: var(--radius-full); display:flex; align-items:center; justify-content:center; }

/* Tags & badges */
.tag {
    display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .4px;
    padding: 3px 8px; border-radius: var(--radius-full);
    background: var(--color-secondary); color: var(--color-primary-dark);
    text-transform: uppercase;
}
.tag-new       { background: #E8F5E9; color: #2E7D32; }
.tag-bestseller{ background: #FFF3E0; color: #E65100; }
.tag-limited   { background: #FCE4EC; color: #C2185B; }
.tag-festive   { background: #FFF8E1; color: #B8860B; }
.tag-preorder  { background: #E3F2FD; color: #1565C0; }
.badge {
    display: inline-block; padding: 4px 12px; border-radius: var(--radius-full);
    font-size: var(--font-size-xs); font-weight: 700;
}
.badge-pending, .badge-confirmed { background: #FFF8E1; color: #B8860B; }
.badge-preparing        { background: #FFF3E0; color: #E65100; }
.badge-ready            { background: #E3F2FD; color: #1565C0; }
.badge-out_for_delivery { background: #FFF3E0; color: #E65100; }
.badge-completed        { background: #E8F5E9; color: #2E7D32; }
.badge-cancelled        { background: #FFEBEE; color: #C62828; }

/* Forms */
.field { margin-bottom: var(--space-md); }
.field label { display: block; font-size: var(--font-size-sm); font-weight: 500; margin-bottom: 6px; color: var(--color-text-muted); }
.input, select.input, textarea.input {
    width: 100%; min-height: 48px; padding: 12px 14px;
    border: 1.5px solid var(--color-border); border-radius: var(--radius-sm);
    background: var(--color-surface); font-size: var(--font-size-base);
}
.input:focus { outline: none; border-color: var(--color-primary); }
textarea.input { min-height: 80px; resize: vertical; }

/* Quantity stepper */
.stepper { display: inline-flex; align-items: center; gap: 2px; border: 1.5px solid var(--color-border); border-radius: var(--radius-full); }
.stepper button { width: 36px; height: 36px; font-size: 18px; color: var(--color-primary-dark); }
.stepper .qty { min-width: 28px; text-align: center; font-weight: 700; }

/* Segmented toggle (pickup / delivery) */
.segmented { display: flex; background: var(--color-secondary); border-radius: var(--radius-md); padding: 4px; }
.segmented button {
    flex: 1; min-height: 44px; border-radius: calc(var(--radius-md) - 4px);
    font-weight: 700; color: var(--color-primary-dark);
}
.segmented button.active { background: var(--color-surface); box-shadow: var(--shadow-card); }

/* Sticky bottom bar (product detail / cart) */
.sticky-bar {
    position: fixed; left: 0; right: 0;
    bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
    background: var(--color-surface); border-top: 1px solid var(--color-border);
    padding: 10px var(--space-md); z-index: 40;
    display: flex; gap: var(--space-md); align-items: center;
    max-width: 560px; margin: 0 auto;
}

/* Modal */
.modal-overlay {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(46,33,24,.45);
    display: flex; align-items: flex-end; justify-content: center;
}
.modal-sheet {
    background: var(--color-surface); width: 100%; max-width: 560px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: var(--space-lg); box-shadow: var(--shadow-modal);
    max-height: 85vh; overflow-y: auto;
    animation: sheet-up .25s ease;
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }

/* Toast */
#toast-root { position: fixed; bottom: calc(var(--bottom-nav-height) + 20px); left: 0; right: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
    background: var(--color-text); color: #fff;
    padding: 12px 20px; border-radius: var(--radius-full);
    font-size: var(--font-size-sm); max-width: 90%;
    animation: toast-in .25s ease;
}
.toast-error { background: var(--color-error); }
.toast-success { background: var(--color-success); }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } }

/* Filter chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
    flex-shrink: 0; padding: 8px 16px; border-radius: var(--radius-full);
    border: 1.5px solid var(--color-border); background: var(--color-surface);
    font-size: var(--font-size-sm); font-weight: 500; white-space: nowrap;
}
.chip.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

/* Progress bar (delivery tracker + tier) */
.progress-track { background: var(--color-border); border-radius: var(--radius-full); height: 8px; overflow: hidden; }
.progress-fill  { background: var(--color-primary); height: 100%; border-radius: var(--radius-full); transition: width .4s ease; }

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--color-border) 25%, #F7EFE0 50%, var(--color-border) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite;
    border-radius: var(--radius-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* Empty state */
.empty-state { text-align: center; padding: var(--space-2xl) var(--space-md); color: var(--color-text-muted); }
.empty-state .emoji { font-size: 48px; margin-bottom: var(--space-md); }

/* Membership card */
.member-card {
    border-radius: var(--radius-lg); padding: var(--space-lg);
    color: #fff; position: relative; overflow: hidden;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    box-shadow: var(--shadow-modal);
}
.member-card.tier-silver   { background: linear-gradient(135deg, #9BA4B0, #6E7887); }
.member-card.tier-gold     { background: linear-gradient(135deg, #D4A853, #A87F2C); }
.member-card.tier-platinum { background: linear-gradient(135deg, #4A4458, #2C2836); }
