/* Shared overlays: dropdowns, mini cart, mobile menu, modals, dialogs and toasts. One set of values for all of them.
   Dropdowns: "User Account Dropdown Menu", Dmitry Sergushkin, dribbble.com/shots/25742341
   Mini cart: "Shopping Cart Dropdown", Matt Bonini, dribbble.com/shots/3815376
   Mobile menu: "asklepios v3 Side Sheet", strangehelix, dribbble.com/shots/26882243
   Modals and dialogs: "New project", Untitled UI by Jordan Hughes, dribbble.com/shots/27698376
   Toasts: "Expandable Notification Toast", Virgil Pana, dribbble.com/shots/25882999 */
:root {
    --ui-ink: #16181C; --ui-muted: #6B7280; --ui-faint: #9AA0A9; --ui-line: #ECEEF0; --ui-soft: #F5F6F7;
    --ui-accent: #E0004A; --ui-accent-hover: #B8003D;
    --ui-ok: #16A34A; --ui-bad: #DC2626; --ui-warn: #D97706;
    --ui-shadow: 0 12px 32px rgba(11, 12, 14, 0.08), 0 2px 6px rgba(11, 12, 14, 0.04);
    --ui-ease: cubic-bezier(0.16, 1, 0.3, 1);
}
.ui-menu, .mini-cart, .ui-modal, .drawer, .ui-toast, .swal2-popup { font-family: 'General Sans', 'Helvetica Neue', Arial, sans-serif; }

/* Buttons shared by every overlay: solid primary, outline secondary, 44px tall, 2:1 padding */
.ui-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 20px;
    border-radius: 8px; font-size: 15px; font-weight: 500; line-height: 1.2; text-align: center;
    transition: background-color 150ms ease-out, border-color 150ms ease-out, scale 150ms ease-out;
}
.ui-btn:active { scale: 0.97; }
.ui-btn-primary { background: var(--ui-accent); color: #fff; }
.ui-btn-outline { background: #fff; color: var(--ui-ink); box-shadow: inset 0 0 0 1px var(--ui-line); }
.ui-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.ui-x { display: grid; place-items: center; width: 40px; height: 40px; margin: -8px -8px 0 0; border-radius: 8px; color: var(--ui-faint); transition: background-color 150ms ease-out, color 150ms ease-out; }
.ui-x svg { width: 20px; height: 20px; }
.ui-x-light { color: rgba(255, 255, 255, 0.7); }
@media (hover: hover) and (pointer: fine) {
    .ui-btn-primary:hover { background: var(--ui-accent-hover); }
    .ui-btn-outline:hover { background: var(--ui-soft); }
    .ui-x:hover { background: var(--ui-soft); color: var(--ui-ink); }
    .ui-x-light:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
}

/* Menu panel: header row, groups split by hairlines, rows of icon, label and right-hand meta */
.ui-menu { background: #fff; border: 1px solid var(--ui-line); border-radius: 12px; box-shadow: var(--ui-shadow); overflow: hidden; color: var(--ui-ink); }
.ui-menu-nav { position: absolute; left: 0; top: 100%; width: 300px; margin-top: 4px; }
.ui-menu-search { position: absolute; left: 0; right: 0; top: calc(100% + 8px); z-index: 50; max-height: 400px; overflow-y: auto; }
.ui-menu-head { display: grid; gap: 2px; padding: 16px; border-bottom: 1px solid var(--ui-line); }
.ui-menu-head .ui-menu-name { font-size: 15px; font-weight: 500; }
.ui-menu-group { padding: 8px; }
.ui-menu-group + .ui-menu-group { border-top: 1px solid var(--ui-line); }
.ui-menu-scroll { max-height: min(56vh, 480px); overflow-y: auto; }
.ui-menu-label { padding: 8px 8px 4px; font-size: 13px; font-weight: 500; color: var(--ui-muted); }
.ui-menu-item {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 8px; padding-left: calc(8px + var(--lvl, 0) * 16px);
    border-radius: 8px; color: var(--ui-ink); text-align: left; transition: background-color 120ms ease-out;
}
.ui-menu-item[aria-current="page"] { background: var(--ui-soft); }
.ui-menu-item[aria-current="page"] .ui-menu-name { color: var(--ui-accent); }
.ui-menu-icon { flex-shrink: 0; width: 20px; height: 20px; color: var(--ui-muted); }
.ui-menu-text { display: grid; flex: 1; min-width: 0; }
.ui-menu-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; line-height: 1.35; }
.ui-menu-item.is-sub .ui-menu-name { font-size: 14px; color: var(--ui-muted); }
.ui-menu-sub { font-size: 13px; line-height: 1.35; color: var(--ui-muted); }
.ui-menu-sub:empty { display: none; }
.ui-menu-meta { flex-shrink: 0; font-size: 13px; color: var(--ui-faint); font-variant-numeric: tabular-nums; }
.ui-menu-thumb { flex-shrink: 0; width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--ui-soft); }
.ui-menu-note { padding: 16px; font-size: 14px; color: var(--ui-muted); }
@media (hover: hover) and (pointer: fine) {
    .ui-menu-item:hover { background: var(--ui-soft); }
}

/* Mini cart: caret over the cart button, rows split by hairlines, boxed quantity with stacked arrows */
.mini-cart {
    position: absolute; right: 0; top: calc(100% + 24px); z-index: 50; width: 360px; max-width: calc(100vw - 32px);
    background: #fff; border: 1px solid var(--ui-line); border-radius: 12px; box-shadow: var(--ui-shadow); color: var(--ui-ink);
}
.mini-cart.hidden, .ui-modal.hidden { display: none; }
.mini-cart::before {
    content: ''; position: absolute; right: 92px; top: -7px; width: 12px; height: 12px; rotate: 45deg;
    background: #fff; border-left: 1px solid var(--ui-line); border-top: 1px solid var(--ui-line);
}
.mc-items { max-height: 320px; overflow-y: auto; padding-inline: 16px; }
.mc-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto 32px; align-items: center; gap: 12px; padding-block: 16px; }
.mc-row + .mc-row { border-top: 1px solid var(--ui-line); }
.mc-row img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--ui-soft); }
.mc-info h4 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 500; line-height: 1.3; }
.mc-info p { font-size: 13px; line-height: 1.4; color: var(--ui-muted); font-variant-numeric: tabular-nums; }
.mc-qty { display: flex; align-items: stretch; height: 44px; border: 1px solid var(--ui-line); border-radius: 8px; overflow: hidden; }
.mc-qty > span:first-child { display: grid; place-items: center; min-width: 32px; font-size: 15px; font-variant-numeric: tabular-nums; }
.mc-qty-arrows { display: grid; border-left: 1px solid var(--ui-line); }
.mc-qty-arrows button { display: grid; place-items: center; width: 24px; color: var(--ui-muted); }
.mc-qty-arrows button + button { border-top: 1px solid var(--ui-line); }
.mc-qty-arrows button:disabled { opacity: 0.35; }
.mc-qty-arrows svg { width: 14px; height: 14px; }
.mc-remove { display: grid; place-items: center; width: 32px; height: 44px; color: var(--ui-faint); transition: color 150ms ease-out; }
.mc-remove svg { width: 20px; height: 20px; }
.mc-foot { display: grid; gap: 8px; padding: 16px; border-top: 1px solid var(--ui-line); }
.mc-total { display: flex; justify-content: space-between; padding-bottom: 8px; font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; }
.mc-empty { display: grid; justify-items: center; gap: 8px; padding: 32px 16px; text-align: center; font-size: 14px; color: var(--ui-muted); }
.mc-empty svg { width: 32px; height: 32px; color: var(--ui-faint); }
.mc-empty a { font-weight: 500; color: var(--ui-accent); }
@media (hover: hover) and (pointer: fine) {
    .mc-remove:hover { color: var(--ui-bad); }
    .mc-qty-arrows button:not(:disabled):hover { background: var(--ui-soft); color: var(--ui-ink); }
}

/* Mobile menu: side sheet with a solid head whose inner corner is rounded, grouped icon rows, two buttons at the foot */
.ui-scrim { background: rgba(11, 12, 14, 0.4); }
.drawer {
    position: fixed; inset: 0 auto 0 0; z-index: 101; width: min(88vw, 360px); display: flex; flex-direction: column;
    background: #fff; color: var(--ui-ink); translate: -100% 0; transition: translate 280ms var(--ui-ease), box-shadow 280ms;
}
.drawer.is-open { translate: 0 0; box-shadow: 0 0 48px rgba(11, 12, 14, 0.2); }
.drawer-head { display: grid; gap: 8px; padding: 16px 16px 24px; background: #0B0C0E; color: #fff; border-bottom-right-radius: 24px; }
.drawer-brand { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.drawer-brand img { width: 40px; height: 40px; object-fit: contain; }
.drawer-brand .ui-x { margin: 0 -8px 0 0; }
.drawer-title { font-size: 24px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.15; }
.drawer-line { font-size: 14px; line-height: 1.45; color: #C9CDD3; }
.drawer-body { flex: 1; overflow-y: auto; padding-block: 8px; }
.drawer-body .ui-menu-group { padding-inline: 8px; }
.drawer-caret { margin-left: auto; transition: rotate 200ms var(--ui-ease); }
.drawer-caret.is-open { rotate: 180deg; }
.drawer-sub { padding-left: 32px; }
.drawer-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 16px; border-top: 1px solid var(--ui-line); }

/* Modal: title and line top left, close top right, body, footer hairline with the outline action left and the solid one right */
.ui-modal { position: fixed; inset: 0; z-index: 110; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(11, 12, 14, 0.4); }
.ui-modal-panel {
    width: 100%; max-width: 480px; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
    background: #fff; border-radius: 16px; box-shadow: 0 0 0 1px rgba(11, 12, 14, 0.04), 0 24px 48px rgba(11, 12, 14, 0.12); color: var(--ui-ink);
}
.ui-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 24px 24px 0; }
.ui-modal-title { font-size: 18px; font-weight: 500; line-height: 1.3; }
.ui-modal-sub { margin-top: 4px; font-size: 14px; line-height: 1.5; color: var(--ui-muted); }
.ui-modal-badge { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 12px; background: var(--ui-soft); color: var(--ui-ok); }
.ui-modal-badge svg { width: 24px; height: 24px; }
.ui-modal-body { display: grid; gap: 24px; padding: 24px; overflow-y: auto; }
.ui-modal-head + .ui-modal-body .ui-modal-title { margin-top: -8px; }
.ui-modal-product { display: grid; grid-template-columns: 72px minmax(0, 1fr); align-items: center; gap: 16px; padding: 12px; border-radius: 12px; background: var(--ui-soft); }
.ui-modal-product img { width: 72px; height: 72px; border-radius: 8px; object-fit: cover; background: #fff; }
.ui-modal-product h4 { font-size: 15px; font-weight: 500; line-height: 1.35; }
.ui-modal-product div div { margin-top: 4px; font-size: 14px; color: var(--ui-muted); font-variant-numeric: tabular-nums; }
.ui-field { display: grid; gap: 8px; }
.ui-field.hidden { display: none; }
.ui-label { font-size: 14px; font-weight: 500; }
.ui-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ui-chip {
    display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 16px; border-radius: 9999px;
    box-shadow: inset 0 0 0 1px var(--ui-line); font-size: 14px; font-weight: 500; color: var(--ui-ink);
    transition: box-shadow 150ms ease-out, background-color 150ms ease-out;
}
.ui-chip.is-selected { box-shadow: inset 0 0 0 2px var(--ui-ink); }
.ui-chip-tag { font-size: 11px; color: var(--ui-muted); }
.ui-swatch { width: 16px; height: 16px; border-radius: 9999px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.ui-hint { width: 100%; font-size: 13px; color: var(--ui-muted); }
.ui-error { font-size: 13px; color: var(--ui-bad); }
.ui-error.hidden { display: none; }
.ui-modal-foot { display: flex; justify-content: space-between; gap: 12px; padding: 16px 24px; border-top: 1px solid var(--ui-line); }
.ui-modal-foot .ui-btn { flex: 1; }
@media (min-width: 480px) { .ui-modal-foot .ui-btn { flex: 0 0 auto; } }
@media (hover: hover) and (pointer: fine) { .ui-chip:not(.is-selected):hover { box-shadow: inset 0 0 0 1px var(--ui-faint); } }

/* SweetAlert dialogs share the modal layout */
.swal2-popup:not(.swal2-toast) {
    width: min(480px, calc(100vw - 32px)) !important; padding: 24px 0 0 !important; border-radius: 16px !important; color: var(--ui-ink) !important;
    box-shadow: 0 0 0 1px rgba(11, 12, 14, 0.04), 0 24px 48px rgba(11, 12, 14, 0.12);
}
.swal2-popup:not(.swal2-toast) .swal2-icon { margin: 0 24px 16px !important; transform: scale(0.6); transform-origin: left top; height: 48px; width: 48px; }
.swal2-popup:not(.swal2-toast) .swal2-title { padding: 0 24px !important; text-align: left !important; font-size: 18px !important; font-weight: 500 !important; color: var(--ui-ink) !important; }
.swal2-popup:not(.swal2-toast) .swal2-html-container { margin: 8px 0 0 !important; padding: 0 24px !important; text-align: left !important; font-size: 14px !important; line-height: 1.5 !important; color: var(--ui-muted) !important; }
.swal2-popup:not(.swal2-toast) .swal2-input { width: auto !important; margin: 16px 24px 0 !important; height: 44px !important; border-radius: 8px !important; border: 1px solid var(--ui-line) !important; box-shadow: none !important; font-size: 15px !important; }
.swal2-popup:not(.swal2-toast) .swal2-input:focus { border-color: var(--ui-ink) !important; }
.swal2-popup:not(.swal2-toast) .swal2-validation-message { margin: 12px 24px 0 !important; background: var(--ui-soft) !important; color: var(--ui-bad) !important; font-size: 13px !important; }
.swal2-popup:not(.swal2-toast) .swal2-actions {
    width: 100%; margin: 24px 0 0 !important; padding: 16px 24px !important; justify-content: flex-end !important; gap: 12px;
    border-top: 1px solid var(--ui-line); flex-direction: row-reverse;
}
.swal2-popup:not(.swal2-toast) .swal2-styled { margin: 0 !important; min-height: 44px; padding: 10px 20px !important; border-radius: 8px !important; font-size: 15px !important; font-weight: 500 !important; box-shadow: none !important; }
.swal2-popup:not(.swal2-toast) .swal2-confirm { background: var(--ui-accent) !important; color: #fff !important; }
.swal2-popup:not(.swal2-toast) .swal2-cancel, .swal2-popup:not(.swal2-toast) .swal2-deny { margin-right: auto !important; background: #fff !important; color: var(--ui-ink) !important; box-shadow: inset 0 0 0 1px var(--ui-line) !important; }
.swal2-popup:not(.swal2-toast) .swal2-close { color: var(--ui-faint) !important; font-size: 28px !important; }
.swal2-container.swal2-backdrop-show:has(> .swal2-modal) { background: rgba(11, 12, 14, 0.4) !important; }
.swal2-popup .swal2-icon.swal2-warning { border-color: var(--ui-warn) !important; color: var(--ui-warn) !important; }
.swal2-popup .swal2-icon.swal2-info, .swal2-popup .swal2-icon.swal2-question { border-color: var(--ui-ink) !important; color: var(--ui-ink) !important; }

/* Toast: white card, outlined status circle, title, close cross, timer bar in the status colour along the bottom */
.swal2-popup.swal2-toast {
    --swal2-background: #fff;
    --swal2-color: var(--ui-ink);
    --swal2-toast-border: 1px solid var(--ui-line);
    --swal2-toast-box-shadow: var(--ui-shadow);
    --swal2-toast-show-animation: toast-in 240ms var(--ui-ease);
    --swal2-toast-hide-animation: toast-out 160ms ease-in forwards;
    --toast-tone: var(--ui-ink);
    width: 360px; max-width: calc(100vw - 24px); padding: 16px !important; border-radius: 16px !important;
    column-gap: 12px; align-items: center; overflow: hidden;
}
.swal2-toast.swal2-icon-success { --toast-tone: var(--ui-ok); }
.swal2-toast.swal2-icon-error { --toast-tone: var(--ui-bad); }
.swal2-toast.swal2-icon-warning { --toast-tone: var(--ui-warn); }
.swal2-toast h2.swal2-title { margin: 0 !important; padding: 0 !important; font-size: 15px !important; font-weight: 500 !important; line-height: 22px !important; color: var(--ui-ink) !important; text-align: left; }
.swal2-toast div.swal2-html-container { margin: 2px 0 0 !important; padding: 0 !important; font-size: 13px; line-height: 18px; color: var(--ui-muted); text-align: left; }
.swal2-toast .swal2-close { width: 32px; height: 32px; margin: -4px -4px -4px 0; border-radius: 8px; font-size: 22px; color: var(--ui-faint); align-self: center; }
.swal2-toast .swal2-close:focus-visible { box-shadow: 0 0 0 2px var(--ui-ink); }
.swal2-toast .swal2-icon { position: relative; width: 24px; min-width: 24px; height: 24px; margin: 0 !important; border: 0; border-radius: 0; background: none; animation: none; }
.swal2-toast .swal2-icon > *, .swal2-toast .swal2-icon::before { display: none !important; }
.swal2-toast .swal2-icon::after {
    content: ""; position: absolute; inset: 0; background: var(--toast-tone);
    -webkit-mask: var(--toast-glyph) center / contain no-repeat; mask: var(--toast-glyph) center / contain no-repeat;
}
/* ponytail: Lucide circle-check / circle-x / triangle-alert / info as masks, so one rule tints them per status */
.swal2-toast .swal2-icon { --toast-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4M12 8h.01'/%3E%3C/svg%3E"); }
.swal2-toast .swal2-icon.swal2-success { --toast-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m9 12 2 2 4-4'/%3E%3C/svg%3E"); }
.swal2-toast .swal2-icon.swal2-error { --toast-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m15 9-6 6M9 9l6 6'/%3E%3C/svg%3E"); }
.swal2-toast .swal2-icon.swal2-warning { --toast-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3'/%3E%3Cpath d='M12 9v4M12 17h.01'/%3E%3C/svg%3E"); }
.swal2-toast .swal2-timer-progress-bar-container { left: 0; right: 0; bottom: 0; border-radius: 0; }
.swal2-toast .swal2-timer-progress-bar { height: 3px; background: var(--toast-tone) !important; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px) scale(0.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-4px); } }
/* Toast stack sits just under the header with its right edge on the page's content edge (gutter 16 / 32 / 48) */
body.swal2-toast-shown .swal2-container.swal2-top-end { inset: 80px 16px auto auto; padding: 0; background: none !important; }
@media (min-width: 768px) { body.swal2-toast-shown .swal2-container.swal2-top-end { right: 32px; } }
@media (min-width: 1280px) { body.swal2-toast-shown .swal2-container.swal2-top-end { right: max(48px, calc((100vw - 1440px) / 2 + 48px)); } }
@media (max-width: 767px) {
    body.swal2-toast-shown .swal2-container.swal2-top-end { left: 16px; }
    .swal2-popup.swal2-toast { max-width: none; width: 100%; }
}

/* Fallback toast for pages without SweetAlert */
.ui-toast {
    position: fixed; top: 80px; right: 16px; z-index: 120; max-width: min(360px, calc(100vw - 32px)); padding: 16px;
    background: #fff; border: 1px solid var(--ui-line); border-radius: 16px; box-shadow: var(--ui-shadow);
    border-bottom: 3px solid var(--ui-ink); font-size: 15px; font-weight: 500; color: var(--ui-ink);
}
.ui-toast-success { border-bottom-color: var(--ui-ok); }
.ui-toast-error { border-bottom-color: var(--ui-bad); }
.ui-toast-warning { border-bottom-color: var(--ui-warn); }

@media (prefers-reduced-motion: reduce) {
    .drawer, .drawer-caret, .ui-btn, .ui-menu-item { transition: none; }
    .swal2-popup.swal2-toast { --swal2-toast-show-animation: none; --swal2-toast-hide-animation: toast-out 1ms forwards; }
}
