/**
 * Swift Commerce Currency Switcher Styles
 * 
 * Uses Swift Commerce-frontend.css design system tokens as defaults.
 * Requires: Swift Commerce-frontend.css to be loaded as a dependency.
 *
 * @package Swift Commerce
 */

/* ==========================================================================
   CSS Reset for Currency Switcher Components
   ========================================================================== */

.swift-commerce-currency-switcher,
.swift-commerce-currency-switcher *,
.swift-commerce-currency-switcher *::before,
.swift-commerce-currency-switcher *::after {
    box-sizing: border-box !important;
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

.swift-commerce-currency-switcher {
    --Swift Commerce-cs-primary: var(--sc-primary, #7c3aed);
    --Swift Commerce-cs-bg: var(--sc-background, #ffffff);
    --Swift Commerce-cs-border: var(--sc-border, #e5e7eb);
    --Swift Commerce-cs-hover: var(--sc-gray-100, #f3f4f6);
    --Swift Commerce-cs-active: var(--sc-gray-200, #e5e7eb);
    --Swift Commerce-cs-text: var(--sc-foreground, #1f2937);
    --Swift Commerce-cs-radius: var(--sc-radius-md, 6px);
    --Swift Commerce-cs-shadow: var(--sc-shadow-lg, 0 4px 12px rgba(0, 0, 0, 0.1));
    --Swift Commerce-cs-transition: all var(--sc-transition-normal, 150ms) var(--sc-ease-in-out, ease);
    
    display: inline-block !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* ==========================================================================
   Dropdown Type
   ========================================================================== */

.swift-commerce-cs-dropdown {
    position: relative !important;
    min-width: 120px !important;
}

.swift-commerce-cs-selected {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 8px 12px !important;
    background-color: var(--Swift Commerce-cs-bg) !important;
    color: var(--Swift Commerce-cs-text) !important;
    border: 1px solid var(--Swift Commerce-cs-border) !important;
    border-radius: var(--Swift Commerce-cs-radius) !important;
    cursor: pointer !important;
    transition: var(--Swift Commerce-cs-transition) !important;
    user-select: none !important;
    text-decoration: none !important;
    box-shadow: none !important;
    outline: none !important;
    margin: 0 !important;
}

.swift-commerce-cs-selected:hover {
    border-color: var(--Swift Commerce-cs-primary) !important;
    text-decoration: none !important;
}

.swift-commerce-cs-dropdown.open .swift-commerce-cs-selected {
    border-color: var(--Swift Commerce-cs-primary) !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

.swift-commerce-cs-arrow {
    margin-left: auto !important;
    font-size: 10px !important;
    transition: transform 0.2s ease !important;
}

.swift-commerce-cs-dropdown.open .swift-commerce-cs-arrow {
    transform: rotate(180deg) !important;
}

.swift-commerce-cs-menu {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
    background-color: var(--Swift Commerce-cs-bg) !important;
    border: 1px solid var(--Swift Commerce-cs-border) !important;
    border-top: none !important;
    border-bottom-left-radius: var(--Swift Commerce-cs-radius) !important;
    border-bottom-right-radius: var(--Swift Commerce-cs-radius) !important;
    box-shadow: var(--Swift Commerce-cs-shadow) !important;
    opacity: 0 !important;
    visibility: hidden !important;
    transition: max-height 0.3s ease, opacity 0.2s ease, visibility 0s linear 0.3s !important;
    z-index: 9999 !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

.swift-commerce-cs-dropdown.open .swift-commerce-cs-menu {
    max-height: 300px !important;
    overflow: hidden !important; /* Keep hidden during animation */
    opacity: 1 !important;
    visibility: visible !important;
    transition: max-height 0.3s ease, opacity 0.2s ease, visibility 0s linear 0s !important;
}

/* Only show scrollbar after animation completes */
.swift-commerce-cs-dropdown.open.animation-complete .swift-commerce-cs-menu {
    overflow-y: auto !important;
}

.swift-commerce-cs-menu-item {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 10px 12px !important;
    cursor: pointer !important;
    transition: var(--Swift Commerce-cs-transition) !important;
    color: var(--Swift Commerce-cs-text) !important;
    text-decoration: none !important;
    background: transparent !important;
    border: none !important;
    margin: 0 !important;
}

.swift-commerce-cs-menu-item:hover {
    background-color: var(--Swift Commerce-cs-hover) !important;
    color: var(--Swift Commerce-cs-hover-text, var(--Swift Commerce-cs-text)) !important;
    text-decoration: none !important;
}

.swift-commerce-cs-menu-item.active {
    background-color: var(--Swift Commerce-cs-hover) !important;
    font-weight: 500 !important;
}

/* ==========================================================================
   Buttons Type
   ========================================================================== */

.swift-commerce-cs-buttons {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

.swift-commerce-cs-button {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 8px 14px !important;
    background-color: var(--Swift Commerce-cs-bg) !important;
    border: 1px solid var(--Swift Commerce-cs-border) !important;
    border-radius: var(--Swift Commerce-cs-radius) !important;
    cursor: pointer !important;
    font-size: inherit !important;
    font-family: inherit !important;
    color: var(--Swift Commerce-cs-text) !important;
    transition: var(--Swift Commerce-cs-transition) !important;
    text-decoration: none !important;
    box-shadow: none !important;
    outline: none !important;
    margin: 0 !important;
}

.swift-commerce-cs-button:hover {
    border-color: var(--Swift Commerce-cs-primary) !important;
    background-color: var(--Swift Commerce-cs-hover) !important;
    text-decoration: none !important;
}

.swift-commerce-cs-button.active {
    background-color: var(--Swift Commerce-cs-primary) !important;
    border-color: var(--Swift Commerce-cs-primary) !important;
    color: #ffffff !important;
}

/* Ensure all child elements in active button have white text */
.swift-commerce-cs-button.active .swift-commerce-cs-code,
.swift-commerce-cs-button.active .swift-commerce-cs-name,
.swift-commerce-cs-button.active .swift-commerce-cs-symbol {
    color: #ffffff !important;
}

/* ==========================================================================
   List Type
   ========================================================================== */

.swift-commerce-cs-list {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background-color: var(--Swift Commerce-cs-bg) !important;
    border: 1px solid var(--Swift Commerce-cs-border) !important;
    border-radius: var(--Swift Commerce-cs-radius) !important;
    overflow: hidden !important;
}

.swift-commerce-cs-list-item {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 10px 14px !important;
    cursor: pointer !important;
    color: var(--Swift Commerce-cs-text) !important;
    transition: var(--Swift Commerce-cs-transition) !important;
    border-bottom: 1px solid var(--Swift Commerce-cs-border) !important;
    text-decoration: none !important;
    background: transparent !important;
    margin: 0 !important;
}

.swift-commerce-cs-list-item:last-child {
    border-bottom: none !important;
}

.swift-commerce-cs-list-item:hover {
    background-color: var(--Swift Commerce-cs-hover) !important;
    color: var(--Swift Commerce-cs-hover-text, var(--Swift Commerce-cs-text)) !important;
    text-decoration: none !important;
}

.swift-commerce-cs-list-item.active {
    background-color: var(--Swift Commerce-cs-hover) !important;
    font-weight: 500 !important;
}

/* ==========================================================================
   Flags Only Type
   ========================================================================== */

.swift-commerce-cs-flags-only {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

.swift-commerce-cs-flags-only .swift-commerce-cs-flag {
    cursor: pointer !important;
    opacity: 0.6 !important;
    transition: var(--Swift Commerce-cs-transition) !important;
}

.swift-commerce-cs-flags-only .swift-commerce-cs-flag:hover {
    opacity: 0.8 !important;
    transform: scale(1.1) !important;
}

.swift-commerce-cs-flags-only .swift-commerce-cs-flag.active {
    opacity: 1 !important;
}

/* ==========================================================================
   Flag Styles
   ========================================================================== */

.swift-commerce-cs-flag {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 20px !important;
    height: 20px !important;
    font-size: 16px !important;
    line-height: 1 !important;
    flex-shrink: 0 !important;
}

.swift-commerce-cs-flag--circle {
    border-radius: 50% !important;
    overflow: hidden !important;
}

.swift-commerce-cs-flag--square {
    border-radius: 0 !important;
}

.swift-commerce-cs-flag--rounded {
    border-radius: 4px !important;
    overflow: hidden !important;
}

.swift-commerce-cs-flag img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ==========================================================================
   Currency Info
   ========================================================================== */

.swift-commerce-cs-code {
    font-weight: 600;
    text-transform: uppercase;
    color: inherit;
}

.swift-commerce-cs-name {
    color: var(--Swift Commerce-cs-text);
    font-size: 13px;
    opacity: 0.7;
}

.swift-commerce-cs-symbol {
    color: var(--Swift Commerce-cs-text);
    opacity: 0.6;
}

/* ==========================================================================
   Preset Themes
   ========================================================================== */

/* Dark Theme */
.swift-commerce-cs-preset--dark {
    --Swift Commerce-cs-primary: #ffffff;
    --Swift Commerce-cs-bg: #1a1a1a;
    --Swift Commerce-cs-border: #333333;
    --Swift Commerce-cs-hover: #2a2a2a;
    --Swift Commerce-cs-active: #333333;
    --Swift Commerce-cs-text: #ffffff;
}

.swift-commerce-cs-preset--dark .swift-commerce-cs-name {
    color: #aaaaaa;
}

.swift-commerce-cs-preset--dark .swift-commerce-cs-symbol {
    color: #888888;
}

/* Minimal Theme */
.swift-commerce-cs-preset--minimal {
    --Swift Commerce-cs-border: transparent;
    --Swift Commerce-cs-shadow: none;
}

.swift-commerce-cs-preset--minimal .swift-commerce-cs-selected {
    border: none;
    padding: 4px 8px;
}

.swift-commerce-cs-preset--minimal .swift-commerce-cs-selected:hover {
    background-color: var(--Swift Commerce-cs-hover);
}

/* Rounded Theme */
.swift-commerce-cs-preset--rounded {
    --Swift Commerce-cs-radius: 24px;
}

.swift-commerce-cs-preset--rounded .swift-commerce-cs-menu {
    border-radius: 16px;
    margin-top: 4px;
    border: 1px solid var(--Swift Commerce-cs-border);
}

/* Bordered Theme */
.swift-commerce-cs-preset--bordered {
    --Swift Commerce-cs-border: #333333;
}

.swift-commerce-cs-preset--bordered .swift-commerce-cs-selected {
    border-width: 2px;
}

/* Flat Theme */
.swift-commerce-cs-preset--flat {
    --Swift Commerce-cs-bg: #f5f5f5;
    --Swift Commerce-cs-border: transparent;
    --Swift Commerce-cs-shadow: none;
}

/* Gradient Theme */
.swift-commerce-cs-preset--gradient .swift-commerce-cs-selected {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: #ffffff;
}

.swift-commerce-cs-preset--gradient .swift-commerce-cs-button.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
}

/* ==========================================================================
   Animations
   ========================================================================== */

.swift-commerce-cs-animate--fade .swift-commerce-cs-menu {
    transition: opacity 0.3s ease;
}

.swift-commerce-cs-animate--slide .swift-commerce-cs-menu {
    transform: translateY(-10px);
    transition: transform 0.3s ease, opacity 0.3s ease, max-height 0.3s ease;
}

.swift-commerce-cs-animate--slide.open .swift-commerce-cs-menu {
    transform: translateY(0);
}

.swift-commerce-cs-animate--scale .swift-commerce-cs-menu {
    transform: scale(0.95);
    transform-origin: top center;
    transition: transform 0.2s ease, opacity 0.2s ease, max-height 0.3s ease;
}

.swift-commerce-cs-animate--scale.open .swift-commerce-cs-menu {
    transform: scale(1);
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.swift-commerce-cs-loading {
    pointer-events: none;
    opacity: 0.7;
}

.swift-commerce-cs-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 12px;
    width: 14px;
    height: 14px;
    margin-top: -7px;
    border: 2px solid var(--Swift Commerce-cs-border);
    border-top-color: var(--Swift Commerce-cs-primary);
    border-radius: 50%;
    animation: Swift Commerce-cs-spin 0.8s linear infinite;
}

@keyframes Swift Commerce-cs-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   Layout Direction (Inline vs Block)
   ========================================================================== */

/* Block layout - vertical stacking */
.swift-commerce-cs-layout--block .swift-commerce-cs-buttons {
    flex-direction: column !important;
}

.swift-commerce-cs-layout--block .swift-commerce-cs-list {
    display: flex !important;
    flex-direction: column !important;
}

.swift-commerce-cs-layout--block .swift-commerce-cs-flags-only {
    flex-direction: column !important;
}

/* Inline layout (default) - horizontal layout */
.swift-commerce-cs-layout--inline .swift-commerce-cs-buttons {
    flex-direction: row !important;
}

.swift-commerce-cs-layout--inline .swift-commerce-cs-list {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    border: none !important;
}

.swift-commerce-cs-layout--inline .swift-commerce-cs-list-item {
    border-bottom: none !important;
    border: 1px solid var(--Swift Commerce-cs-border) !important;
    border-radius: var(--Swift Commerce-cs-radius) !important;
}

.swift-commerce-cs-layout--inline .swift-commerce-cs-flags-only {
    flex-direction: row !important;
}

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

@media (max-width: 768px) {
    .swift-commerce-cs-mobile--fullwidth .swift-commerce-cs-dropdown,
    .swift-commerce-cs-mobile--fullwidth .swift-commerce-cs-buttons,
    .swift-commerce-cs-mobile--fullwidth .swift-commerce-cs-list {
        width: 100%;
    }
    
    .swift-commerce-cs-mobile--bottom .swift-commerce-cs-menu {
        position: fixed;
        top: auto !important;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 16px 16px 0 0;
        max-height: 50vh !important;
    }
    
    .swift-commerce-cs-mobile--larger {
        font-size: 16px;
    }
    
    .swift-commerce-cs-mobile--larger .swift-commerce-cs-selected,
    .swift-commerce-cs-mobile--larger .swift-commerce-cs-button,
    .swift-commerce-cs-mobile--larger .swift-commerce-cs-list-item,
    .swift-commerce-cs-mobile--larger .swift-commerce-cs-menu-item {
        padding: 12px 16px;
    }
    
    .swift-commerce-cs-mobile--larger .swift-commerce-cs-flag {
        width: 24px;
        height: 24px;
        font-size: 20px;
    }
}

/* Overlay for mobile bottom sheet */
.swift-commerce-cs-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9998;
}

.swift-commerce-cs-mobile--bottom.open .swift-commerce-cs-overlay {
    display: block;
}

/* ==========================================================================
   RTL Support
   ========================================================================== */

[dir="rtl"] .swift-commerce-cs-selected,
[dir="rtl"] .swift-commerce-cs-menu-item,
[dir="rtl"] .swift-commerce-cs-list-item,
[dir="rtl"] .swift-commerce-cs-button {
    flex-direction: row-reverse;
}

[dir="rtl"] .swift-commerce-cs-arrow {
    margin-left: 0;
    margin-right: auto;
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

.swift-commerce-cs-selected:focus,
.swift-commerce-cs-button:focus,
.swift-commerce-cs-menu-item:focus {
    outline: 2px solid var(--Swift Commerce-cs-primary);
    outline-offset: 2px;
}

.swift-commerce-cs-selected:focus:not(:focus-visible),
.swift-commerce-cs-button:focus:not(:focus-visible),
.swift-commerce-cs-menu-item:focus:not(:focus-visible) {
    outline: none;
}

/* Screen reader only */
.swift-commerce-cs-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .swift-commerce-currency-switcher {
        display: none !important;
    }
}

