/**
 * Global Currency Switcher - Frontend Styles
 * Matches Screenshot 6: Compact rectangular selector, clean white panel, thin border, chevron, flags
 */

:root {
  --gcs-width: auto;
  --gcs-max-height: 280px;
  --gcs-font-size: 14px;
  --gcs-bg: #ffffff;
  --gcs-text: #1f2937;
  --gcs-border: #e5e7eb;
  --gcs-radius: 4px;
  --gcs-hover-bg: #f3f4f6;
  --gcs-hover-text: #111827;
  --gcs-active-bg: #f3f4f6;
  --gcs-active-text: #111827;
  --gcs-flag-width: 20px;
  --gcs-flag-radius: 2px;
}

/* Base Wrapper */
.gcs-switcher-wrapper {
  position: relative;
  display: inline-block;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  font-size: var(--gcs-font-size);
  color: var(--gcs-text);
  line-height: 1.4;
  vertical-align: middle;
  box-sizing: border-box;
}

.gcs-switcher-wrapper *,
.gcs-switcher-wrapper *::before,
.gcs-switcher-wrapper *::after {
  box-sizing: border-box;
}

/* Trigger Button (Closed State - Screenshot 6 match) */
.gcs-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: var(--gcs-width);
  min-height: 38px;
  padding: 6px 12px;
  background-color: var(--gcs-bg);
  color: var(--gcs-text);
  border: 1px solid var(--gcs-border);
  border-radius: var(--gcs-radius);
  cursor: pointer;
  text-align: left;
  user-select: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
  outline: none;
  white-space: nowrap;
}

.gcs-trigger:hover {
  border-color: #cbd5e1;
  background-color: #ffffff;
}

.gcs-trigger:focus-visible {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.gcs-switcher-wrapper.is-open .gcs-trigger {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

/* Trigger Content Inside */
.gcs-trigger-content {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Flags */
.gcs-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: var(--gcs-flag-width);
  height: auto;
}

.gcs-flag img {
  width: var(--gcs-flag-width);
  height: calc(var(--gcs-flag-width) * 0.72);
  object-fit: cover;
  border-radius: var(--gcs-flag-radius);
  display: block;
  box-shadow: 0 0 1px rgba(0, 0, 0, 0.25);
}

/* Typography components */
.gcs-country-name {
  font-weight: 500;
  color: var(--gcs-text);
}

.gcs-symbol {
  font-weight: 600;
  color: var(--gcs-text);
}

.gcs-curr-name {
  color: #6b7280;
  font-size: 0.95em;
}

.gcs-code {
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--gcs-text);
}

.gcs-separator {
  color: #9ca3af;
  margin: 0 2px;
}

/* Chevron */
.gcs-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  flex-shrink: 0;
  margin-left: 4px;
  transition: transform 0.2s ease, color 0.15s ease;
}

.gcs-switcher-wrapper.is-open .gcs-chevron {
  transform: rotate(180deg);
  color: #1f2937;
}

/* Dropdown Panel */
.gcs-dropdown-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 999999;
  min-width: 240px;
  max-width: 380px;
  width: max-content;
  background-color: var(--gcs-bg);
  border: 1px solid var(--gcs-border);
  border-radius: var(--gcs-radius);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  display: none;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.gcs-switcher-wrapper.is-open .gcs-dropdown-panel {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* When opening upwards if near bottom of screen */
.gcs-switcher-wrapper.open-upwards .gcs-dropdown-panel {
  top: auto;
  bottom: calc(100% + 4px);
  transform: translateY(4px);
}

.gcs-switcher-wrapper.open-upwards.is-open .gcs-dropdown-panel {
  transform: translateY(0);
}

/* Dropdown Search Box */
.gcs-search-container {
  position: relative;
  padding: 8px 10px;
  border-bottom: 1px solid var(--gcs-border);
  background-color: #fafafa;
  border-top-left-radius: var(--gcs-radius);
  border-top-right-radius: var(--gcs-radius);
}

.gcs-search-icon {
  position: absolute;
  top: 50%;
  left: 18px;
  transform: translateY(-50%);
  color: #9ca3af;
  pointer-events: none;
  display: flex;
  align-items: center;
}

.gcs-search-input {
  width: 100% !important;
  height: 32px !important;
  padding: 4px 8px 4px 30px !important;
  font-size: 13px !important;
  line-height: 1.4 !important;
  color: var(--gcs-text) !important;
  background-color: #ffffff !important;
  border: 1px solid var(--gcs-border) !important;
  border-radius: 3px !important;
  outline: none !important;
  box-shadow: none !important;
  transition: border-color 0.15s ease;
}

.gcs-search-input:focus {
  border-color: #3b82f6 !important;
}

/* Use My Location Bar */
.gcs-location-action {
  padding: 6px 10px;
  border-bottom: 1px solid #f3f4f6;
  background-color: #ffffff;
}

.gcs-use-location-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 500;
  color: #2563eb;
  background-color: #eff6ff;
  border: 1px solid #dbeafe;
  border-radius: 3px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  outline: none;
}

.gcs-use-location-btn:hover {
  background-color: #dbeafe;
  border-color: #bfdbfe;
}

/* Options List */
.gcs-options-list {
  list-style: none !important;
  margin: 0 !important;
  padding: 4px 0 !important;
  max-height: var(--gcs-max-height);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

/* Scrollbar styling */
.gcs-options-list::-webkit-scrollbar {
  width: 6px;
}

.gcs-options-list::-webkit-scrollbar-track {
  background: #f1f5f9;
}

.gcs-options-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.gcs-options-list::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Single Option Item */
.gcs-option-item {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  margin: 0 !important;
  cursor: pointer;
  color: var(--gcs-text);
  font-size: var(--gcs-font-size);
  line-height: 1.4;
  outline: none;
  user-select: none;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.gcs-option-item:hover,
.gcs-option-item:focus {
  background-color: var(--gcs-hover-bg);
  color: var(--gcs-hover-text);
}

.gcs-option-item.is-selected {
  background-color: var(--gcs-active-bg);
  color: var(--gcs-active-text);
  font-weight: 600;
}

.gcs-option-item.is-hidden {
  display: none !important;
}

/* Option Content */
.gcs-item-content {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gcs-item-content .gcs-country-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Checkmark */
.gcs-check-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #2563eb;
  flex-shrink: 0;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.gcs-option-item.is-selected .gcs-check-icon {
  opacity: 1;
  transform: scale(1);
}

/* No results */
.gcs-no-results {
  padding: 16px 12px;
  text-align: center;
  color: #6b7280;
  font-size: 13px;
}


/* Floating Switcher */
.gcs-floating-switcher {
  position: fixed;
  z-index: 999990;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  border-radius: var(--gcs-radius);
}

.gcs-floating-bottom_right {
  bottom: 24px;
  right: 24px;
}

.gcs-floating-bottom_left {
  bottom: 24px;
  left: 24px;
}

.gcs-floating-switcher .gcs-trigger {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Menu Item Integration */
.menu-item-gcs-switcher {
  display: inline-flex !important;
  align-items: center;
}

.menu-item-gcs-switcher .gcs-switcher-wrapper {
  margin: 0;
}

/* Cart & Checkout Approximate Display */
.gcs-cart-approx {
  font-size: 0.85em;
  color: #64748b;
  font-weight: normal;
  margin-left: 4px;
}

.gcs-cart-total-approx {
  display: block;
  font-size: 0.85em;
  color: #64748b;
  font-weight: normal;
  margin-top: 2px;
}

.gcs-checkout-notice {
  font-size: 14px;
  padding: 12px 18px;
  background-color: #f8fafc;
  border-left: 4px solid #3b82f6;
  color: #1e293b;
  border-radius: 3px;
}

/* RTL Support */
[dir="rtl"] .gcs-trigger {
  text-align: right;
}

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

[dir="rtl"] .gcs-search-icon {
  left: auto;
  right: 18px;
}

[dir="rtl"] .gcs-search-input {
  padding: 4px 30px 4px 8px !important;
}

[dir="rtl"] .gcs-panel-footer {
  text-align: left;
}

/* Responsive adjust for mobile */
@media (max-width: 640px) {
  .gcs-dropdown-panel {
    max-width: calc(100vw - 20px);
  }
}
