/**
 * Price by Country - Currency Switcher Styles
 * 
 * Provides styling for header dropdown and side panel currency switcher
 * with mobile responsiveness and RTL support.
 */

/* ============================================
   Base Currency Switcher Styles
   ============================================ */

.pbc-currency-switcher {
  position: relative;
  display: inline-block;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu,
    Cantarell, "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.pbc-currency-switcher * {
  box-sizing: border-box;
}

/* Header wrapper for fallback positioning */
.pbc-header-switcher-wrapper {
  z-index: 9999;
  display: inline-block;
}

.pbc-header-switcher-wrapper .pbc-currency-switcher-header {
  display: inline-flex;
}

/* ============================================
   Header Dropdown Styles - Desktop
   ============================================ */

.pbc-currency-switcher-header {
  display: inline-flex;
  position: relative;
  z-index: 9999;
  align-items: center;
}

.pbc-currency-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  min-width: auto;
  box-shadow: none;
}

.pbc-currency-trigger:hover {
  background: #f5f5f5;
  border-color: #e0e0e0;
}

.pbc-currency-trigger:focus {
  outline: 2px solid #0073aa;
  outline-offset: 2px;
}

.pbc-current-currency {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pbc-currency-flag {
  width: 24px;
  height: 16px;
  object-fit: cover;
  border-radius: 2px;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.pbc-currency-flag img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pbc-currency-code {
  font-weight: 500;
  color: #333;
  font-size: 14px;
}

.pbc-currency-symbol {
  font-weight: 600;
  color: #333;
  font-size: 14px;
}

.pbc-dropdown-arrow {
  margin-left: 4px;
  font-size: 10px;
  color: #666;
  transition: transform 0.2s ease;
}

.pbc-currency-trigger[aria-expanded="true"] .pbc-dropdown-arrow {
  transform: rotate(180deg);
}

/* Dropdown Menu */
.pbc-currency-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  /* Match header button width */
  min-width: 100%;
  max-height: 400px;
  overflow-y: auto;
  overflow-x: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s ease;
  z-index: 10000;
  display: none !important;
}

.pbc-currency-dropdown[style*="display: block"],
.pbc-currency-dropdown[style*="display:block"] {
  display: block !important;
}

.pbc-currency-dropdown.pbc-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  display: block;
}

/* Ensure dropdown doesn't get cut off */
.pbc-currency-switcher-header {
  position: relative;
}

/* Custom scrollbar for dropdown */
.pbc-currency-dropdown::-webkit-scrollbar {
  width: 6px;
}

.pbc-currency-dropdown::-webkit-scrollbar-track {
  background: #f9f9f9;
  border-radius: 10px;
}

.pbc-currency-dropdown::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 10px;
}

.pbc-currency-dropdown::-webkit-scrollbar-thumb:hover {
  background: #999;
}

.pbc-currency-list {
  list-style: none;
  margin: 0;
  padding: 8px 0;
}

.pbc-currency-dropdown li[role="option"] {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pbc-currency-option {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 10px 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  color: #555;
  text-decoration: none;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

/* Keep code + symbol together */
.pbc-code-with-symbol {
  display: inline-flex;
  align-items: center;
  gap: 0;
}

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

.pbc-currency-option:focus {
  background: #f0f0f0;
  outline: none;
}

.pbc-currency-option.active {
  background: #f0f7ff;
  color: #0073aa;
}

.pbc-currency-option.active:hover {
  background: #e6f2ff;
}

.pbc-currency-info {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 8px;
  justify-content: flex-start;
}

.pbc-currency-code {
  font-weight: 500;
  font-size: 14px;
  color: #333;
  min-width: 40px;
}

.pbc-currency-option.active .pbc-currency-code {
  color: #0073aa;
  font-weight: 600;
}

.pbc-currency-name {
  font-size: 14px;
  color: #666;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pbc-currency-option.active .pbc-currency-name {
  color: #0073aa;
}

.pbc-currency-symbol {
  font-weight: 600;
  color: #999;
  font-size: 14px;
  margin-left: 0;
}

.pbc-currency-option.active .pbc-currency-symbol {
  color: #0073aa;
}

/* Return to detected currency option styling */
.pbc-return-to-detected {
  border-top: 1px solid #eee;
  font-style: italic;
}

.pbc-return-to-detected .pbc-currency-name,
.pbc-return-to-detected .pbc-currency-name-full {
  font-style: italic;
  font-weight: 500;
}

.pbc-return-to-detected.active {
  background: #e6f2ff !important;
  color: #005a99 !important;
}

.pbc-return-to-detected.active .pbc-currency-code,
.pbc-return-to-detected.active .pbc-currency-name,
.pbc-return-to-detected.active .pbc-currency-name-full {
  color: #005a99 !important;
}

.pbc-return-to-detected:hover {
  background: #f0f9ff !important;
}

/* Return to detected styling for simple injection methods */
.pbc-currency-option.pbc-return-to-detected {
  border-top: 1px solid #eee;
  font-style: italic;
  padding-top: 8px !important;
  margin-top: 8px !important;
  border-top: 1px solid #eee !important;
}

.pbc-currency-option.pbc-return-to-detected .pbc-currency-code {
  font-style: italic;
  font-weight: 500;
}

.pbc-currency-button.pbc-return-to-detected {
  border-top: 1px solid #eee;
  font-style: italic;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #eee;
}

.pbc-currency-button.pbc-return-to-detected .pbc-currency-code,
.pbc-currency-button.pbc-return-to-detected .pbc-currency-name-full {
  font-style: italic;
  font-weight: 500;
}

/* ============================================
   Side Panel Styles - Compact with Hover Reveal
   ============================================ */

.pbc-currency-side-panel {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 9998;
  background: #fff;
  border-radius: 8px 0 0 8px;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
  padding: 10px 5px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 80vh;
  overflow-y: auto;
  overflow-x: hidden;
  width: 60px;
}

.pbc-currency-side-panel.left {
  left: 0;
  border-radius: 0 8px 8px 0;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.pbc-currency-side-panel.right {
  right: 0;
}

/* Expanded state on hover */
.pbc-currency-side-panel:hover {
  width: 280px;
  padding: 20px 15px;
  box-shadow: -2px 0 15px rgba(0, 0, 0, 0.15);
}

.pbc-currency-side-panel.left:hover {
  box-shadow: 2px 0 15px rgba(0, 0, 0, 0.15);
}

.pbc-currency-side-panel:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* Custom scrollbar for side panel */
.pbc-currency-side-panel::-webkit-scrollbar {
  width: 6px;
}

.pbc-currency-side-panel::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.pbc-currency-side-panel::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 10px;
}

.pbc-currency-side-panel::-webkit-scrollbar-thumb:hover {
  background: #555;
}

.pbc-side-panel-header {
  text-align: center;
  padding-bottom: 0;
  margin-bottom: 12px;
  border-bottom: none;
  opacity: 0;
  height: 0;
  overflow: hidden;
  transition: all 0.3s ease;
}

.pbc-currency-side-panel:hover .pbc-side-panel-header {
  opacity: 1;
  height: auto;
  padding-bottom: 12px;
  border-bottom: 1px solid #e8e8e8;
}

.pbc-side-panel-title {
  font-size: 11px;
  font-weight: 600;
  color: #adb5bd;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.pbc-side-panel-inner {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.pbc-currency-side-panel:hover .pbc-side-panel-inner {
  gap: 8px;
}

/* Optional: Add a subtle indicator that it's hoverable */
.pbc-currency-side-panel::before {
  content: "";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 40px;
  background: #495057;
  border-radius: 3px;
  opacity: 0.5;
  transition: opacity 0.3s ease;
}

.pbc-currency-side-panel.right::before {
  left: -3px;
  border-radius: 3px 0 0 3px;
}

.pbc-currency-side-panel.left::before {
  right: -3px;
  border-radius: 0 3px 3px 0;
}

.pbc-currency-side-panel:hover::before {
  opacity: 1;
}

.pbc-side-panel-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Compact button - just currency code */
.pbc-currency-button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: row;
  width: 50px;
  height: 40px;
  padding: 8px;
  border: none;
  border-radius: 4px;
  background: #3d4f5d;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  gap: 0;
  color: #fff;
}

.pbc-currency-button:hover {
  background: #4a5d6d;
  transform: translateX(-2px);
}

.pbc-currency-button:focus {
  outline: 2px solid #666;
  outline-offset: 2px;
}

.pbc-currency-button.active {
  background: #2c3e50;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Hide flag in compact view */
.pbc-currency-button .pbc-currency-flag {
  display: none;
  width: 28px;
  height: 20px;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: all 0.25s ease;
}

.pbc-currency-button .pbc-currency-flag img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Show only code in compact view */
.pbc-currency-button .pbc-currency-code {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  text-align: center;
  line-height: 1.2;
  letter-spacing: 0.3px;
}

.pbc-currency-button.active .pbc-currency-code {
  color: #fff;
}

/* Hide name in compact view */
.pbc-currency-button .pbc-currency-name-full {
  display: none;
  font-size: 13px;
  color: #6c757d;
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pbc-currency-button.active .pbc-currency-name-full {
  color: #e9ecef;
}

.pbc-currency-button-code {
  display: none;
}

/* Expanded state on panel hover */
.pbc-currency-side-panel:hover .pbc-currency-button {
  width: 100%;
  height: auto;
  padding: 12px 15px;
  justify-content: flex-start;
  gap: 12px;
  background: #f8f9fa;
  border: 2px solid transparent;
  color: #333;
  flex-direction: row;
}

.pbc-currency-side-panel:hover .pbc-currency-button:hover {
  background: #e9ecef;
  border-color: #dee2e6;
  transform: none;
}

.pbc-currency-side-panel:hover .pbc-currency-button.active {
  background: #2c3e50;
  color: #fff;
  border-color: #2c3e50;
}

.pbc-currency-side-panel:hover .pbc-currency-button.active:hover {
  background: #1a252f;
  border-color: #1a252f;
}

/* Show flag in expanded view */
.pbc-currency-side-panel:hover .pbc-currency-button .pbc-currency-flag {
  display: block;
}

.pbc-currency-side-panel:hover .pbc-currency-button:hover .pbc-currency-flag {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Adjust code in expanded view */
.pbc-currency-side-panel:hover .pbc-currency-button .pbc-currency-code {
  min-width: 45px;
  color: #212529;
  font-weight: 600;
  flex-shrink: 0;
}

.pbc-currency-side-panel:hover .pbc-currency-button.active .pbc-currency-code {
  color: #fff;
}

/* Show name in expanded view */
.pbc-currency-side-panel:hover .pbc-currency-button .pbc-currency-name-full {
  display: block;
}

/* ============================================
   Loading States
   ============================================ */

.pbc-loading {
  position: relative;
  opacity: 0.6;
  pointer-events: none;
}

.pbc-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #ccc;
  border-top-color: #0073aa;
  border-radius: 50%;
  animation: pbc-spin 0.6s linear infinite;
}

@keyframes pbc-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Loading overlay for price updates */
.pbc-price-loading {
  position: relative;
}

.pbc-price-loading::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  z-index: 1;
}

.pbc-price-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid #ddd;
  border-top-color: #0073aa;
  border-radius: 50%;
  animation: pbc-spin 0.5s linear infinite;
  z-index: 2;
}

/* ============================================
   Shortcode and Widget Styles
   ============================================ */

.pbc-currency-switcher-shortcode {
  margin: 10px 0;
}

.pbc-currency-switcher-widget {
  padding: 15px;
}

.pbc-currency-switcher-widget .pbc-currency-list {
  padding: 0;
}

.pbc-currency-switcher-widget .pbc-currency-option {
  padding: 8px 10px;
}

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

@media (max-width: 768px) {
  /* Hide header currency switcher on mobile */
  .pbc-currency-switcher-header,
  .pbc-header-switcher-wrapper {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 0 !important;
    height: 0 !important;
    visibility: hidden !important;
  }

  /* Remove spacing from parent containers */
  .site-header .pbc-header-switcher-wrapper,
  .masthead .pbc-header-switcher-wrapper,
  header .pbc-header-switcher-wrapper,
  .header-right .pbc-header-switcher-wrapper,
  .site-tools .pbc-header-switcher-wrapper,
  .header-tools .pbc-header-switcher-wrapper,
  .header-actions .pbc-header-switcher-wrapper,
  .site-navigation .pbc-header-switcher-wrapper,
  .main-navigation .pbc-header-switcher-wrapper {
    margin: 0 !important;
  }

  /* Remove spacing from adjacent elements */
  .pbc-header-switcher-wrapper + .site-header-cart,
  .pbc-header-switcher-wrapper + .woocommerce-mini-cart,
  .pbc-header-switcher-wrapper + .cart-contents,
  .site-header-cart + .pbc-header-switcher-wrapper,
  .woocommerce-mini-cart + .pbc-header-switcher-wrapper,
  .cart-contents + .pbc-header-switcher-wrapper {
    margin-left: 0 !important;
  }

  /* Header dropdown mobile adjustments */
  .pbc-currency-dropdown {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 12px 12px 0 0;
    max-height: 60vh;
    min-width: 100%;
    transform: translateY(100%);
  }

  .pbc-currency-dropdown.pbc-open {
    transform: translateY(0);
  }

  .pbc-currency-option {
    padding: 14px 20px;
    font-size: 16px;
    min-height: 56px;
  }

  .pbc-currency-flag {
    width: 28px;
    height: 20px;
  }

  .pbc-currency-trigger {
    padding: 8px 10px;
    gap: 4px;
  }

  .pbc-currency-code {
    font-size: 13px;
  }

  .pbc-currency-symbol {
    font-size: 13px;
  }

  /* Fixed position on mobile */
  .pbc-header-switcher-wrapper.pbc-fixed-position {
    top: 10px;
    right: 10px;
    padding: 6px 10px;
  }

  /* Side panel mobile adjustments - Convert to single button */
  .pbc-currency-side-panel {
    width: auto !important;
    padding: 0;
    border-radius: 8px;
    max-height: none;
    overflow: visible;
    background: transparent;
    box-shadow: none;
  }

  .pbc-currency-side-panel.left {
    left: 10px;
  }

  .pbc-currency-side-panel.right {
    right: 10px;
  }

  /* Hide the hover indicator on mobile */
  .pbc-currency-side-panel::before {
    display: none;
  }

  /* Hide header and all currency buttons except the toggle */
  .pbc-side-panel-header {
    display: none !important;
  }

  .pbc-side-panel-inner {
    gap: 0;
  }

  .pbc-currency-button {
    display: none !important;
  }

  /* Show only the mobile toggle button */
  .pbc-mobile-currency-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    padding: 12px;
    border: none;
    border-radius: 50%;
    background: #3d4f5d;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
  }

  .pbc-mobile-currency-toggle:hover,
  .pbc-mobile-currency-toggle:focus {
    background: #4a5d6d;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
    outline: none;
  }

  .pbc-mobile-currency-toggle:active {
    transform: scale(0.95);
  }

  /* Mobile modal overlay */
  .pbc-mobile-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .pbc-mobile-modal-overlay.pbc-active {
    display: block;
    opacity: 1;
  }

  /* Mobile modal content */
  .pbc-mobile-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    overflow: hidden;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .pbc-mobile-modal.pbc-active {
    display: flex;
    flex-direction: column;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }

  /* Modal header */
  .pbc-mobile-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #fff;
  }

  .pbc-mobile-modal-title {
    font-size: 16px;
    font-weight: 600;
    color: #666;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 11px;
  }

  .pbc-mobile-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #666;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    transition: all 0.2s ease;
  }

  .pbc-mobile-modal-close:hover,
  .pbc-mobile-modal-close:focus {
    background: #f5f5f5;
    color: #333;
    outline: none;
  }

  /* Modal body */
  .pbc-mobile-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    background: #fff;
  }

  .pbc-mobile-modal-body::-webkit-scrollbar {
    width: 6px;
  }

  .pbc-mobile-modal-body::-webkit-scrollbar-track {
    background: #f9f9f9;
    border-radius: 10px;
  }

  .pbc-mobile-modal-body::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
  }

  .pbc-mobile-modal-body::-webkit-scrollbar-thumb:hover {
    background: #999;
  }

  /* Modal currency list */
  .pbc-mobile-currency-list {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .pbc-mobile-currency-list .pbc-currency-button {
    display: flex !important;
    width: 100%;
    height: auto;
    padding: 10px 16px;
    border: none;
    border-bottom: none;
    border-radius: 0;
    background: #fff !important;
    color: #555 !important;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    box-shadow: none !important;
  }

  .pbc-mobile-currency-list .pbc-currency-button:last-child {
    border-bottom: none;
  }

  .pbc-mobile-currency-list .pbc-currency-button:hover,
  .pbc-mobile-currency-list .pbc-currency-button:focus {
    background: #f5f5f5 !important;
    outline: none;
    transform: none !important;
  }

  .pbc-mobile-currency-list .pbc-currency-button.active {
    background: #f0f7ff !important;
    color: #0073aa !important;
    border-color: transparent !important;
  }

  .pbc-mobile-currency-list .pbc-currency-button.active:hover {
    background: #e6f2ff !important;
  }

  /* Show flag in modal */
  .pbc-mobile-currency-list .pbc-currency-button .pbc-currency-flag {
    display: block;
    width: 24px;
    height: 16px;
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
  }

  /* Show code in modal */
  .pbc-mobile-currency-list .pbc-currency-button .pbc-currency-code {
    font-size: 14px;
    font-weight: 500;
    color: #333 !important;
    min-width: 40px;
  }

  .pbc-mobile-currency-list .pbc-currency-button.active .pbc-currency-code {
    color: #0073aa !important;
    font-weight: 600;
  }

  /* Show name in modal */
  .pbc-mobile-currency-list .pbc-currency-button .pbc-currency-name-full {
    display: block;
    font-size: 14px;
    color: #666 !important;
    flex: 1;
    text-align: left;
  }

  .pbc-mobile-currency-list
    .pbc-currency-button.active
    .pbc-currency-name-full {
    color: #0073aa !important;
  }

  /* Disable hover expansion on mobile */
  .pbc-currency-side-panel:hover {
    width: auto !important;
    padding: 0;
    box-shadow: none;
  }
}

@media (max-width: 480px) {
  .pbc-mobile-currency-toggle {
    width: 56px;
    height: 56px;
    font-size: 13px;
  }

  .pbc-mobile-modal {
    width: 95%;
    max-height: 85vh;
  }

  .pbc-mobile-modal-header {
    padding: 16px;
  }

  .pbc-mobile-modal-title {
    font-size: 16px;
  }

  .pbc-mobile-currency-list .pbc-currency-button {
    padding: 14px 16px;
  }

  .pbc-mobile-currency-list .pbc-currency-button .pbc-currency-flag {
    width: 28px;
    height: 20px;
  }

  .pbc-mobile-currency-list .pbc-currency-button .pbc-currency-code {
    font-size: 15px;
    min-width: 45px;
  }

  .pbc-mobile-currency-list .pbc-currency-button .pbc-currency-name-full {
    font-size: 14px;
  }
}

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

[dir="rtl"] .pbc-currency-switcher-header {
  direction: rtl;
}

[dir="rtl"] .pbc-currency-dropdown {
  right: auto;
  left: 0;
}

[dir="rtl"] .pbc-currency-trigger {
  flex-direction: row-reverse;
}

[dir="rtl"] .pbc-currency-arrow {
  margin-left: 0;
  margin-right: auto;
}

[dir="rtl"] .pbc-currency-option {
  flex-direction: row-reverse;
  text-align: right;
}

[dir="rtl"] .pbc-currency-side-panel.left {
  left: auto;
  right: 20px;
}

[dir="rtl"] .pbc-currency-side-panel.right {
  right: auto;
  left: 20px;
}

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

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

/* Focus visible for keyboard navigation */
.pbc-currency-trigger:focus-visible,
.pbc-currency-option:focus-visible,
.pbc-currency-button:focus-visible {
  outline: 2px solid #0073aa;
  outline-offset: 2px;
}

/* Ensure focus is always visible for keyboard users */
.pbc-currency-trigger:focus,
.pbc-currency-option:focus,
.pbc-currency-button:focus {
  outline: 2px solid #0073aa;
  outline-offset: 2px;
}

/* Skip focus outline for mouse users */
.pbc-currency-trigger:focus:not(:focus-visible),
.pbc-currency-option:focus:not(:focus-visible),
.pbc-currency-button:focus:not(:focus-visible) {
  outline: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .pbc-currency-trigger,
  .pbc-currency-dropdown,
  .pbc-currency-side-panel {
    border-width: 2px;
  }

  .pbc-currency-option.pbc-active {
    border: 2px solid #fff;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .pbc-currency-trigger,
  .pbc-currency-dropdown,
  .pbc-currency-option,
  .pbc-currency-button,
  .pbc-currency-arrow {
    transition: none;
  }

  .pbc-loading::after,
  .pbc-price-loading::after {
    animation: none;
  }
}

/* ============================================
   Z-Index Layering
   ============================================ */

/* Ensure proper stacking context */
.pbc-currency-switcher-header {
  z-index: 9999;
}

.pbc-currency-dropdown {
  z-index: 10000;
}

.pbc-currency-side-panel {
  z-index: 9998;
}

/* Dropdown backdrop for mobile */
.pbc-currency-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.pbc-currency-backdrop.pbc-active {
  display: block;
  opacity: 1;
}

@media (max-width: 768px) {
  .pbc-currency-backdrop {
    display: block;
  }
}

/* ============================================
   JavaScript-Injected Switcher Styles
   ============================================ */

/* Wrapper for dynamically injected header switcher */
.pbc-currency-dropdown-wrapper {
  position: relative;
}

/* Trigger button for JS-injected switcher */
#pbc-currency-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  font-size: 14px;
  font-family: inherit;
  color: #333;
  cursor: pointer;
  min-width: 110px;
  height: 38px;
  line-height: 1.4;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: border-color 0.2s ease;
}

#pbc-currency-trigger:hover {
  border-color: #999;
}

#pbc-current-flag {
  width: 20px;
  height: 14px;
  object-fit: cover;
  border-radius: 2px;
}

#pbc-current-currency {
  font-weight: 500;
}

#pbc-currency-trigger .pbc-dropdown-arrow {
  margin-left: auto;
  font-size: 12px;
}

/* Dropdown for JS-injected switcher */
#pbc-currency-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  display: none;
  max-height: 300px;
  overflow-y: auto;
  /* Match header button width */
  min-width: 100%;
  width: 115%;
  white-space: nowrap;
  overflow-x: hidden;
}

#pbc-currency-dropdown.pbc-open {
  display: block;
}

/* Currency option items in JS-injected dropdown */
.pbc-currency-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  border-bottom: 1px solid #f0f0f0;
  min-width: 0;
}

.pbc-currency-option:last-child {
  border-bottom: none;
}

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

.pbc-currency-option img {
  width: 20px;
  height: 14px;
  object-fit: cover;
  border-radius: 2px;
  flex-shrink: 0;
}

.pbc-currency-option .pbc-currency-code {
  font-weight: 500;
  flex-shrink: 0;
  min-width: 30px;
}

.pbc-currency-option .pbc-currency-symbol {
  color: #666;
  margin-left: 0 !important;
  flex-shrink: 0;
  font-weight: 500;
}

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

@media print {
  .pbc-currency-switcher-header,
  .pbc-currency-side-panel {
    display: none !important;
  }
}

/* ============================================
   Theme Compatibility Overrides
   ============================================ */

/* Reset common theme conflicts */
.pbc-currency-switcher button {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.pbc-currency-list li {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Ensure flags display correctly */
.pbc-currency-flag img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Header integration styles */
.site-header .pbc-header-switcher-wrapper,
.masthead .pbc-header-switcher-wrapper,
header .pbc-header-switcher-wrapper {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-left: 15px;
}

/* When positioned before cart */
.pbc-header-switcher-wrapper + .site-header-cart,
.pbc-header-switcher-wrapper + .woocommerce-mini-cart,
.pbc-header-switcher-wrapper + .cart-contents {
  margin-left: 15px;
}

/* When positioned after cart */
.site-header-cart + .pbc-header-switcher-wrapper,
.woocommerce-mini-cart + .pbc-header-switcher-wrapper,
.cart-contents + .pbc-header-switcher-wrapper {
  margin-left: 15px;
  margin-right: 0;
}

/* Fixed position fallback styling */
.pbc-header-switcher-wrapper.pbc-fixed-position {
  position: fixed;
  top: 15px;
  right: 15px;
  z-index: 9999;
  background: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  border: 1px solid #e0e0e0;
}

/* Ensure proper spacing in header */
.pbc-currency-switcher-header {
  margin: 0;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

/* Flex container support */
.site-header .pbc-header-switcher-wrapper {
  flex-shrink: 0;
  align-self: center;
}

/* Ensure it doesn't break header layout */
.pbc-header-switcher-wrapper {
  white-space: nowrap;
  box-sizing: border-box;
}

/* Header right area integration */
.header-right .pbc-header-switcher-wrapper,
.site-tools .pbc-header-switcher-wrapper,
.header-tools .pbc-header-switcher-wrapper,
.header-actions .pbc-header-switcher-wrapper {
  margin-left: 0;
  margin-right: 10px;
}

/* Navigation area integration */
.site-navigation .pbc-header-switcher-wrapper,
.main-navigation .pbc-header-switcher-wrapper {
  margin-left: 20px;
  margin-right: 0;
}

/* Responsive header integration */
@media (max-width: 768px) {
  .site-header .pbc-header-switcher-wrapper,
  .masthead .pbc-header-switcher-wrapper,
  header .pbc-header-switcher-wrapper {
    margin-left: 10px;
    margin-right: 5px;
  }

  .pbc-header-switcher-wrapper.pbc-fixed-position {
    top: 10px;
    right: 10px;
    padding: 6px 10px;
  }
}
