/* Base Currency Switcher Styles */
.wcgcsp-currency-switcher {
    position: relative;
    margin: 10px 0;
    min-width: 180px;
}

.wcgcsp-currency-selector {
    display: none; /* Hide the native select as we'll use Select2 */
}

.select2-container--default .select2-selection--single {
    height: auto;
    padding: 10px 15px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background-color: #fff;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: all 0.3s ease;
}

.select2-container--default .select2-selection--single:hover {
    border-color: #999;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
}

.select2-container--default .select2-selection--single:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 1px rgba(0,115,170,0.3);
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 100%;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: normal;
    padding-left: 0;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #f0f0f0;
    color: #333;
}

.select2-container--default .select2-results__option[aria-selected=true] {
    background-color: #0073aa;
    color: #fff;
}

.currency-option {
    display: flex;
    align-items: center;
    line-height: normal;
    min-height: 24px;
}

.currency-text {
    align-self: center;
    line-height: 1.4;
}

/* Floating Currency Switcher Styles */
.wcgcsp-floating-switcher {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    z-index: 99999;
    transition: right 0.4s ease;
}

.wcgcsp-floating-switcher:hover {
    right: 10px;
}

.wcgcsp-tab {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: #3498db;
    color: white;
    padding: 15px 8px;
    border-radius: 8px 0 0 8px;
    writing-mode: vertical-lr;
    text-orientation: mixed;
    cursor: pointer;
    font-weight: 600;
    box-shadow: -4px 0 10px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.wcgcsp-tab:hover {
    background: #2980b9;
    padding-right: 12px;
}

.wcgcsp-switcher-content {
    background: white;
    padding: 20px;
    border-radius: 12px 0 0 12px;
    box-shadow: -5px 5px 20px rgba(0, 0, 0, 0.15);
    width: 300px;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.4s ease;
    pointer-events: none;
    position: relative;
    z-index: 99998;
}

.wcgcsp-floating-switcher:hover .wcgcsp-switcher-content {
    opacity: 1;
    transform: translateX(0);
    pointer-events: all;
}

/* Fix Select2 dropdown z-index issues */
.wcgcsp-floating-switcher .select2-container {
    z-index: 99997;
}

.wcgcsp-floating-switcher .select2-dropdown {
    z-index: 99996;
}

/* Ensure Select2 dropdown appears properly */
.select2-container--open .select2-dropdown--below {
    z-index: 99999 !important;
}

.select2-container--open .select2-dropdown--above {
    z-index: 99999 !important;
}

.current-currency {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    border: 1px solid #eee;
    z-index: 1;
}

.current-currency-title {
    font-weight: 600;
    margin-bottom: 8px;
    color: #2c3e50;
}

.current-currency-value {
    font-size: 18px;
    font-weight: 700;
    color: #3498db;
}

/* Select2 customization for floating switcher */
.wcgcsp-floating-switcher .select2-container--default .select2-selection--single {
    height: 46px;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #f8f9fa;
}

.wcgcsp-floating-switcher .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 44px;
}

.wcgcsp-floating-switcher .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 26px;
    font-size: 16px;
    display: flex;
    align-items: center;
}

/* Specific fixes for Select2 dropdown items */
.select2-results__option .currency-option {
    padding: 6px 4px;
}

.select2-results__option[aria-selected=true] .currency-option,
.select2-results__option[aria-selected=true] .currency-flag,
.select2-results__option[aria-selected=true] .currency-text {
    color: #fff !important;
}

/* Fix for the selected value in the Select2 container */
.select2-selection__rendered .currency-option {
    display: flex;
    align-items: center;
    height: 100%;
}

.select2-selection__rendered
    margin-right: 8px;
}

/* Ensure proper alignment in the dropdown */
.select2-results__option {
    padding: 8px 12px !important;
    display: flex;
    align-items: center;
}

/* Fix for flag icon alignment */
.fi {
    display: inline-block;
    vertical-align: middle;
    line-height: 1;
}

/* Additional alignment fixes for the floating switcher */
.wcgcsp-floating-switcher .select2-selection__rendered .currency-option {
    height: 26px;
    display: flex;
    align-items: center;
}

/* Loading State */
.wcgcsp-currency-selector.loading {
    opacity: 0.7;
    pointer-events: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M21 12a9 9 0 1 1-6.219-8.56'%3e%3c/path%3e%3c/svg%3e");
    background-size: 18px;
    animation: spin 1s linear infinite;
}

.wcgcsp-switcher-loading {
    display: none;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Responsive Styles */
@media (max-width: 768px) {
    .wcgcsp-switcher-content {
        width: 250px;
    }
    
    .wcgcsp-floating-switcher:hover {
        right: 5px;
    }
    
    .wcgcsp-tab {
        padding: 12px 6px;
        font-size: 14px;
    }
    
    .wcgcsp-floating-switcher .select2-container--default .select2-selection--single {
        height: 42px;
        padding: 8px 12px;
    }
}

/* Tooltip for Currency Names */
.wcgcsp-currency-selector option {
    position: relative;
}

.wcgcsp-currency-selector option:before {
    content: attr(title);
    position: absolute;
    left: 100%;
    top: 0;
    white-space: nowrap;
    background: #333;
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    margin-left: 10px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.wcgcsp-currency-selector option:hover:before {
    opacity: 1;
}