/* ===========================
   Design Tokens
   =========================== */
:root {
  --color-primary: #1E3A8A;
  --color-primary-light: #3B82F6;
  --color-primary-dark: #1E2D5B;
  --color-bg: #F9FAFB;
  --color-white: #FFFFFF;
  --color-text: #111827;
  --color-text-light: #6B7280;
  --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: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --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%;
}

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;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

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

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

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

.logo-text {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

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

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

.hero-sub {
  font-size: 1.125rem;
  opacity: 0.9;
}

/* ===========================
   Converter Widget
   =========================== */
.converter-section {
  margin-top: -1.5rem;
  padding-bottom: 2rem;
  position: relative;
  z-index: 10;
}

.converter {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
}

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

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

.converter-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-light);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.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.25rem;
  font-weight: 600;
  padding: 0.75rem 1rem;
  background: transparent;
  color: var(--color-text);
}

.converter-swap-col {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 0.25rem;
}

.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-rate {
  text-align: center;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
}

.rate-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-primary);
}

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

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

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

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

.combobox-code {
  font-size: 1.05rem;
}

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

.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: 0.95rem;
  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: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}

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

/* ===========================
   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;
}

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

.related-links {
  display: grid;
  grid-template-columns: repeat(3, 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 1.25rem 1rem;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--color-text);
}

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

/* ===========================
   Footer
   =========================== */
.footer {
  margin-top: auto;
  background: var(--color-primary-dark);
  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;
  }

  .hero-sub {
    font-size: 1rem;
  }

  .converter {
    padding: 1.25rem;
  }

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

  .converter-swap-col {
    order: 0;
    padding: 0;
  }

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

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

  .converter-amount {
    font-size: 1.125rem;
  }

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

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

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

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

@media (max-width: 480px) {
  .related-links {
    grid-template-columns: 1fr;
  }

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