/**
 * Zadwa Network — Currency Switcher & Amount Display v2.4.0
 * Design: clean, symmetric, no icon clutter.
 * Search is secondary — list scrolls first.
 */

/* ═══════════════════════════════════════════════════
   0. COMPANION BAR MODE — safety suppression
   When currency lives in the AI Companion bar, the
   standalone floating pill must never appear on any
   screen size. PHP suppresses the HTML; CSS is a
   belt-and-suspenders fallback for cached pages.
══════════════════════════════════════════════════ */
#zn-currency-switcher.zn-cs-companion-bar-mode,
body.zn-companion-bar-currency #zn-currency-switcher {
    display: none !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

@media (max-width: 782px) {
    /* Mobile — extra specificity in case theme overrides */
    #zn-currency-switcher.zn-cs-companion-bar-mode {
        display: none !important;
    }
}

/* ═══════════════════════════════════════════════════
   1. FLOATING CONTAINER
═══════════════════════════════════════════════════ */
#zn-currency-switcher {
    position: fixed;
    bottom: 24px;
    left: 20px;
    z-index: 9990;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
}
#zn-currency-switcher.zn-cs-pos--bottom-right { left: auto; right: 20px; }

/* ═══════════════════════════════════════════════════
   2. TRIGGER BUTTON
═══════════════════════════════════════════════════ */
#zn-currency-switcher .zn-cs-trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px 9px 11px;
    background: #1e293b;
    color: #f1f5f9;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(0,0,0,0.26), 0 1px 4px rgba(0,0,0,0.12);
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
    white-space: nowrap;
    outline: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
#zn-currency-switcher .zn-cs-trigger:hover {
    background: #0f172a;
    transform: translateY(-1px);
    box-shadow: 0 6px 22px rgba(0,0,0,0.30);
}
#zn-currency-switcher .zn-cs-trigger:focus-visible {
    outline: 2px solid #0d9488;
    outline-offset: 2px;
}
#zn-currency-switcher .zn-cs-trigger:active { transform: none; }

/* Size variants */
#zn-currency-switcher.zn-cs-size--compact .zn-cs-trigger { padding: 6px 10px; font-size: 12px; }
#zn-currency-switcher.zn-cs-size--compact .zn-cs-flag    { font-size: 14px; }
#zn-currency-switcher.zn-cs-size--large  .zn-cs-trigger  { padding: 11px 17px; font-size: 15px; }
#zn-currency-switcher.zn-cs-size--large  .zn-cs-flag     { font-size: 20px; }

.zn-cs-flag    { font-size: 18px; line-height: 1; flex-shrink: 0; }
.zn-cs-code    { font-size: 13px; font-weight: 700; color: #94a3b8; min-width: 28px; letter-spacing: 0.02em; }
.zn-cs-chevron {
    width: 14px; height: 14px; opacity: 0.6; flex-shrink: 0;
    transition: transform 0.18s ease;
}
#zn-currency-switcher .zn-cs-trigger[aria-expanded="true"] .zn-cs-chevron {
    transform: rotate(180deg);
}

/* ═══════════════════════════════════════════════════
   3. DROPDOWN PANEL
═══════════════════════════════════════════════════ */
#zn-currency-switcher .zn-cs-panel {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 0;
    width: 272px;
    max-height: 368px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.14), 0 4px 14px rgba(0,0,0,0.07);
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
}
#zn-currency-switcher.zn-cs-pos--bottom-right .zn-cs-panel { left: auto; right: 0; }

/* Scrollbar */
#zn-currency-switcher .zn-cs-panel::-webkit-scrollbar { width: 4px; }
#zn-currency-switcher .zn-cs-panel::-webkit-scrollbar-thumb {
    background: #e2e8f0; border-radius: 4px;
}

/* ── Search bar (sticky top) ── */
#zn-currency-switcher .zn-cs-search-wrap {
    position: sticky;
    top: 0;
    background: #fff;
    padding: 10px 12px 8px;
    border-bottom: 1px solid #f1f5f9;
    z-index: 1;
    flex-shrink: 0;
}
#zn-currency-switcher .zn-cs-search {
    width: 100%;
    box-sizing: border-box;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 13px;
    font-weight: 400;
    color: #1e293b;
    background: #f8fafc;
    outline: none;
    transition: border-color 0.14s;
}
#zn-currency-switcher .zn-cs-search:focus {
    border-color: #0d9488;
    background: #fff;
}
#zn-currency-switcher .zn-cs-search::placeholder { color: #94a3b8; }

/* ── Currency options ── */
#zn-currency-switcher .zn-cs-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 11px 14px;
    background: transparent;
    border: none;
    border-bottom: 1px solid #f8fafc;
    cursor: pointer;
    text-align: left;
    color: #1e293b;
    transition: background 0.1s;
}
#zn-currency-switcher .zn-cs-option:last-of-type { border-bottom: none; }
#zn-currency-switcher .zn-cs-option:hover        { background: #f8fafc; }
#zn-currency-switcher .zn-cs-option:focus-visible {
    outline: 2px solid #0d9488; outline-offset: -2px; background: #f0fdfb;
}
#zn-currency-switcher .zn-cs-option.zn-cs-active {
    background: #f0fdfb; color: #0d9488;
}

#zn-currency-switcher .zn-cs-option .zn-cs-flag { font-size: 20px; flex-shrink: 0; }
#zn-currency-switcher .zn-cs-option .zn-cs-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: inherit;
}
#zn-currency-switcher .zn-cs-option .zn-cs-sym {
    font-size: 12px;
    font-weight: 700;
    color: #94a3b8;
    min-width: 24px;
    text-align: right;
    flex-shrink: 0;
}
#zn-currency-switcher .zn-cs-option .zn-cs-rate {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    min-width: 44px;
    text-align: right;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}
#zn-currency-switcher .zn-cs-option .zn-cs-check {
    font-size: 13px;
    font-weight: 700;
    color: #0d9488;
    min-width: 14px;
    text-align: right;
    flex-shrink: 0;
}
#zn-currency-switcher .zn-cs-option.zn-cs-active .zn-cs-rate,
#zn-currency-switcher .zn-cs-option.zn-cs-active .zn-cs-sym { color: #0d9488; }

/* ── Footer (sticky bottom) ── */
#zn-currency-switcher .zn-cs-footer {
    position: sticky;
    bottom: 0;
    padding: 8px 14px;
    font-size: 11px;
    color: #94a3b8;
    border-top: 1px solid #f1f5f9;
    background: #f8fafc;
    text-align: center;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════
   4. INLINE PILLS  [zn_currency_switcher]
═══════════════════════════════════════════════════ */
.zn-currency-switcher.zn-cs-inline { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.zn-currency-switcher .zn-cs-pill {
    display: inline-flex;
    align-items: center;
    padding: 5px 13px;
    border: 1.5px solid #e2e8f0;
    border-radius: 999px;
    background: #fff;
    color: #475569;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.13s;
    letter-spacing: 0.03em;
    -webkit-tap-highlight-color: transparent;
}
.zn-currency-switcher .zn-cs-pill:hover        { border-color: #0d9488; color: #0d9488; background: #f0fdfb; }
.zn-currency-switcher .zn-cs-pill.zn-cs-active { background: #0d9488; border-color: #0d9488; color: #fff; }
.zn-currency-switcher .zn-cs-pill.zn-cs-loading { opacity: 0.5; pointer-events: none; }

/* ═══════════════════════════════════════════════════
   5. AMOUNT BRACKETS
═══════════════════════════════════════════════════ */
.zn-currency-amount   { display: inline; white-space: nowrap; }
.zn-currency-secondary {
    display: inline;
    font-size: 0.76em;
    color: #94a3b8;
    font-weight: 400;
    margin-left: 3px;
    white-space: nowrap;
}
.price .zn-currency-secondary,
.woocommerce-Price-amount .zn-currency-secondary { font-size: 0.70em; }
.zn-reward-amount .zn-currency-secondary {
    display: block;
    font-size: 0.74em;
    color: #94a3b8;
    margin-top: 2px;
}

/* ═══════════════════════════════════════════════════
   6. LOADING / PULSE
═══════════════════════════════════════════════════ */
.zn-cs-option.zn-cs-loading { opacity: 0.6; pointer-events: none; }

@keyframes zn-cs-pulse-ring {
    0%   { box-shadow: 0 0 0 0 rgba(13,148,136,0.55); }
    70%  { box-shadow: 0 0 0 14px rgba(13,148,136,0); }
    100% { box-shadow: 0 0 0 0 rgba(13,148,136,0); }
}
#zn-currency-switcher.zn-cs-pulse .zn-cs-trigger {
    animation: zn-cs-pulse-ring 0.8s ease-out 3;
    background: #0d9488;
    color: #fff;
}
#zn-currency-switcher.zn-cs-pulse .zn-cs-code { color: rgba(255,255,255,0.8); }

/* ═══════════════════════════════════════════════════
   7. RESPONSIVE
═══════════════════════════════════════════════════ */
@media (max-width: 480px) {
    #zn-currency-switcher                              { bottom: 16px; left: 12px; }
    #zn-currency-switcher.zn-cs-pos--bottom-right      { left: auto; right: 12px; }
    #zn-currency-switcher .zn-cs-panel                 { width: 252px; max-height: 296px; }
}
/* Clear WooCommerce floating bar on mobile */
@media (max-width: 768px) {
    #zn-currency-switcher { bottom: 72px; }
}
