/* TejCart Currency Switcher — front-end styles.
 *
 * Every dropdown / sidebar rule is **double-scoped** so it beats common
 * theme rules like Astra's `.entry-content ul li` (specificity 0,1,2)
 * that would otherwise inject left-indent, bullets, and an unwanted
 * line-height into the option list. We pair the root class with each
 * child class (e.g. `.tejcart-csw-dropdown .tejcart-csw-dropdown__list`)
 * which yields 0,2,0 — enough to win against ancestor-class theme rules
 * without resorting to `!important` on layout properties.
 *
 * The few `!important` declarations below are reserved for two things
 * themes are notorious for forcing onto every `<li>`:
 *   1. list bullets / numbering via `::marker` and `::before`
 *   2. extra `padding-left` on the parent `<ul>`
 * Those two stay non-negotiable.
 */

.tejcart-csw-dropdown,
.tejcart-csw-sidebar {
    --tejcart-csw-bg: #ffffff;
    --tejcart-csw-fg: #111827;
    --tejcart-csw-muted: #6b7280;
    --tejcart-csw-border: #e5e7eb;
    --tejcart-csw-border-strong: #d1d5db;
    --tejcart-csw-hover: #f9fafb;
    --tejcart-csw-active: #eef2ff;
    --tejcart-csw-active-fg: #4338ca;
    --tejcart-csw-ring: rgba(79, 70, 229, 0.22);
    --tejcart-csw-shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.06);
    --tejcart-csw-shadow-md: 0 12px 28px -10px rgba(17, 24, 39, 0.18), 0 4px 10px -4px rgba(17, 24, 39, 0.08);
    --tejcart-csw-radius: 10px;
    --tejcart-csw-radius-sm: 6px;
    --tejcart-csw-flag-radius: 3px;
    --tejcart-csw-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    box-sizing: border-box;
    color: var(--tejcart-csw-fg);
    font-family: var(--tejcart-csw-font);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.2;
}

.tejcart-csw-dropdown *,
.tejcart-csw-dropdown *::before,
.tejcart-csw-dropdown *::after,
.tejcart-csw-sidebar *,
.tejcart-csw-sidebar *::before,
.tejcart-csw-sidebar *::after {
    box-sizing: border-box;
}

@media (prefers-color-scheme: dark) {
    .tejcart-csw-dropdown,
    .tejcart-csw-sidebar {
        --tejcart-csw-bg: #0f172a;
        --tejcart-csw-fg: #e2e8f0;
        --tejcart-csw-muted: #94a3b8;
        --tejcart-csw-border: #1f2937;
        --tejcart-csw-border-strong: #334155;
        --tejcart-csw-hover: #111c33;
        --tejcart-csw-active: #1e293b;
        --tejcart-csw-active-fg: #a5b4fc;
        --tejcart-csw-ring: rgba(165, 180, 252, 0.28);
        --tejcart-csw-shadow-md: 0 12px 28px -10px rgba(0, 0, 0, 0.55), 0 4px 10px -4px rgba(0, 0, 0, 0.4);
    }
}

/* --- shared flag chip -------------------------------------------------- */

.tejcart-csw-dropdown .tejcart-csw-flag-svg,
.tejcart-csw-sidebar .tejcart-csw-flag-svg {
    display: block;
    width: 100%;
    height: 100%;
}

.tejcart-csw-dropdown .tejcart-csw-dropdown__flag,
.tejcart-csw-sidebar .tejcart-csw-sidebar__flag {
    display: inline-flex;
    flex: 0 0 auto;
    width: 22px;
    height: 16px;
    overflow: hidden;
    border-radius: var(--tejcart-csw-flag-radius);
    background: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(17, 24, 39, 0.10);
    line-height: 0;
}

/* --- dropdown ---------------------------------------------------------- */

.tejcart-csw-dropdown {
    position: relative;
    display: inline-block;
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
    text-align: left;
    vertical-align: middle;
}

.tejcart-csw-dropdown .tejcart-csw-dropdown__select {
    /* Hidden visually; preserved for non-JS / screen-reader fallback. */
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.tejcart-csw-dropdown .tejcart-csw-dropdown__trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 7px 10px 7px 9px;
    width: auto;
    min-height: 36px;
    background: var(--tejcart-csw-bg);
    border: 1px solid var(--tejcart-csw-border-strong);
    border-radius: var(--tejcart-csw-radius);
    box-shadow: var(--tejcart-csw-shadow-sm);
    color: var(--tejcart-csw-fg);
    font-family: var(--tejcart-csw-font);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.01em;
    text-transform: none;
    text-decoration: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
    transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease, transform 140ms ease;
}

.tejcart-csw-dropdown .tejcart-csw-dropdown__trigger:hover {
    background: var(--tejcart-csw-hover);
    border-color: var(--tejcart-csw-border-strong);
    box-shadow: var(--tejcart-csw-shadow-sm), 0 2px 6px rgba(17, 24, 39, 0.06);
}

.tejcart-csw-dropdown .tejcart-csw-dropdown__trigger:focus {
    outline: none;
}

.tejcart-csw-dropdown .tejcart-csw-dropdown__trigger:focus-visible {
    outline: none;
    border-color: var(--tejcart-csw-active-fg);
    box-shadow: 0 0 0 3px var(--tejcart-csw-ring);
}

.tejcart-csw-dropdown .tejcart-csw-dropdown__trigger:active {
    transform: translateY(1px);
}

.tejcart-csw-dropdown.is-open .tejcart-csw-dropdown__trigger {
    background: var(--tejcart-csw-bg);
    border-color: var(--tejcart-csw-active-fg);
    box-shadow: 0 0 0 3px var(--tejcart-csw-ring);
}

.tejcart-csw-dropdown .tejcart-csw-dropdown__code {
    display: inline-block;
    color: var(--tejcart-csw-fg);
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.04em;
    line-height: 1;
}

.tejcart-csw-dropdown .tejcart-csw-dropdown__chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 12px;
    height: 12px;
    margin-left: 2px;
    color: var(--tejcart-csw-muted);
    transition: transform 180ms ease, color 140ms ease;
}

.tejcart-csw-dropdown .tejcart-csw-dropdown__chevron svg {
    display: block;
    width: 10px;
    height: 6px;
}

.tejcart-csw-dropdown.is-open .tejcart-csw-dropdown__chevron {
    color: var(--tejcart-csw-active-fg);
    transform: rotate(180deg);
}

/* --- loading state ----------------------------------------------------- */

.tejcart-csw-dropdown.is-loading .tejcart-csw-dropdown__trigger {
    cursor: progress;
    color: transparent;
    pointer-events: none;
}

.tejcart-csw-dropdown.is-loading .tejcart-csw-dropdown__trigger > * {
    visibility: hidden;
}

.tejcart-csw-dropdown.is-loading .tejcart-csw-dropdown__trigger::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid var(--tejcart-csw-border-strong);
    border-top-color: var(--tejcart-csw-active-fg);
    border-radius: 50%;
    visibility: visible;
    animation: tejcartCswSpin 720ms linear infinite;
}

.tejcart-csw-dropdown .tejcart-csw-dropdown__trigger {
    position: relative;
}

.tejcart-csw-dropdown.is-loading .tejcart-csw-dropdown__list {
    pointer-events: none;
    opacity: 0.85;
}

.tejcart-csw-dropdown.is-loading .tejcart-csw-dropdown__option {
    cursor: progress;
}

.tejcart-csw-dropdown.is-loading .tejcart-csw-dropdown__option.is-active {
    position: relative;
}

.tejcart-csw-dropdown.is-loading .tejcart-csw-dropdown__option.is-active::after {
    content: "";
    flex: 0 0 auto;
    width: 14px;
    height: 14px;
    margin-left: auto;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    opacity: 0.7;
    animation: tejcartCswSpin 720ms linear infinite;
}

@keyframes tejcartCswSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .tejcart-csw-dropdown.is-loading .tejcart-csw-dropdown__trigger::after,
    .tejcart-csw-dropdown.is-loading .tejcart-csw-dropdown__option.is-active::after {
        animation-duration: 1800ms;
    }
}

/* --- dropdown list ---------------------------------------------------- */

/* Double-up the class to beat `.entry-content ul` etc. */
.tejcart-csw-dropdown ul.tejcart-csw-dropdown__list,
.tejcart-csw-dropdown .tejcart-csw-dropdown__list {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 1000;
    margin: 0 !important;
    padding: 6px !important;
    min-width: 260px;
    max-height: 320px;
    overflow-y: auto;
    background: var(--tejcart-csw-bg);
    border: 1px solid var(--tejcart-csw-border);
    border-radius: var(--tejcart-csw-radius);
    box-shadow: var(--tejcart-csw-shadow-md);
    list-style: none !important;
    text-align: left;
    animation: tejcartCswDropdownIn 140ms ease-out;
}

.tejcart-csw-dropdown .tejcart-csw-dropdown__list[hidden] {
    display: none;
}

@keyframes tejcartCswDropdownIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.tejcart-csw-dropdown li.tejcart-csw-dropdown__option,
.tejcart-csw-dropdown .tejcart-csw-dropdown__option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin: 0 !important;
    padding: 8px 10px !important;
    border: 0;
    border-radius: var(--tejcart-csw-radius-sm);
    background: transparent;
    color: var(--tejcart-csw-fg);
    font-family: var(--tejcart-csw-font);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    text-align: left;
    text-indent: 0;
    cursor: pointer;
    user-select: none;
    list-style: none !important;
    transition: background-color 120ms ease, color 120ms ease;
}

.tejcart-csw-dropdown .tejcart-csw-dropdown__option::before,
.tejcart-csw-dropdown .tejcart-csw-dropdown__option::marker {
    /* Defeat block-theme bullet pseudo-elements. */
    content: none !important;
    display: none !important;
}

.tejcart-csw-dropdown .tejcart-csw-dropdown__option:hover,
.tejcart-csw-dropdown .tejcart-csw-dropdown__option.is-focus {
    background: var(--tejcart-csw-hover);
}

.tejcart-csw-dropdown .tejcart-csw-dropdown__option.is-active {
    background: var(--tejcart-csw-active);
    color: var(--tejcart-csw-active-fg);
}

.tejcart-csw-dropdown .tejcart-csw-dropdown__option .tejcart-csw-dropdown__code {
    flex: 0 0 auto;
    width: 44px;
    min-width: 44px;
    color: inherit;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.06em;
    line-height: 1.2;
}

.tejcart-csw-dropdown .tejcart-csw-dropdown__option .tejcart-csw-dropdown__name {
    flex: 1 1 auto;
    overflow: hidden;
    color: var(--tejcart-csw-muted);
    font-weight: 400;
    font-size: 14px;
    letter-spacing: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tejcart-csw-dropdown .tejcart-csw-dropdown__option.is-active .tejcart-csw-dropdown__name {
    color: var(--tejcart-csw-active-fg);
}

.tejcart-csw-dropdown .tejcart-csw-dropdown__submit {
    /* Only shown inside <noscript>. Keep it minimally styled. */
    margin-top: 6px;
    padding: 6px 10px;
    background: var(--tejcart-csw-active-fg);
    border: 0;
    border-radius: var(--tejcart-csw-radius-sm);
    color: #ffffff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

/* Inline-on-product-summary placement: a bit of breathing room above the
 * stock badge and add-to-cart button so the trigger reads as its own row
 * rather than glued to the price. */
.tejcart-csw-dropdown.tejcart-csw-switcher--product {
    display: inline-flex;
    margin: 14px 0 18px;
}

/* --- sidebar ----------------------------------------------------------- */

.tejcart-csw-sidebar {
    position: fixed;
    top: 30vh;
    z-index: 999;
    padding: 6px;
    background: var(--tejcart-csw-bg);
    border: 1px solid var(--tejcart-csw-border);
    border-radius: var(--tejcart-csw-radius);
    box-shadow: var(--tejcart-csw-shadow-md);
    font-size: 13px;
}

.tejcart-csw-sidebar.tejcart-csw-sidebar--left  { left: 0;  border-top-left-radius: 0;  border-bottom-left-radius: 0;  border-left-width: 0; }
.tejcart-csw-sidebar.tejcart-csw-sidebar--right { right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; border-right-width: 0; }

.tejcart-csw-sidebar.tejcart-csw-sidebar--compact { padding: 4px; }

.tejcart-csw-sidebar ul.tejcart-csw-sidebar__list,
.tejcart-csw-sidebar .tejcart-csw-sidebar__list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

.tejcart-csw-sidebar li.tejcart-csw-sidebar__item,
.tejcart-csw-sidebar .tejcart-csw-sidebar__item {
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

.tejcart-csw-sidebar .tejcart-csw-sidebar__item::before,
.tejcart-csw-sidebar .tejcart-csw-sidebar__item::marker {
    content: none !important;
    display: none !important;
}

.tejcart-csw-sidebar .tejcart-csw-sidebar__item a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: var(--tejcart-csw-radius-sm);
    color: var(--tejcart-csw-fg);
    text-decoration: none;
    transition: background-color 120ms ease, color 120ms ease;
}

.tejcart-csw-sidebar .tejcart-csw-sidebar__item a:hover,
.tejcart-csw-sidebar .tejcart-csw-sidebar__item a:focus-visible {
    background: var(--tejcart-csw-hover);
    color: var(--tejcart-csw-fg);
    outline: none;
}

.tejcart-csw-sidebar .tejcart-csw-sidebar__item.is-active a {
    background: var(--tejcart-csw-active);
    color: var(--tejcart-csw-active-fg);
    font-weight: 600;
}

.tejcart-csw-sidebar .tejcart-csw-sidebar__code {
    font-weight: 600;
    letter-spacing: 0.04em;
}

.tejcart-csw-sidebar .tejcart-csw-sidebar__symbol {
    margin-left: auto;
    color: var(--tejcart-csw-muted);
    font-variant-numeric: tabular-nums;
}

.tejcart-csw-sidebar.tejcart-csw-sidebar--compact .tejcart-csw-sidebar__item a {
    padding: 4px 6px;
    gap: 6px;
}

.tejcart-csw-sidebar.tejcart-csw-sidebar--compact .tejcart-csw-sidebar__code,
.tejcart-csw-sidebar.tejcart-csw-sidebar--compact .tejcart-csw-sidebar__symbol { display: none; }

/* --- checkout notice (unchanged behaviour, modernised styling) -------- */

.tejcart-csw-checkout-notice {
    margin: 1em 0;
    padding: 0.75em 1em;
    border-left: 4px solid #4338ca;
    background: #eef2ff;
    border-radius: 6px;
    color: inherit;
}

@media (prefers-color-scheme: dark) {
    .tejcart-csw-checkout-notice {
        border-left-color: #a5b4fc;
        background: #1e293b;
    }
}

/* --- responsive -------------------------------------------------------- */

@media (max-width: 480px) {
    .tejcart-csw-dropdown .tejcart-csw-dropdown__list {
        min-width: 220px;
        max-width: calc(100vw - 24px);
    }

    .tejcart-csw-sidebar {
        top: auto;
        bottom: 12px;
        right: 12px;
        left: auto;
        border-radius: var(--tejcart-csw-radius);
        border-width: 1px;
    }

    .tejcart-csw-sidebar.tejcart-csw-sidebar--left,
    .tejcart-csw-sidebar.tejcart-csw-sidebar--right {
        left: auto;
        right: 12px;
        border-radius: var(--tejcart-csw-radius);
        border-width: 1px;
    }
}
