/**
 * ================================================
 * Description : The Salt - Mini Cart — frontend styles.
 *               Global reset → structural layout →
 *               component styles. All visual values
 *               overrideable via Elementor controls.
 * Author      : The Salt
 * Updated     : 2026-05-06
 * ================================================
 */

/* =========================================================================
   Focus ring reset — must come first so !important beats any theme/Elementor
   rules that add outlines back on interactive states.
   ========================================================================= */

.ts-mini-cart button:focus,
.ts-mini-cart button:focus-visible,
.ts-mini-cart button:focus-within,
.ts-mini-cart button:hover,
.ts-mini-cart input:focus,
.ts-mini-cart input:focus-visible,
.ts-mini-cart a:focus,
.ts-mini-cart a:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

/* =========================================================================
   Global styles reset
   Neutralizes theme / Elementor global button, input and link styles.
   ========================================================================= */

.ts-mini-cart button,
.ts-mini-cart input[type="button"],
.ts-mini-cart input[type="submit"],
.ts-mini-cart .ts-mini-cart__btn,
.ts-mini-cart .ts-mini-cart__qty-btn,
.ts-mini-cart .ts-mini-cart__coupon-btn,
.ts-mini-cart .ts-mini-cart__remove,
.ts-mini-cart .ts-mini-cart__coupon-remove {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    border: none !important;
    border-radius: 0;
    outline: none !important;
    background: transparent;
    background-image: none;
    box-shadow: none !important;
    text-decoration: none;
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    font-style: inherit;
    line-height: inherit;
    letter-spacing: inherit;
    text-transform: none;
    color: inherit;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    transition: none;
    width: auto;
    height: auto;
    min-width: 0;
    min-height: 0;
}

.ts-mini-cart input[type="text"],
.ts-mini-cart input[type="number"],
.ts-mini-cart .ts-mini-cart__coupon-input,
.ts-mini-cart .ts-mini-cart__qty-input {
    box-sizing: border-box;
    margin: 0;
    border: none;
    border-radius: 0;
    outline: none;
    background: transparent;
    background-image: none;
    box-shadow: none;
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
    letter-spacing: inherit;
    color: inherit;
    appearance: none;
    -webkit-appearance: none;
    width: auto;
    height: auto;
    min-width: 0;
}

.ts-mini-cart a,
.ts-mini-cart .ts-mini-cart__btn {
    text-decoration: none;
    color: inherit;
    background: transparent;
    box-shadow: none;
    border: none;
    padding: 0;
}

/* =========================================================================
   Icon spans — universal sizing for SVG and icon-font (Font Awesome) icons
   injected by PHP / JS into .ts-mc-icon spans.
   Without explicit dimensions SVG defaults to 300×150px browser default,
   which overflows the button and gets clipped by overflow:hidden.
   ========================================================================= */

.ts-mc-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none;
}

/* SVG from media library or inline — default 1em × 1em, visually correct */
.ts-mc-icon svg {
    display: block;
    width: 1em;
    height: 1em;
    overflow: visible;
    pointer-events: none;
}

/* Font Awesome / icon font <i> elements */
.ts-mc-icon i {
    display: block;
    font-style: normal;
    line-height: 1;
    pointer-events: none;
}

/* =========================================================================
   Wrapper
   ========================================================================= */

.ts-mini-cart {
    position: relative;
    width: 100%;
}

/* =========================================================================
   Loading overlay
   ========================================================================= */

.ts-mini-cart__overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.75);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    border-radius: inherit;
}

.ts-mini-cart.is-loading .ts-mini-cart__overlay {
    opacity: 1;
    pointer-events: all;
}

.ts-mini-cart__spinner {
    display: block;
    width: 32px;
    height: 32px;
    border: 3px solid rgba(0, 0, 0, 0.12);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: ts-mc-spin 0.7s linear infinite;
}

@keyframes ts-mc-spin {
    to { transform: rotate(360deg); }
}

/* =========================================================================
   Empty state
   ========================================================================= */

.ts-mini-cart__empty {
    padding: 24px 0;
    text-align: center;
    margin: 0;
}

/* =========================================================================
   Product list
   ========================================================================= */

.ts-mini-cart__items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    /* Scroll added dynamically when max-height is set via Elementor control */
}

/* Scrollbar styling */
.ts-mini-cart__items::-webkit-scrollbar {
    width: 4px;
}
.ts-mini-cart__items::-webkit-scrollbar-track {
    background: transparent;
}
.ts-mini-cart__items::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

.ts-mini-cart__item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: flex-start; /* default: top — overridden by Elementor control */
}

/* Remove animation */
.ts-mini-cart__item.is-removing {
    animation: ts-mc-item-out 0.25s ease forwards;
    pointer-events: none;
    overflow: hidden;
}

@keyframes ts-mc-item-out {
    0%   { opacity: 1; transform: translateX(0); }
    100% { opacity: 0; transform: translateX(12px); }
}

/* ---- Thumbnail ---- */

.ts-mini-cart__thumb {
    flex: 0 0 72px;
    width: 72px;
    overflow: hidden; /* clips border-radius on link/img */
}

.ts-mini-cart__thumb img {
    display: block;
    width: 72px;
    height: 72px;
    object-fit: cover;
}

.ts-mini-cart__thumb a {
    display: block;
    line-height: 0;
}

/* ---- Details ---- */

.ts-mini-cart__details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0; /* prevent grid blowout */
}

.ts-mini-cart__name,
.ts-mini-cart__name a {
    text-decoration: none;
    color: inherit;
    overflow-wrap: break-word;
}

.ts-mini-cart__name a:hover {
    text-decoration: underline;
}

/* ---- Variants ---- */

.ts-mini-cart__variants {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ts-mini-cart__variant {
    font-size: 0.8em;
    opacity: 0.7;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

/* ---- Remove button ---- */

.ts-mini-cart__remove {
    all: unset;           /* safe on button, inherits reset above */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: inherit;
    opacity: 0.5;
    transition: opacity 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
    font-size: 16px;      /* controls SVG 1em size */
}

.ts-mini-cart__remove:focus,
.ts-mini-cart__remove:focus-visible {
    outline: none;
    box-shadow: none;
}

.ts-mini-cart__remove:hover {
    opacity: 1;
}

.ts-mini-cart__remove svg,
.ts-mini-cart__remove i {
    pointer-events: none;
    display: block;
}

/* =========================================================================
   Qty controls
   FIX: width: fit-content prevents stretching across the grid cell.
   min-width: 3.5ch on input ensures "999" always fits without layout jump.
   ========================================================================= */

.ts-mini-cart__qty-wrap {
    display: inline-flex;
    align-items: stretch;
    width: fit-content;   /* FIX: do not stretch to grid width */
    align-self: flex-start;
    border: 1px solid currentColor;
    border-radius: 4px;
    overflow: hidden;
}

.ts-mini-cart__qty-btn {
    all: unset;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    line-height: 1;
    flex-shrink: 0;
    transition: background-color 0.15s ease, color 0.15s ease;
    user-select: none;
}

.ts-mini-cart__qty-btn:focus,
.ts-mini-cart__qty-btn:focus-visible,
.ts-mini-cart__qty-btn:focus-within {
    outline: none;
    box-shadow: none;
}

.ts-mini-cart__qty-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.ts-mini-cart input[type="number"].ts-mini-cart__qty-input {
    all: unset;           /* reset cascaded global styles at this specificity level */
    box-sizing: border-box;
    display: block;
    width: 3.5ch;         /* fits "999" in most fonts */
    min-width: 3.5ch;
    height: 32px;         /* overridden by Elementor qty_btn_size control */
    text-align: center;
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
    background: transparent;
    -moz-appearance: textfield;
    appearance: textfield;
    border-left: 1px solid currentColor;
    border-right: 1px solid currentColor;
    cursor: text;
}

.ts-mini-cart__qty-input::-webkit-inner-spin-button,
.ts-mini-cart__qty-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* =========================================================================
   Coupon
   FIX: align-items: stretch makes button match input height exactly.
   ========================================================================= */

.ts-mini-cart__coupon {
    margin-top: 16px;
}

.ts-mini-cart__coupon-row {
    display: flex;
    align-items: stretch; /* FIX: button matches input height */
    gap: 0;
}

.ts-mini-cart__coupon-input {
    flex: 0 0 70%;
    max-width: 70%;
    padding: 8px 10px;
    border: 1px solid currentColor;
    background: transparent;
    font-size: inherit;
    font-family: inherit;
    line-height: 1.4;
}

.ts-mini-cart .ts-mini-cart__coupon-btn {
    flex: 0 0 30%;
    max-width: 30%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    white-space: nowrap;
    cursor: pointer;
    box-sizing: border-box;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.ts-mini-cart__coupon-msg {
    margin: 6px 0 0;
    font-size: 0.875em;
    min-height: 1.2em;
}

.ts-mini-cart__coupon-msg.is-success { color: #2e7d32; }
.ts-mini-cart__coupon-msg.is-error   { color: #c62828; }

.ts-mini-cart__applied-coupons {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ts-mini-cart__coupon-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.8em;
    background-color: rgba(0, 0, 0, 0.07);
}

.ts-mini-cart__coupon-remove {
    all: unset;
    cursor: pointer;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.15s ease;
}

.ts-mini-cart__coupon-remove:hover { opacity: 1; }

/* =========================================================================
   Footer — subtotal + action buttons
   ========================================================================= */

/* __inner is always a flex column so margin-top: auto on footer works
   as soon as a height is set via the Elementor cart_height control. */
.ts-mini-cart__inner {
    display: flex;
    flex-direction: column;
}

.ts-mini-cart__footer {
    margin-top: auto;  /* pushes footer to bottom when __inner has defined height */
    padding-top: 20px; /* replaces old margin-top: 20px */
    display: flex;
    flex-direction: column;
    /* gap between subtotal and buttons set via Elementor control */
}

/* Sticky footer — activated via .has-sticky-footer on wrapper */
.has-sticky-footer .ts-mini-cart__footer {
    position: sticky;
    bottom: 0;
    z-index: 2;
}

/* ---- Dividers ---- */
/* Invisible by default — colour + height set via Elementor controls. */
.ts-mini-cart__divider {
    width: 100%;
    height: 0;
    border: none;
    background-color: transparent;
    flex-shrink: 0;
}

.ts-mini-cart__subtotal {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 12px 0;
}

.ts-mini-cart__discount {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 4px 0;
}

.ts-mini-cart__discount-value {
    color: inherit;
}

.ts-mini-cart__actions {
    display: flex;
    flex-direction: column; /* default: stacked — changed via Elementor select */
    gap: 8px;
}

/* When inline layout is selected, stretch buttons equally */
.ts-mini-cart__actions[style*="row"] .ts-mini-cart__btn,
.ts-mini-cart__actions[style*="flex-direction: row"] .ts-mini-cart__btn {
    flex: 1 1 0;
}

.ts-mini-cart__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 12px 20px;
    text-decoration: none;
    font-weight: 600;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
    box-sizing: border-box;
}

/* Default appearances — overridden by Elementor controls */
.ts-mini-cart__btn--cart {
    border: 1px solid currentColor;
}

.ts-mini-cart__btn--checkout {
    border: 1px solid transparent;
}

/* =========================================================================
   Cart icon badge
   .ts-cart-badge-wrap  — injected by JS around .ts-cart-icon elements
   .ts-cart-count       — the number bubble; all visual styles controlled
                          via global Elementor selectors in the widget
   ========================================================================= */

.ts-cart-badge-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ts-cart-count {
    position: absolute;
    top: -6px;
    right: -6px;
    z-index: 1;
    /* Layout */
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    box-sizing: border-box;
    /* Default visual — overridden by Elementor controls */
    background-color: #000;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    border-radius: 999px;
    /* Animation */
    transition: transform 0.15s ease, opacity 0.15s ease;
    transform-origin: center;
    pointer-events: none;
    /* Hide when 0 */
    &:empty {
        transform: scale(0);
        opacity: 0;
    }
}

.ts-cart-count.is-zero {
    transform: scale(0);
    opacity: 0;
}
