/**
 * Vignette Currency Converter - Frontend Styles
 * Version 1.4.0 - Popup selector
 */

/* =====================================================
   Trigger (collapsed state)
   ===================================================== */

.vcc-currency-selector-wrapper {
    display: inline-flex;
    align-items: center;
}

.vcc-currency-trigger {
    display: inline-block;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    font-weight: inherit;
    color: inherit;
    background: transparent;
    border: none;
    padding: 0;
    line-height: inherit;
    user-select: none;
    -webkit-user-select: none;
}

.vcc-currency-trigger:hover {
    opacity: 0.75;
    text-decoration: underline;
}

.vcc-currency-trigger:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
    border-radius: 2px;
}

/* Global selector rendered in footer — inherits theme nav styles */
.vcc-currency-selector-wrapper.vcc-global-selector {
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

/* Inline shortcode/widget selector */
.vcc-currency-selector-wrapper.vcc-inline-selector {
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

/* =====================================================
   Popup Overlay
   ===================================================== */

#vcc-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

/* Prevent body scroll when popup is open */
body.vcc-popup-open {
    overflow: hidden;
}

/* =====================================================
   Popup Panel
   ===================================================== */

.vcc-popup {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 520px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Popup Header */
.vcc-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e8e8e8;
    flex-shrink: 0;
}

.vcc-popup-title {
    font-size: 16px;
    font-weight: 600;
    color: #111;
    margin: 0;
}

.vcc-popup-close {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}

.vcc-popup-close:hover {
    background: #f0f0f0;
    color: #111;
}

/* =====================================================
   Currency Grid
   ===================================================== */

.vcc-popup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    overflow-y: auto;
    flex: 1;
}

.vcc-popup-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.12s;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

/* Right-column options get a left border to act as column divider */
.vcc-popup-option:nth-child(even) {
    border-left: 1px solid #f0f0f0;
}

.vcc-popup-option:hover {
    background: #f7f7f7;
}

.vcc-popup-option:focus {
    outline: none;
    background: #eef4ff;
}

/* Selected state */
.vcc-popup-option.vcc-selected {
    background: #f0f6ff;
}

.vcc-popup-option.vcc-selected .vcc-popup-name {
    font-weight: 600;
    color: #1a1a1a;
}

/* Flag */
.vcc-popup-flag {
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
    width: 22px;
    text-align: center;
}

/* Currency name */
.vcc-popup-name {
    font-size: 13px;
    color: #333;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Symbol */
.vcc-popup-symbol {
    font-size: 13px;
    font-weight: 600;
    color: #555;
    flex-shrink: 0;
}

/* Checkmark — hidden by default, shown when selected */
.vcc-popup-check {
    font-size: 14px;
    color: #2271b1;
    opacity: 0;
    flex-shrink: 0;
    transition: opacity 0.1s;
}

.vcc-popup-option.vcc-selected .vcc-popup-check {
    opacity: 1;
}

/* =====================================================
   Price Display
   ===================================================== */

.vcc-converted-price {
    font-weight: 600;
    color: #2271b1;
}

/* =====================================================
   Cart / Checkout Notice
   ===================================================== */

.vcc-currency-info th {
    padding: 10px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
}

/* =====================================================
   Loading Animation
   ===================================================== */

@keyframes vcc-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}

.vcc-loading {
    font-size: 12px;
    color: #666;
    font-style: italic;
    animation: vcc-pulse 1.5s ease-in-out infinite;
}

/* =====================================================
   Mobile
   ===================================================== */

@media (max-width: 480px) {
    #vcc-popup-overlay {
        padding: 12px;
        align-items: flex-end;
    }

    .vcc-popup {
        max-width: 100%;
        max-height: 90vh;
        border-radius: 12px 12px 0 0;
    }

    .vcc-popup-grid {
        grid-template-columns: 1fr;
    }

    /* Remove left-border "column divider" on mobile single-column */
    .vcc-popup-option:nth-child(even) {
        border-left: none;
    }
}

/* =====================================================
   Dark Mode Support
   ===================================================== */

@media (prefers-color-scheme: dark) {
    .vcc-popup {
        background: #1e1e1e;
        box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    }

    .vcc-popup-header {
        border-bottom-color: #333;
    }

    .vcc-popup-title {
        color: #f0f0f0;
    }

    .vcc-popup-close {
        color: #aaa;
    }

    .vcc-popup-close:hover {
        background: #2a2a2a;
        color: #f0f0f0;
    }

    .vcc-popup-option {
        border-bottom-color: #2a2a2a;
    }

    .vcc-popup-option:nth-child(even) {
        border-left-color: #2a2a2a;
    }

    .vcc-popup-option:hover {
        background: #2a2a2a;
    }

    .vcc-popup-option:focus {
        background: #1d2a3a;
    }

    .vcc-popup-option.vcc-selected {
        background: #162033;
    }

    .vcc-popup-name {
        color: #ccc;
    }

    .vcc-popup-option.vcc-selected .vcc-popup-name {
        color: #f0f0f0;
    }

    .vcc-popup-symbol {
        color: #aaa;
    }

    .vcc-popup-check {
        color: #5b9bd5;
    }

    .vcc-loading {
        color: #999;
    }
}
