/**
 * ZN Currency Engine — Frontend Styles
 * Version: 1.0.0
 *
 * Styles the global floating currency switcher, inline pills,
 * and currency amount display helpers.
 */

/* ── CSS Custom Properties ──────────────────────────────────────── */
:root {
    --zn-cs-bg:         #ffffff;
    --zn-cs-border:     #e2e8f0;
    --zn-cs-shadow:     0 8px 24px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.08);
    --zn-cs-trigger-bg: #1a1a2e;
    --zn-cs-trigger-fg: #ffffff;
    --zn-cs-active-bg:  #f0f9ff;
    --zn-cs-active-border: #0ea5e9;
    --zn-cs-hover-bg:   #f8fafc;
    --zn-cs-text:       #1e293b;
    --zn-cs-muted:      #64748b;
    --zn-cs-radius:     10px;
    --zn-cs-transition: 0.18s ease;
    --zn-cs-z:          9999;
}

/* ════════════════════════════════════════════════════════════════
   FLOATING SWITCHER WRAPPER
════════════════════════════════════════════════════════════════ */
#zn-currency-switcher {
    position: fixed;
    bottom: var(--zn-cs-bottom, 80px);
    left: 20px;
    right: auto;
    z-index: var(--zn-cs-z);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
}
/* Position variants */
#zn-currency-switcher.zn-cs-pos--bottom-right {
    left: auto;
    right: 20px;
}
/* Size variants */
#zn-currency-switcher.zn-cs-size--compact .zn-cs-trigger {
    padding: 6px 10px 6px 8px;
    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: 10px 16px 10px 12px;
    font-size: 14px;
}
/* Panel opens upward (above trigger) */
#zn-currency-switcher .zn-cs-panel {
    bottom: calc(100% + 8px);
    top: auto !important;
    left: 0;
    right: auto;
}
#zn-currency-switcher.zn-cs-pos--bottom-right .zn-cs-panel {
    left: auto;
    right: 0;
}

/* ── Trigger button ─────────────────────────────────────────────── */
.zn-cs-trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--zn-cs-trigger-bg);
    color: var(--zn-cs-trigger-fg);
    border: none;
    border-radius: 24px;
    padding: 8px 14px 8px 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .3px;
    box-shadow: 0 2px 12px rgba(0,0,0,.2);
    transition: background var(--zn-cs-transition), transform var(--zn-cs-transition);
    white-space: nowrap;
    user-select: none;
}

.zn-cs-trigger:hover {
    background: #2d2d4e;
    transform: translateY(-1px);
}

.zn-cs-trigger:active {
    transform: translateY(0);
}

.zn-cs-flag {
    font-size: 18px;
    line-height: 1;
}

.zn-cs-code {
    font-size: 13px;
    font-weight: 700;
}

.zn-cs-chevron {
    transition: transform var(--zn-cs-transition);
    opacity: .7;
}

.zn-cs-trigger[aria-expanded="true"] .zn-cs-chevron {
    transform: rotate(180deg);
}

/* ── Panel ──────────────────────────────────────────────────────── */
.zn-cs-panel {
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    width: 280px;
    max-height: 420px;
    background: var(--zn-cs-bg);
    border: 1px solid var(--zn-cs-border);
    border-radius: var(--zn-cs-radius);
    box-shadow: var(--zn-cs-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: znCsSlideIn var(--zn-cs-transition) forwards;
}

@keyframes znCsSlideIn {
    from { opacity: 0; transform: translateY(8px) scale(.97); }
    to   { opacity: 1; transform: translateY(0)  scale(1);    }
}

/* ── Search ─────────────────────────────────────────────────────── */
.zn-cs-search-wrap {
    padding: 10px 12px 8px;
    border-bottom: 1px solid var(--zn-cs-border);
    flex-shrink: 0;
}

.zn-cs-search {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--zn-cs-border);
    border-radius: 6px;
    font-size: 13px;
    color: var(--zn-cs-text);
    outline: none;
    box-sizing: border-box;
    transition: border-color var(--zn-cs-transition);
}

.zn-cs-search:focus {
    border-color: var(--zn-cs-active-border);
    box-shadow: 0 0 0 3px rgba(14,165,233,.12);
}

/* ── List ───────────────────────────────────────────────────────── */
.zn-cs-list {
    list-style: none;
    margin: 0;
    padding: 6px 0;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.zn-cs-list li {
    margin: 0;
    padding: 0;
}

/* ── Option button ──────────────────────────────────────────────── */
.zn-cs-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 14px;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background var(--zn-cs-transition);
    color: var(--zn-cs-text);
}

.zn-cs-option:hover,
.zn-cs-option:focus {
    background: var(--zn-cs-hover-bg);
    outline: none;
}

.zn-cs-option--active {
    background: var(--zn-cs-active-bg) !important;
}

.zn-cs-option-flag {
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.zn-cs-option-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.zn-cs-option-code {
    font-size: 13px;
    font-weight: 700;
    color: var(--zn-cs-text);
    display: block;
}

.zn-cs-option-name {
    font-size: 11px;
    color: var(--zn-cs-muted);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.zn-cs-option-rate {
    font-size: 11px;
    color: var(--zn-cs-muted);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    text-align: right;
    min-width: 40px;
}

.zn-cs-check {
    flex-shrink: 0;
    color: var(--zn-cs-active-border);
}

/* ── Footer ─────────────────────────────────────────────────────── */
.zn-cs-footer {
    padding: 8px 14px;
    border-top: 1px solid var(--zn-cs-border);
    background: #f8fafc;
    flex-shrink: 0;
}

.zn-cs-rate-info {
    font-size: 11px;
    color: var(--zn-cs-muted);
}

/* ════════════════════════════════════════════════════════════════
   INLINE SHORTCODE SWITCHER [zn_currency_switcher]
════════════════════════════════════════════════════════════════ */
.zn-cs-inline {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.zn-cs-pill {
    padding: 5px 12px;
    border: 1.5px solid var(--zn-cs-border);
    border-radius: 20px;
    background: var(--zn-cs-bg);
    color: var(--zn-cs-text);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--zn-cs-transition);
    letter-spacing: .3px;
}

.zn-cs-pill:hover {
    border-color: var(--zn-cs-active-border);
    color: var(--zn-cs-active-border);
}

.zn-cs-pill--active,
.zn-cs-pill.active {
    background: var(--zn-cs-trigger-bg);
    border-color: var(--zn-cs-trigger-bg);
    color: #ffffff;
}

/* ════════════════════════════════════════════════════════════════
   AMOUNT DISPLAY HELPERS
════════════════════════════════════════════════════════════════ */
.zn-currency-amount {
    /* Wrapper set by ZN_Currency_Engine::format() */
    display: inline;
}

.zn-currency-secondary {
    font-size: .85em;
    color: var(--zn-cs-muted);
    margin-left: 4px;
    font-weight: 400;
}

/* ════════════════════════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    #zn-currency-switcher {
        bottom: 70px;
        right: 12px;
    }

    .zn-cs-panel {
        width: 260px;
        right: -4px;
    }
}

/* ── Ensure the switcher clears WooCommerce bottom bar ─────────── */
@media (max-width: 768px) {
    #zn-currency-switcher {
        bottom: 90px; /* above mobile checkout bar if present */
    }
}

/* ── Dark mode support ──────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    :root {
        --zn-cs-bg:           #1e293b;
        --zn-cs-border:       #334155;
        --zn-cs-text:         #f1f5f9;
        --zn-cs-muted:        #94a3b8;
        --zn-cs-hover-bg:     #0f172a;
        --zn-cs-active-bg:    #0f172a;
        --zn-cs-trigger-bg:   #0ea5e9;
        --zn-cs-trigger-fg:   #ffffff;
    }

    .zn-cs-search {
        background: #0f172a;
        color: #f1f5f9;
    }

    .zn-cs-footer {
        background: #0f172a;
    }
}
