/* Mithila Gems - real-time cart UI (mini-cart drawer, badge, toasts) */

.mg-no-scroll {
    overflow: hidden;
}

/* --------------------------------------------------------------- badge */

[data-cart-count] {
    position: absolute;
    top: -5px;
    right: -6px;
    min-width: 19px;
    height: 19px;
    padding: 0 5px;
    border-radius: 10px;
    background: #d64545;
    color: #fff;
    font-size: 0.66rem;
    font-weight: 700;
    line-height: 19px;
    text-align: center;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

[data-cart-count].is-visible {
    opacity: 1;
    transform: scale(1);
}

/* Brief pop so the shopper sees the count change. */
@keyframes mgBadgePop {
    0% { transform: scale(1); }
    45% { transform: scale(1.45); }
    100% { transform: scale(1); }
}

[data-cart-count].is-bump {
    animation: mgBadgePop 0.35s ease;
}

/* -------------------------------------------------------------- drawer */

.mg-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(420px, 100vw);
    background: #fff;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 30px rgba(15, 40, 34, 0.18);
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    visibility: hidden;
}

.mg-drawer.is-open {
    transform: translateX(0);
    visibility: visible;
}

.mg-drawer__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 40, 34, 0.45);
    z-index: 1199;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s ease, visibility 0.28s ease;
}

.mg-drawer__backdrop.is-open {
    opacity: 1;
    visibility: visible;
}

.mg-drawer__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e7eee9;
    background: #193833;
    color: #fff;
}

.mg-drawer__title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
    color: #fff;
}

.mg-drawer__close {
    background: transparent;
    border: 0;
    color: #fff;
    font-size: 1.6rem;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
    opacity: 0.85;
}

.mg-drawer__close:hover { opacity: 1; }

.mg-drawer__body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
}

.mg-drawer__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mg-drawer__item {
    display: flex;
    gap: 14px;
    padding: 16px 0;
    border-bottom: 1px solid #eef3f0;
    align-items: flex-start;
}

.mg-drawer__img {
    width: 62px;
    height: 62px;
    object-fit: contain;
    border: 1px solid #eef3f0;
    border-radius: 8px;
    padding: 4px;
    flex-shrink: 0;
}

.mg-drawer__meta {
    flex: 1;
    min-width: 0;
}

.mg-drawer__name {
    display: block;
    font-weight: 700;
    font-size: 0.92rem;
    color: #193833;
    text-decoration: none;
}

.mg-drawer__name:hover { color: #258F67; }

.mg-drawer__label {
    display: block;
    font-size: 0.8rem;
    color: #6b807a;
    margin: 2px 0 8px;
}

.mg-drawer__side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.mg-drawer__price {
    font-weight: 700;
    color: #193833;
    white-space: nowrap;
}

.mg-drawer__remove {
    background: transparent;
    border: 0;
    color: #b0393c;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.mg-drawer__empty {
    text-align: center;
    padding: 48px 12px;
    color: #6b807a;
}

.mg-drawer__foot {
    border-top: 1px solid #e7eee9;
    padding: 18px 24px 22px;
    background: #f7faf8;
}

.mg-drawer__total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 14px;
    font-size: 0.95rem;
    color: #4a5d58;
}

.mg-drawer__total strong {
    font-size: 1.4rem;
    color: #258F67;
}

/* --------------------------------------------------------- qty stepper */

.mg-qty {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid #d4e0d9;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.mg-qty__btn {
    border: 0;
    background: #f1f5f3;
    color: #193833;
    width: 34px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease;
}

.mg-qty__btn:hover:not(:disabled) { background: #dce8e1; }
.mg-qty__btn:disabled { opacity: 0.5; cursor: not-allowed; }

.mg-qty__input {
    width: 56px;
    border: 0;
    padding: 7px 4px;
    font-weight: 700;
    font-size: 0.9rem;
    color: #193833;
    -moz-appearance: textfield;
}

.mg-qty__input::-webkit-outer-spin-button,
.mg-qty__input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.mg-qty__input:focus {
    outline: 2px solid #258F67;
    outline-offset: -2px;
}

.mg-qty--sm .mg-qty__btn { width: 28px; font-size: 0.95rem; }
.mg-qty--sm .mg-qty__input { width: 42px; padding: 4px 2px; font-size: 0.82rem; }

/* -------------------------------------------------------------- toasts */

.mg-toast-host {
    position: fixed;
    right: 20px;
    top: 20px;
    z-index: 1300;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
    pointer-events: none;
}

.mg-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: min(380px, calc(100vw - 40px));
    padding: 12px 18px;
    border-radius: 10px;
    background: #193833;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 10px 28px rgba(15, 40, 34, 0.28);
    opacity: 0;
    transform: translateY(-14px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.mg-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.mg-toast--error { background: #a5322f; }
.mg-toast--info  { background: #2f5d55; }

.mg-toast__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    font-size: 0.75rem;
    flex-shrink: 0;
}

/* ------------------------------------------------- button busy / spinner */

.is-busy {
    opacity: 0.7;
    cursor: progress !important;
    pointer-events: none;
}

.mg-spinner {
    display: inline-block;
    width: 13px;
    height: 13px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: mgSpin 0.7s linear infinite;
    vertical-align: -2px;
}

@keyframes mgSpin {
    to { transform: rotate(360deg); }
}

/* Keep the native <select> arrow while hiding the text during a fetch. */
select.is-busy {
    color: transparent !important;
}

@media (max-width: 575.98px) {
    .mg-drawer { width: 100vw; }
    .mg-toast-host { left: 16px; right: 16px; align-items: stretch; }
    .mg-toast { max-width: none; }
}