/* Base Variables & Theme Config */
:root {
  --font-family: 'Inter', 'Noto Sans SC', system-ui, -apple-system, sans-serif;

  /* Light Theme Variables */
  --bg-gradient: radial-gradient(circle at 0% 0%, #f6f8fa 0%, #eef1f6 100%);
  --card-bg: rgba(255, 255, 255, 0.7);
  --card-border: rgba(255, 255, 255, 0.5);
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent-color: #4f46e5;
  --accent-light: #e0e7ff;
  --shadow-color: rgba(15, 23, 42, 0.05);
  --input-bg: rgba(255, 255, 255, 0.8);
  --input-border: #e2e8f0;
  --dropdown-bg: rgba(255, 255, 255, 0.96);
  --dropdown-hover: #f1f5f9;
  --badge-bg: #f1f5f9;

  /* Ads Colors */
  --ad-bg: #f8fafc;
  --ad-border: #e2e8f0;
  --ad-text: #94a3b8;

  --circle-1-color: rgba(99, 102, 241, 0.12);
  --circle-2-color: rgba(236, 72, 153, 0.12);
}

[data-theme="dark"] {
  /* Dark Theme Variables */
  --bg-gradient: radial-gradient(circle at 0% 0%, #080c14 0%, #0f172a 100%);
  --card-bg: rgba(15, 23, 42, 0.7);
  --card-border: rgba(255, 255, 255, 0.05);
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --accent-color: #6366f1;
  --accent-light: rgba(99, 102, 241, 0.15);
  --shadow-color: rgba(0, 0, 0, 0.3);
  --input-bg: rgba(30, 41, 59, 0.8);
  --input-border: #334155;
  --dropdown-bg: rgba(15, 23, 42, 0.96);
  --dropdown-hover: #1e293b;
  --badge-bg: #1e293b;

  /* Ads Colors */
  --ad-bg: #1e293b;
  --ad-border: #334155;
  --ad-text: #64748b;

  --circle-1-color: rgba(99, 102, 241, 0.06);
  --circle-2-color: rgba(236, 72, 153, 0.06);
}

/* Reset & Global Styling */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-x: hidden;
  position: relative;
  transition: background 0.5s ease;
  padding: 40px 20px;
}

/* Background Decorative Circles */
.background-decor {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
}

.circle {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  animation: float 25s infinite alternate ease-in-out;
}

.circle-1 {
  width: 500px;
  height: 500px;
  background: var(--circle-1-color);
  top: -150px;
  left: -150px;
}

.circle-2 {
  width: 600px;
  height: 600px;
  background: var(--circle-2-color);
  bottom: -200px;
  right: -150px;
  animation-delay: -12s;
}

@keyframes float {
  0% {
    transform: translate(0, 0) scale(1);
  }

  100% {
    transform: translate(60px, 60px) scale(1.1);
  }
}

/* Layout Grid Setup */
.app-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  z-index: 10;
}

/* Main Left and Sidebar Column */
.main-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

.sidebar-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo .icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: var(--accent-light);
  overflow: hidden;
  box-shadow: 0 4px 10px var(--shadow-color);
  flex-shrink: 0;
}

.logo .icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.logo h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.logo .subtitle {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.theme-toggle-btn {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px var(--shadow-color);
  transition: all 0.3s ease;
}

.theme-toggle-btn:hover {
  transform: scale(1.05);
}

.theme-toggle-btn .light-icon {
  display: none;
}

[data-theme="dark"] .theme-toggle-btn .light-icon {
  display: block;
}

[data-theme="dark"] .theme-toggle-btn .dark-icon {
  display: none;
}

/* Ads Box Container */
.ad-container {
  background: var(--ad-bg);
  border: 1px dashed var(--ad-border);
  border-radius: 16px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  max-width: 100%;
  width: 100%;
}

.adsbygoogle {
  max-width: 100% !important;
}

.ad-badge {
  font-size: 10px;
  color: var(--ad-text);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ad-placeholder-content {
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid var(--ad-border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 90px;
  max-width: 100%;
}

.ad-sidebar-rect .ad-placeholder-content {
  min-height: 250px;
  width: 300px;
  max-width: 100%;
}

.ad-mock-text {
  font-size: 12px;
  color: var(--ad-text);
  font-family: monospace;
}

.ad-sidebar-link {
  padding: 14px;
}

.ad-placeholder-content-link {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.mock-link-ad {
  display: block;
  font-size: 13px;
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--accent-light);
  transition: all 0.2s ease;
}

.mock-link-ad:hover {
  transform: translateX(4px);
}

/* Converter Card & Info Cards */
.converter-card,
.info-card {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 10px 40px var(--shadow-color);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.converter-row {
  margin-bottom: 24px;
}

.converter-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.converter-col label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper input {
  width: 100%;
  padding: 18px;
  padding-right: 80px;
  font-size: 28px;
  font-weight: 700;
  border-radius: 18px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-primary);
  outline: none;
  transition: all 0.3s ease;
}

.input-wrapper input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 4px var(--accent-light);
}

.input-wrapper input::-webkit-outer-spin-button,
.input-wrapper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.input-wrapper input[type=number] {
  -moz-appearance: textfield;
}

.input-currency-symbol {
  position: absolute;
  right: 20px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-muted);
}

/* Currency Selectors & Swap layout */
.currency-selectors-wrapper {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  position: relative;
}

.search-tip-text {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 24px;
  text-align: center;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.selector-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.selector-box .label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.selector-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 18px;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
  text-align: left;
  transition: all 0.3s ease;
}

.selector-trigger:hover {
  border-color: var(--accent-color);
}

.selector-trigger .chevron {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.3s ease;
}

.selector-box.active .selector-trigger .chevron {
  transform: rotate(180deg);
}

.selector-trigger .flag {
  font-size: 22px;
  flex-shrink: 0;
}

.selector-trigger .code {
  font-weight: 700;
  flex-shrink: 0;
}

.selector-trigger .name {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: 2px;
}

/* Swap button */
.swap-button {
  background: var(--accent-color);
  border: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  margin-top: 22px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.swap-button:hover {
  transform: rotate(180deg) scale(1.05);
  background: #4338ca;
}

/* Dropdowns */
.currency-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 320px;
  max-height: 320px;
  background: var(--dropdown-bg);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
  display: none;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

#to-selector-box .currency-dropdown {
  left: auto;
  right: 0;
}

.selector-box.active .currency-dropdown {
  display: flex;
}

.search-box {
  padding: 12px;
  border-bottom: 1px solid var(--input-border);
}

.dropdown-search {
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
  border-radius: 12px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-primary);
  outline: none;
}

.currency-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

.currency-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s ease;
}

.currency-item:hover,
.currency-item.highlighted {
  background: var(--dropdown-hover);
}

.currency-item.highlighted {
  border-left: 3px solid var(--accent-color);
  padding-left: 15px;
}

.currency-item.selected {
  background: var(--accent-light);
  color: var(--accent-color);
  font-weight: 600;
}

.currency-item .flag {
  font-size: 22px;
}

.currency-item .code {
  font-weight: 700;
}

.currency-item .name {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Result display */
.result-display {
  background: rgba(99, 102, 241, 0.04);
  border-radius: 20px;
  padding: 24px;
  text-align: center;
  margin-bottom: 24px;
  border: 1px dashed rgba(99, 102, 241, 0.2);
}

.result-display .formula {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 8px;
}

.result-display .converted-amount {
  font-size: 42px;
  font-weight: 800;
  color: var(--accent-color);
  letter-spacing: -1.5px;
  line-height: 1.2;
}

.result-display .update-time {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
}

/* Quick shortcuts */
.quick-shortcuts {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.shortcut-btn {
  flex: 1;
  padding: 12px 0;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-secondary);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.shortcut-btn:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
  background: var(--accent-light);
}

/* Section descriptions inside Cards */
.info-card h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.section-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* Comparison Table Design */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.comparison-table th,
.comparison-table td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--input-border);
}

.comparison-table th {
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.01);
}

.comparison-table td .flag {
  margin-right: 8px;
  font-size: 18px;
}

.comparison-table tr:hover td {
  background: rgba(99, 102, 241, 0.02);
}

/* FAQ Grid design */
.faq-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.faq-item h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.faq-item p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Quick Rates Grid */
.quick-rates-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.quick-rate-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 14px;
  font-size: 13px;
  transition: all 0.2s ease;
}

.quick-rate-item:hover {
  transform: translateY(-2px);
  border-color: var(--accent-color);
}

.quick-rate-item .pair {
  font-weight: 600;
  color: var(--text-secondary);
}

.quick-rate-item .value {
  font-weight: 700;
  color: var(--text-primary);
}

/* Conversion History List */
.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-history {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 16px 0;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 12px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.history-item:hover {
  border-color: var(--accent-color);
  background: var(--accent-light);
}

.history-item .details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-item .details .amount {
  font-weight: 700;
  color: var(--text-primary);
}

.history-item .details .pair {
  font-size: 11px;
  color: var(--text-muted);
}

.history-item .arrow-icon {
  font-size: 14px;
  color: var(--accent-color);
}

.clear-btn {
  width: 100%;
  background: transparent;
  border: 1px solid var(--input-border);
  color: var(--text-secondary);
  padding: 10px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 14px;
  transition: all 0.2s ease;
}

.clear-btn:hover {
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.2);
}

/* Responsive Breakpoints */
@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .faq-grid {
    grid-template-columns: 1fr;
  }

  .ad-banner-top {
    max-width: 100%;
    width: 100%;
  }

  .ad-banner-top .adsbygoogle {
    display: none !important;
  }

  .ad-banner-top .ad-mock-text {
    display: none;
  }

  .ad-banner-top .ad-placeholder-content {
    min-height: 60px;
  }

  .ad-banner-top .ad-placeholder-content::after {
    content: "Google Ads (Responsive Mobile Banner)";
    font-size: 12px;
    color: var(--ad-text);
    font-family: monospace;
  }
}

@media (max-width: 480px) {
  body {
    padding: 20px 10px;
  }

  .converter-card,
  .info-card {
    padding: 20px;
  }

  .input-wrapper input {
    font-size: 24px;
  }

  .currency-selectors-wrapper {
    flex-direction: column;
    gap: 8px;
  }

  .swap-button {
    margin-top: 0;
    align-self: center;
    transform: rotate(90deg);
  }

  .swap-button:hover {
    transform: rotate(270deg) scale(1.05);
  }

  .currency-dropdown {
    width: 100%;
  }

  .comparison-table th,
  .comparison-table td {
    padding: 10px 8px;
    font-size: 12px;
  }
}