/**
 * WooCommerce Smart Currency Switcher - Frontend Styles
 * Author: Your Name
 * Version: 2.2.0
 */

/* ========== Currency Switcher Wrapper ========== */
.ek-currency-switcher-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    margin: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

/* Currency Flag */
.ek-currency-flag {
    flex-shrink: 0 !important;
    width: 1.33333em !important;
    height: 1em !important;
    min-width: 20px !important;
    min-height: 15px !important;
    display: inline-block !important;
    border-radius: 2px !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;
    vertical-align: middle !important;
    background-size: contain !important;
    background-position: 50% !important;
    background-repeat: no-repeat !important;
    position: relative !important;
}

.ek-currency-flag:before {
    content: "\00a0" !important;
}

/* ========== Currency Label ========== */
.ek-currency-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin: 0;
    cursor: default;
}

.ek-currency-icon {
    font-size: 18px;
    line-height: 1;
}

/* ========== Currency Select ========== */
select.ek-currency-select,
.ek-currency-switcher-wrapper select.ek-currency-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding: 8px 32px 8px 12px;
    font-size: 14px;
    font-weight: 400;
    color: #333;
    background: #fff;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23333" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 18px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    width: 130px !important;
    min-width: 130px !important;
    max-width: 130px !important;
    flex: 0 0 130px !important;
    font-family: "Segoe UI Emoji", "Segoe UI Symbol", "Apple Color Emoji", "Noto Color Emoji", "Twemoji Mozilla", "EmojiOne Color", "Android Emoji", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif !important;
}

select.ek-currency-select:hover,
.ek-currency-switcher-wrapper select.ek-currency-select:hover {
    border-color: #999;
}

select.ek-currency-select:focus,
.ek-currency-switcher-wrapper select.ek-currency-select:focus {
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1);
}

select.ek-currency-select option,
.ek-currency-switcher-wrapper select.ek-currency-select option {
    padding: 8px;
    font-size: 14px;
    font-family: "Segoe UI Emoji", "Segoe UI Symbol", "Apple Color Emoji", "Noto Color Emoji", "Twemoji Mozilla", "EmojiOne Color", "Android Emoji", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif !important;
}

/* ========== Custom Dropdown (SVG Flags) ========== */
.ek-custom-select {
    position: relative;
    width: 130px !important;
    user-select: none;
}

.ek-select-selected {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 32px 8px 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.ek-select-selected:hover {
    border-color: #999;
}

.ek-select-selected img {
    width: 20px;
    height: 15px;
    object-fit: contain;
    flex-shrink: 0;
}

.ek-select-items {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    max-height: 300px;
    overflow-y: auto;
    z-index: 9999;
    box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 0;
}

.ek-select-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.15s ease;
}

.ek-select-item:hover {
    background-color: #f5f5f5;
}

.ek-select-item img {
    width: 20px;
    height: 15px;
    object-fit: contain;
    flex-shrink: 0;
}

/* ========== Checkout Currency Notice ========== */
.ek-checkout-notice {
    margin-top: 20px;
    padding: 15px 18px;
    background: linear-gradient(to right, #f0f8ff, #ffffff);
    border-left: 4px solid #007cba;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.ek-checkout-notice p {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: #555;
}

.ek-checkout-notice p:first-child {
    font-weight: 500;
}

.ek-checkout-notice p + p {
    margin-top: 8px;
    font-size: 13px;
    color: #777;
    font-style: italic;
}

.ek-checkout-notice strong {
    color: #333;
}

/* ========== Responsive Design ========== */
@media (max-width: 768px) {
    .ek-currency-switcher-wrapper {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        width: 100%;
    }

    select.ek-currency-select,
    .ek-currency-switcher-wrapper select.ek-currency-select {
        width: 130px !important;
        min-width: 130px !important;
        max-width: 130px !important;
        flex: 0 0 130px !important;
    }

    .ek-custom-select {
        width: 130px !important;
    }

    .ek-checkout-notice {
        padding: 12px 15px;
    }

    .ek-checkout-notice p {
        font-size: 13px;
    }
}

/* ========== Header/Footer Widget Area Styles ========== */
.widget .ek-currency-switcher-wrapper {
    width: 130px !important;
}

.widget select.ek-currency-select,
.widget .ek-currency-switcher-wrapper select.ek-currency-select {
    width: 130px !important;
    min-width: 130px !important;
    max-width: 130px !important;
    flex: 0 0 130px !important;
}

/* ========== Admin Bar Currency Refresh Button ========== */
#wpadminbar #wp-admin-bar-ek-currency-refresh .ab-item {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#wpadminbar #wp-admin-bar-ek-currency-refresh:hover .ab-item {
    background-color: #0073aa;
}

#wpadminbar #wp-admin-bar-ek-currency-refresh.ek-refreshing .ab-item::before {
    content: '🔄 ';
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ========== Loading State ========== */
select.ek-currency-select.loading,
.ek-currency-switcher-wrapper select.ek-currency-select.loading {
    opacity: 0.6;
    pointer-events: none;
    cursor: wait;
}

select.ek-currency-select.loading::after,
.ek-currency-switcher-wrapper select.ek-currency-select.loading::after {
    content: '...';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}

/* ========== Dark Mode Support ========== */
@media (prefers-color-scheme: dark) {
    .ek-currency-switcher-wrapper {
        background: #1e1e1e;
        border-color: #3a3a3a;
    }

    .ek-currency-label {
        color: #e0e0e0;
    }

    select.ek-currency-select,
    .ek-currency-switcher-wrapper select.ek-currency-select {
        background-color: #2a2a2a;
        color: #e0e0e0;
        border-color: #3a3a3a;
    }

    select.ek-currency-select:hover,
    .ek-currency-switcher-wrapper select.ek-currency-select:hover {
        background-color: #333;
        border-color: #4a90e2;
    }

    select.ek-currency-select:focus,
    .ek-currency-switcher-wrapper select.ek-currency-select:focus {
        background-color: #2a2a2a;
        border-color: #4a90e2;
    }

    .ek-select-selected {
        background-color: #2a2a2a;
        color: #e0e0e0;
        border-color: #3a3a3a;
    }

    .ek-select-selected:hover {
        background-color: #333;
        border-color: #4a90e2;
    }

    .ek-select-items {
        background-color: #2a2a2a;
        border-color: #3a3a3a;
    }

    .ek-select-item {
        color: #e0e0e0;
    }

    .ek-select-item:hover {
        background-color: #333;
    }

    .ek-checkout-notice {
        background: linear-gradient(to right, #1a2530, #1e1e1e);
        border-left-color: #4a90e2;
    }

    .ek-checkout-notice p {
        color: #c0c0c0;
    }

    .ek-checkout-notice strong {
        color: #e0e0e0;
    }
}

/* ========== Print Styles ========== */
@media print {
    .ek-currency-switcher-wrapper {
        display: none;
    }
}
