/**
 * eSIM Currency Switcher Styles
 */

/* Base Styles */
.esim-currency-switcher {
    display: inline-block;
    position: relative;
    font-size: 14px;
    /* Prevent layout shift */
    min-height: 36px;
}

/* Modal Trigger Button */
.esim-currency-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: inherit;
    transition: all 0.2s ease;
    white-space: nowrap;
    /* Fixed dimensions to prevent layout shift */
    height: 36px;
    min-width: 100px;
    box-sizing: border-box;
}

.esim-currency-trigger:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.5);
}

/* Modal Styles */
.esim-currency-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: none;
}

.esim-currency-modal.active {
    display: block;
}

.esim-currency-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    cursor: pointer;
}

.esim-currency-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.esim-currency-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
}

.esim-currency-modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.esim-currency-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.esim-currency-modal-close:hover {
    background: #f0f0f0;
    color: #666;
}

.esim-currency-modal-body {
    padding: 8px;
    overflow-y: auto;
    flex: 1;
}

.esim-currency-modal .esim-currency-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    margin: 4px;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    transition: all 0.2s ease;
}

.esim-currency-modal .esim-currency-option:hover {
    background: #f5f5f5;
}

.esim-currency-modal .esim-currency-option.active {
    background: #e3f2fd;
    color: #0066cc;
}

.esim-currency-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.esim-currency-name {
    font-weight: 500;
    font-size: 16px;
    margin-bottom: 2px;
}

.esim-currency-code-symbol {
    font-size: 13px;
    color: #666;
}

.esim-currency-option.active .esim-currency-code-symbol {
    color: #0066cc;
}

.esim-currency-check {
    font-size: 20px;
    color: #0066cc;
}

/* Dropdown Style */
.esim-currency-dropdown {
    position: relative;
}

.esim-currency-current {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.esim-currency-current:hover {
    border-color: #999;
    background: #f8f8f8;
}

.esim-currency-current.active {
    border-color: #0066cc;
    box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.1);
}

.esim-currency-arrow {
    transition: transform 0.2s ease;
}

.esim-currency-current.active .esim-currency-arrow {
    transform: rotate(180deg);
}

.esim-currency-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    min-width: 200px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    /* Prevent layout shift */
    pointer-events: none;
}

.esim-currency-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear;
    pointer-events: auto;
}

.esim-currency-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    color: #333;
    text-decoration: none;
    transition: background 0.2s ease;
}

.esim-currency-option:hover {
    background: #f5f5f5;
}

.esim-currency-option.active {
    background: #e3f2fd;
    color: #0066cc;
    font-weight: 500;
}

.esim-currency-option:first-child {
    border-radius: 5px 5px 0 0;
}

.esim-currency-option:last-child {
    border-radius: 0 0 5px 5px;
}

.esim-currency-name {
    flex: 1;
}

.esim-currency-code {
    font-weight: 500;
    opacity: 0.7;
}

.esim-currency-symbol {
    opacity: 0.6;
    font-size: 13px;
}

/* Flags Style */
.esim-currency-flags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.esim-currency-flag-link {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    font-weight: 500;
    transition: all 0.2s ease;
}

.esim-currency-flag-link:hover {
    background: #e8e8e8;
    border-color: #ccc;
}

.esim-currency-flag-link.active {
    background: #0066cc;
    color: #fff;
    border-color: #0066cc;
}

/* Compact Select Style */
.esim-currency-select {
    padding: 6px 30px 6px 10px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.esim-currency-select:hover {
    border-color: #999;
}

.esim-currency-select:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.1);
}

/* Currency Flags */
.esim-currency-flag {
    display: inline-block;
    font-size: 18px;
    line-height: 1;
    margin-right: 6px;
    vertical-align: middle;
    min-width: 20px;
    width: 20px;
    height: 20px;
    text-align: center;
    /* Prevent layout shift */
    aspect-ratio: 1;
    overflow: hidden;
}

/* Ensure proper emoji rendering */
.esim-currency-flag {
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Android Emoji", "EmojiSymbols", "EmojiOne Mozilla", "Twemoji Mozilla", "Segoe UI Symbol", "Noto Emoji";
    font-variant-emoji: emoji;
}

/* Responsive flag sizing */
@media (max-width: 768px) {
    .esim-currency-flag {
        font-size: 16px;
        min-width: 18px;
        width: 18px;
        height: 18px;
    }
}

/* Flag positioning in different contexts */
.esim-currency-trigger .esim-currency-flag {
    margin-right: 8px;
}

.esim-currency-option .esim-currency-flag {
    margin-right: 10px;
    flex-shrink: 0;
}

.esim-currency-flag-link .esim-currency-flag {
    margin-right: 4px;
}

/* Fallback currency code flags */
.currency-code-flag {
    display: inline-block;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 4px;
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 3px;
    color: #666;
    text-transform: uppercase;
    line-height: 1;
    min-width: 20px;
    text-align: center;
}

.esim-currency-option.active .currency-code-flag {
    background: #0066cc;
    color: #fff;
    border-color: #0066cc;
}

/* Debug styles for testing */
.esim-currency-flag {
    border: 1px solid transparent; /* for debugging */
}

.esim-currency-flag:empty::after {
    content: "🏳️";
    opacity: 0.5;
}

/* Legacy CSS flag fallback - now deprecated */
.esim-currency-flag-legacy {
    display: inline-block;
    width: 20px;
    height: 15px;
    background-size: cover;
    background-position: center;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
}

.esim-currency-flag-legacy::before {
    display: block;
    width: 100%;
    height: 100%;
    line-height: 15px;
    text-align: center;
    font-size: 14px;
}

/* Header Integration */
.site-header .esim-currency-switcher {
    margin: 0 10px;
}

.site-header .esim-currency-current {
    background: transparent;
    border-color: rgba(255,255,255,0.3);
    color: inherit;
}

.site-header.dark-mode .esim-currency-current {
    color: #fff;
}

.site-header .esim-currency-current:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.5);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .esim-currency-menu {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
        border-radius: 12px 12px 0 0;
        max-height: 70vh;
    }
    
    .esim-currency-option {
        padding: 14px 16px;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .esim-currency-flags {
        justify-content: center;
    }
    
    .esim-currency-select {
        width: 100%;
        padding: 10px 35px 10px 12px;
    }
}