/* ===========================
   Design Tokens
   =========================== */
:root {
  --color-primary: #08115A;
  --color-primary-light: #3B82F6;
  --color-primary-dark: #1E2D5B;
  --color-bg: #F9FAFB;
  --color-white: #FFFFFF;
  --color-text: #111827;
  --color-text-light: #848fa7;
  --color-border: #E5E7EB;
  --color-border-focus: #3B82F6;
  --color-green: #059669;
  --color-red: #DC2626;
  --color-hover: #F3F4F6;
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1), 0 4px 10px rgba(0,0,0,0.05);
  --container-max: 960px;
}

/* ===========================
   Reset & Base
   =========================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  background: var(--color-primary);
}

body {
  font-family: var(--font-stack);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
input { font-family: inherit; }

.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 1rem;
}

/* ===========================
   Navbar
   =========================== */
.navbar {
  background: var(--color-primary);
  padding: 0.75rem 0;
  z-index: 100;
}

.navbar-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.navbar-logo {
  color: var(--color-white);
  text-decoration: none;
}

.navbar-logo:hover { text-decoration: none; }

.logo-text {
  font-size: 1.2rem;
  font-weight: 400;
}

.logo-dot {
  color: #93C5FD;
}

/* ===========================
   Language Selector
   =========================== */
.lang-selector {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
}

.lang-trigger {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  background: none;
  border: none;
  padding: 0.375rem 0.5rem;
  color: rgba(255, 255, 255, 0.8);
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
}

.lang-trigger:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.lang-flag {
  border-radius: 2px;
  display: block;
  flex-shrink: 0;
}

.lang-arrow {
  flex-shrink: 0;
  transition: transform 0.15s;
}

.lang-selector.open .lang-arrow {
  transform: rotate(180deg);
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 185px;
  overflow: hidden;
  z-index: 200;
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  color: var(--color-text);
  text-decoration: none;
  cursor: pointer;
  user-select: none;
}

a.lang-option:hover {
  background: var(--color-hover);
  text-decoration: none;
}

.lang-option--active {
  background: var(--color-hover);
  font-weight: 600;
}

.lang-option--disabled {
  color: var(--color-text-light);
  cursor: default;
}

.lang-soon {
  font-size: 0.72rem;
  color: var(--color-text-light);
  font-weight: 400;
  margin-left: 0.2rem;
}

/* ===========================
   Hero
   =========================== */
.hero {
  background: var(--color-primary);
  color: var(--color-white);
  padding: 2rem 0 0;
  text-align: center;
}

.hero-title {
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

/* ===========================
   Converter Widget
   =========================== */
.converter-section {
  background: linear-gradient(to bottom, var(--color-primary) 50%, var(--color-bg) 50%);
  padding: 1.5rem 0 2rem;
  position: relative;
  z-index: 10;
}

.converter {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.converter-row {
  display: flex;
  align-items: stretch;
  gap: 1rem;
}

.converter-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.converter-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-light);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.converter-input-group {
  display: flex;
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  overflow: visible;
  position: relative;
  transition: border-color 0.15s;
  flex: 1;
}

.converter-input-group:focus-within {
  border-color: var(--color-border-focus);
}

.converter-amount {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  font-size: 1.5rem;
  font-weight: 600;
  padding: 1rem;
  background: transparent;
  color: var(--color-text);
  direction: ltr;
  unicode-bidi: bidi-override;
}

.converter-swap-col {
  display: flex;
  align-items: center;
  padding-top: calc(12px * 1.6 + 4px);
}

.swap-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  background: var(--color-white);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.swap-btn:hover {
  background: var(--color-primary);
  color: var(--color-white);
  border-color: var(--color-primary);
}

/* Converter Footer (rate + copy button) */
.converter-footer {
  display: grid;
  grid-template-columns: 1fr;
  align-items: end;
}

.converter-footer > * {
  grid-column: 1;
  grid-row: 1;
}

.converter-rate {
  text-align: center;
}

.rate-text {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-text);
}

.rate-minor {
  color: var(--color-text-light);
}

.rate-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-green);
  margin-right: 0.5rem;
  position: relative;
  top: -0.2em;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.rate-updated {
  font-size: 1rem;
  color: var(--color-text-light);
  margin-top: 0.25rem;
}

.copy-link-btn {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0;
  border: none;
  background: none;
  color: var(--color-text-light);
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.15s;
  white-space: nowrap;
  justify-self: end;
}

.copy-link-btn:hover {
  color: var(--color-primary);
}

.rate-text-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.rate-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: rate-spin 0.7s linear infinite;
  flex-shrink: 0;
  pointer-events: none;
}

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

@property --border-angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

.rate-updated-anim::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  background: conic-gradient(from var(--border-angle), var(--color-primary), var(--color-primary-light), var(--color-primary));
  -webkit-mask:
    linear-gradient(#fff, #fff) padding-box,
    linear-gradient(#fff, #fff) border-box;
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#fff, #fff) padding-box,
    linear-gradient(#fff, #fff) border-box;
  mask-composite: exclude;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  animation: border-anim 1.8s ease-in-out forwards;
}

@keyframes border-anim {
  0%   { opacity: 0; --border-angle: 0deg; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { opacity: 0; --border-angle: 360deg; }
}

.copy-link-btn.copied {
  color: var(--color-green);
}

/* ===========================
   Combobox (Custom Dropdown)
   =========================== */
.combobox {
  position: relative;
}

.combobox-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border: none;
  border-right: 2px solid var(--color-border);
  background: transparent;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  transition: background 0.15s;
  border-radius: calc(var(--radius) - 2px) 0 0 calc(var(--radius) - 2px);
  height: 100%;
}

.combobox-trigger:hover {
  background: var(--color-hover);
}

.combobox-flag {
  width: 24px;
  height: 18px;
  border-radius: 2px;
  object-fit: cover;
  flex-shrink: 0;
}

.combobox-code {
  font-size: 1.25rem;
  display: inline-block;
  width: 3.5ch;
  text-align: left;
}

.combobox-arrow {
  width: 12px;
  height: 8px;
  opacity: 0.5;
  flex-shrink: 0;
  transition: transform 0.15s;
  margin-left: 0.25rem;
}

.combobox[data-open] .combobox-arrow {
  transform: rotate(180deg);
}

.combobox-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 280px;
  max-height: 320px;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.combobox-dropdown[hidden] {
  display: none;
}

.combobox-search-wrap {
  padding: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.combobox-search {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  outline: none;
}

.combobox-search:focus {
  border-color: var(--color-border-focus);
}

.combobox-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 0.25rem 0;
}

.combobox-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: background 0.1s;
}

.combobox-item:hover,
.combobox-item[data-highlighted] {
  background: var(--color-hover);
}

.combobox-item[data-selected] {
  background: #EFF6FF;
  font-weight: 600;
}

.combobox-item-flag {
  width: 22px;
  height: 16px;
  border-radius: 2px;
  object-fit: cover;
  flex-shrink: 0;
}

.combobox-item-code {
  font-weight: 600;
  font-size: 0.9rem;
  min-width: 36px;
}

.combobox-item-name {
  color: var(--color-text-light);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===========================
   Ad Banner
   =========================== */
.ad-section {
  padding: 0 0 1rem;
}

.ad-banner {
  background:
    linear-gradient(var(--color-white), var(--color-white)) padding-box,
    linear-gradient(135deg, var(--color-primary), var(--color-primary-light)) border-box;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
}

.ad-banner-content {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.ad-banner[hidden] { display: none; }

.ad-logo {
  flex-shrink: 0;
}

.ad-logo img {
  height: 40px;
  width: auto;
}

.ad-body {
  flex: 1;
  font-size: 0.95rem;
  color: var(--color-text);
  line-height: 1.5;
}

.ad-cta {
  display: inline-flex;
  align-items: center;
  padding: 0.625rem 1.25rem;
  background: var(--color-primary);
  color: var(--color-white);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s;
  flex-shrink: 0;
}

.ad-cta:hover {
  background: var(--color-primary-light);
  text-decoration: none;
}

@media (max-width: 768px) {
  .ad-banner {
    padding: 1.25rem;
  }

  .ad-banner-content {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
  }
}

/* ===========================
   Chart
   =========================== */
.chart-section {
  padding: 2rem 0;
}

.chart-timeframes {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.tf-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-white);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-light);
  transition: all 0.15s;
  min-width: 44px;
  min-height: 44px;
}

.tf-btn:hover {
  border-color: var(--color-primary-light);
  color: var(--color-primary);
}

.tf-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-white);
}

.chart-wrap {
  position: relative;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  min-height: 300px;
}

.chart-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-light);
  font-size: 1rem;
  background: var(--color-white);
  border-radius: var(--radius);
}

.chart-loading[hidden] { display: none; }

#rate-chart {
  width: 100% !important;
  max-height: 350px;
}

/* ===========================
   Section Titles
   =========================== */
.section-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--color-text);
}

/* ===========================
   SEO Content
   =========================== */
.seo-section {
  padding: 2rem 0;
}

.seo-section h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.seo-section p {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--color-text);
  margin-bottom: 1rem;
}

/* ===========================
   Conversion Tables
   =========================== */
.tables-section {
  padding: 2rem 0;
  border-top: 1px solid var(--color-border);
}

.tables-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.conversion-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
}

.conversion-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  background: var(--color-primary);
  color: var(--color-white);
  font-weight: 600;
  font-size: 0.95rem;
}

.conversion-table th:first-child {
  border-radius: var(--radius) 0 0 0;
}

.conversion-table th:last-child {
  border-radius: 0 var(--radius) 0 0;
}

.conversion-table td {
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.conversion-table tr:nth-child(even) td {
  background: var(--color-hover);
}

.conversion-table a {
  color: var(--color-primary);
  font-weight: 500;
}

.conversion-table a:hover {
  text-decoration: underline;
}

/* ===========================
   Stats Section
   =========================== */

.stats-section {
  padding: 2rem 0;
  border-top: 1px solid var(--color-border);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: center;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
}

.stats-table thead th {
  text-align: left;
  padding: 0.75rem 1rem;
  background: var(--color-primary);
  color: var(--color-white);
  font-weight: 600;
  font-size: 0.95rem;
}

.stats-table thead th:first-child {
  border-radius: var(--radius) 0 0 0;
}

.stats-table thead th:last-child {
  border-radius: 0 var(--radius) 0 0;
}

.stats-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.stats-table td:first-child {
  font-weight: 500;
  color: var(--color-text-light);
}

.stats-table td:not(:first-child) {
  font-weight: 600;
}

.stat-positive {
  color: var(--color-green);
}

.stat-negative {
  color: var(--color-red);
}

.stats-text-col .section-title {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.stats-text-col p {
  color: var(--color-text-light);
  line-height: 1.6;
  margin-bottom: 1rem;
}

/* ===========================
   Related Conversions
   =========================== */
.related-section {
  padding: 2rem 0;
  border-top: 1px solid var(--color-border);
}

.related-links {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem 1.5rem;
}

.related-links a {
  display: block;
  padding: 0.5rem 0;
  font-size: 1rem;
  color: var(--color-primary);
}

.related-links a:hover {
  text-decoration: underline;
}

/* ===========================
   FAQs (Accordion)
   =========================== */
.faq-section {
  padding: 2rem 0;
  border-top: 1px solid var(--color-border);
}

.faq-list {
  max-width: 800px;
}

.faq-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  overflow: hidden;
}

.faq-question {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border: none;
  background: var(--color-white);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
  min-height: 44px;
}

.faq-question:hover {
  background: var(--color-hover);
}

.faq-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  transition: transform 0.2s;
}

.faq-item[open] .faq-icon {
  transform: rotate(180deg);
}

.faq-answer {
  padding: 0.75rem 1.25rem 1rem;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--color-text);
}

.faq-answer[hidden] { display: none; }

/* ===========================
   Contact Form
   =========================== */
.contact-field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.contact-field label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
}

.contact-field input,
.contact-field textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  color: var(--color-text);
  background: var(--color-white);
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.contact-field input:focus,
.contact-field textarea:focus {
  outline: none;
  border-color: var(--color-border-focus);
}

.contact-field textarea {
  resize: vertical;
}

.contact-submit {
  padding: 0.75rem 1.75rem;
  background: var(--color-primary);
  color: var(--color-white);
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.contact-submit:hover {
  opacity: 0.9;
}

.contact-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ===========================
   Footer
   =========================== */
.footer {
  margin-top: auto;
  background: var(--color-primary);
  color: var(--color-white);
  padding: 2rem 0;
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  margin-bottom: 1rem;
}

.footer-links a {
  color: #D1D5DB;
  font-size: 0.9rem;
}

.footer-links a:hover {
  color: var(--color-white);
  text-decoration: underline;
}

.footer-copy {
  font-size: 0.85rem;
  color: #9CA3AF;
}

/* ===========================
   Responsive
   =========================== */
@media (max-width: 768px) {
  .hero-title {
    font-size: 1.75rem;
  }

  .converter {
    padding: 1.5rem 1.25rem 2rem 1.25rem;
  }

  .converter-row {
    flex-direction: column;
    gap: 0.75rem;
  }

  .converter-swap-col {
    order: 0;
    padding: 0;
    margin-bottom: calc(-12px * 1.6 - 4px);
    align-self: center;
  }

  .swap-btn {
    width: 44px;
    height: 44px;
  }

  .swap-btn svg {
    transform: rotate(90deg);
  }

  .copy-link-btn {
    display: none;
  }

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

  .tables-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .related-links {
    grid-template-columns: repeat(3, 1fr);
  }

  .section-title {
    font-size: 1.375rem;
  }

  .combobox-dropdown {
    width: 260px;
  }
}

@media (max-width: 480px) {
  .converter-amount {
    font-size: 20px;
  }

  .rate-text {
    font-size: 24px;
  }

  .related-links {
    grid-template-columns: 1fr 1fr;
  }

  .footer-links {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }
}
