/* Base styles */
:root {
  --bg-color: #ffffff;
  --background-color-rgb: 255, 255, 255;
  --card-bg: #ffffff;
  --rate-card-bg: #f8f9fa;
  --text-color: #333333;
  --secondary-text: #666666;
  --header-bg: #ffffff;
  --footer-bg: #f8f9fa;
  --link-color: #007bff;
  --link-hover-color: #0056b3;
}

body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 20px;
  line-height: 1.6;
  transition: background-color 0.3s, color 0.3s;
  background-color: var(--bg-color);
  color: var(--text-color);
  /* Adjust body padding to prevent content from being hidden by sticky banners */
  padding-top: 0;
  padding-bottom: 0;
}

/* Mobile-first layout */
header {
  max-width: 800px;
  margin: 0 auto;
  padding: 10px 0;
  background-color: var(--header-bg);
  transition: background-color 0.3s;
  text-align: center;
}

main {
  max-width: 800px;
  margin: 20px auto;
}

footer {
  max-width: 800px;
  margin: 20px auto;
  padding: 20px 0;
  background-color: var(--footer-bg);
  transition: background-color 0.3s;
  text-align: center;
  font-size: 0.9rem;
  color: var(--secondary-text);
}

footer p {
  margin: 0;
  padding: 0;
}

.footer-separator {
  margin: 0 8px;
  color: var(--secondary-text);
}

a {
  color: var(--link-color);
  transition: color 0.3s;
}

a:hover {
  color: var(--link-hover-color);
}

h1 {
  font-size: 2rem;
  margin: 0;
}

#timestamp {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 1.5rem;
}

/* Converter card styles */
.converter-card {
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  padding: 24px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  margin: 0 auto;
}

.title {
  color: var(--text-color);
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 24px;
}

.rates {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 32px;
  margin-bottom: 16px;
  width: 100%;
}

.rates > div {
  text-align: center;
}

.rate-value {
  font-size: 35px;
  font-weight: bold;
  color: var(--link-color);
  margin-bottom: 8px;
  text-align: center;
}

.rate-label {
  color: var(--secondary-text);
  font-size: 16px;
  text-align: center;
}

@media (max-width: 480px) {
  .converter-card {
    padding: 16px;
  }

  .rates {
    gap: 16px;
    margin: 0 auto 16px;
  }
}

.spread {
  color: #ff0000;
  font-size: 14px;
  margin-bottom: 8px;
}

.source {
  color: var(--secondary-text);
  font-size: 12px;
  margin-bottom: 24px;
}

.converter-section {
  border-top: 1px solid var(--secondary-text);
  padding-top: 24px;
}

.converter-title {
  color: var(--text-color);
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 16px;
}

.input-field {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--link-color);
  border-radius: 4px;
  text-align: center;
  margin-bottom: 16px;
  font-size: 14px;
  background-color: var(--bg-color);
  color: var(--text-color);
}

.conversion-result {
  font-size: 14px;
  color: var(--text-color);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
  flex-wrap: nowrap;
}

.result-value {
  font-weight: 1000;
  color: var(--text-color);
  display: inline-block;
  margin: 0 2px;
}

@media (max-width: 768px) {
  .conversion-result {
    font-size: 13px;
  }

  .result-line {
    gap: 3px;
  }
}

/* Rates section styles */
.rates-section {
  margin: 20px 0;
  padding: 15px;
  background-color: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#dolar-libre-rates {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rate-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background-color: var(--rate-card-bg);
  border-radius: 6px;
}

.rate-type {
  font-weight: bold;
  color: var(--text-color);
}

.rates-section .rate-value {
  font-size: 1.1em;
  color: #007bff;
  font-variant-numeric: tabular-nums;
  font-family: "Courier New", monospace;
  min-width: 8ch;
  display: inline-block;
  text-align: right;
}

.rate-timestamp {
  text-align: right;
  font-size: 0.9em;
  color: var(--secondary-text);
  margin-top: 10px;
}

/* Format numbers with consistent width and alignment */
#dolar-libre-buy,
#dolar-libre-sell {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  font-family: "Courier New", monospace;
  min-width: 8ch;
  text-align: center;
  display: inline-block;
}

/* Theme styles */
[data-theme="light"] {
  --bg-color: #ffffff;
  --card-bg: #ffffff;
  --rate-card-bg: #f8f9fa;
  --text-color: #333333;
  --secondary-text: #666666;
}

[data-theme="dark"] {
  --bg-color: #1a1a1a;
  --card-bg: #2d2d2d;
  --rate-card-bg: #3d3d3d;
  --text-color: #f5f5f5;
  --secondary-text: #aaaaaa;
  --header-bg: #2d2d2d;
  --footer-bg: #1a1a1a;
  --link-color: #64b5f6;
  --link-hover-color: #42a5f5;
}

/* Settings section */
.settings-section {
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin: 20px 0;
  padding: 0;
  max-width: 800px;
  width: 100%;
}

.settings-section.collapsed .settings-content {
  display: none;
}

.settings-header {
  padding: 15px 20px;
  cursor: pointer;
  background: var(--rate-card-bg);
  color: var(--text-color);
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 8px;
  margin-bottom: 0;
}

.settings-header::after {
  content: '▼';
  font-size: 12px;
  transition: transform 0.3s ease;
}

.settings-section.collapsed .settings-header::after {
  transform: rotate(-90deg);
}

.settings-content {
  padding: 20px;
}

.language-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 15px;
}

.language-links a {
  text-decoration: none;
  color: var(--link-color);
  padding: 5px 10px;
  border-radius: 4px;
  background: var(--rate-card-bg);
}

.language-links a:hover {
  color: var(--link-hover-color);
  background: var(--bg-color);
}

.save-language {
  margin-bottom: 15px;
}

.save-language label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-color);
  cursor: pointer;
}

/* Theme toggle button */
#theme-toggle {
  padding: 10px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background-color: #007bff;
  color: white;
  font-size: 1.2rem;
  display: block;
  margin: 0 auto;
}

/* Chart section styles */
.chart-section {
  margin: 20px 0;
  padding: 15px;
  background-color: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
}

#price-chart {
  width: 100%;
  height: 600px;
  background-color: var(--rate-card-bg);
  border-radius: 6px;
  padding: 10px 10px 30px 10px;
  margin: 0;
  transition: background-color 0.3s;
  box-sizing: border-box;
}

/* Calculator section styles */
.calculator-section {
  margin: 20px 0;
  padding: 15px;
  background-color: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.calculator {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 20px;
  min-height: 100px;
}

.input-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.input-line span {
  color: var(--text-color);
  white-space: nowrap;
}

.calculator input {
  padding: 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
  color: var(--text-color);
  width: 80px;
}

.results-container {
  display: flex;
  flex-direction: column;
  gap: 0px;
  position: relative;
  padding-left: 0px;
}

.result-line {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
}

.result-line span {
  color: var(--text-color);
  white-space: nowrap;
}

.result-line span:first-child {
  width: auto;
}

.result-value {
  display: flex;
  gap: 5px;
  align-items: center;
}

.result-line #buy-result,
.result-line #sell-result {
  color: #007bff;
  font-weight: bold;
  width: auto;
  text-align: right;
  margin-left: 0px;
}

.result-line.top {
  transform: none;
}

.result-line.bottom {
  transform: none;
}

[data-theme="dark"] .calculator input {
  color: #000;
  background-color: #fff;
}

/* Calculator responsive styles */
@media (max-width: 768px) {
  .calculator {
    flex-direction: column;
    align-items: flex-start;
    padding: 15px;
    gap: 20px;
  }

  .results-container {
    padding-left: 0;
    gap: 0px;
    width: 100%;
  }

  .result-line {
    flex-direction: row;
    align-items: center;
    gap: 5px;
    margin: 0;
    transform: none !important;
  }

  .result-line span:first-child {
    width: auto;
  }

  .result-value {
    width: auto;
    justify-content: flex-start;
  }

  .result-line #buy-result,
  .result-line #sell-result {
    width: auto;
    margin-left: 0;
  }
}

/* Chart responsive styles */
@media (min-width: 601px) {
  #price-chart {
    padding: 15px;
  }

  .apexcharts-canvas {
    width: 100% !important;
  }
}

@media (max-width: 600px) and (orientation: portrait) {
  #price-chart {
    width: 100%;
    height: 100vh;
    margin: 0;
    padding: 10px;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
  }

  [data-theme="dark"] #price-chart {
    background: var(--card-bg);
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  #price-chart {
    height: 70vh;
    padding: 10px;
  }

  .apexcharts-toolbar {
    transform: scale(0.8);
    transform-origin: right top;
  }
}

/* Responsive design */
@media (min-width: 768px) {
  h1 {
    font-size: 2.5rem;
  }

  #timestamp {
    font-size: 1rem;
  }
}

/* Additional chart styles */
.apexcharts-tooltip {
  background: var(--background-color) !important;
  color: var(--text-color) !important;
  border: 1px solid var(--secondary-text) !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

.apexcharts-tooltip .apexcharts-tooltip-title {
  color: #000000 !important;
  /* Darker color for date */
  font-weight: bold;
  margin-bottom: 4px;
}

.apexcharts-legend {
  position: relative !important;
  top: 0 !important;
  left: 0 !important;
}

.apexcharts-legend-text {
  color: var(--text-color) !important;
  font-size: 14px !important;
}

.apexcharts-xaxis-label,
.apexcharts-yaxis-label {
  color: var(--text-color) !important;
  font-size: 12px !important;
}

.apexcharts-gridline {
  stroke: var(--secondary-text) !important;
}

.apexcharts-toolbar {
  z-index: 10 !important;
}

/* Light mode input field background */
[data-theme="light"] .input-field {
  background: #f7f7f7;
  color: #222;
  border-color: #4da3ff;
}

/* Timestamp two-line styling */
.timestamp-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.timestamp-main {
  font-size: 1rem;
  color: var(--text-color, #fff);
  line-height: 1.2;
}

.timestamp-detail {
  font-size: 0.92em;
  color: var(--secondary-text, #b0b0b0);
  margin-top: 2px;
  line-height: 1.1;
}

/* === Main Card (Rates + Calculator) === */
.main-card {
  background: var(--card-bg, #232323);
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18);
  padding: 36px 32px 32px 32px;
  max-width: 520px;
  margin: 40px auto 32px auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.main-card-title {
  font-size: 2.5rem; /* Equivalent to h1 on larger screens */
  font-weight: bold;
  color: #4da3ff !important; /* Same blue as .main-card-rate-value, with !important */
  text-align: center;
  margin-bottom: 2px; /* Reduced margin to bring subtitles closer */
  letter-spacing: 0.5px;
}

.main-card-subtitle {
  font-size: 1.2rem; /* Adjust font size as needed */
  font-weight: 500;
  color: var(--secondary-text, #b0b0b0); /* Apply the gray color */
  text-align: center;
  margin-top: 0; /* Remove top margin */
  margin-bottom: 2px; /* Reduce bottom margin to bring them closer */
}

.main-card-official-rate {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 4px;
  margin-bottom: 8px;
  border: 1px solid var(--secondary-text, #b0b0b0);
  border-radius: 6px;
  padding: 12px 16px;
}

.main-card-official-rate-label {
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--secondary-text, #b0b0b0);
  text-decoration: underline;
  text-align: center;
}

.main-card-official-rate-value {
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--secondary-text, #b0b0b0);
  text-align: center;
}

.main-card-rates-row {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-top: 10px;
  margin-bottom: 0.5rem;
  gap: 32px;
}

.main-card-rate {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1 1 0;
}

.main-card-rate-value {
  font-size: 2.6rem;
  font-weight: 700;
  color: #4da3ff;
  margin-bottom: 0.2rem;
  letter-spacing: 1px;
}

.main-card-rate-label {
  font-size: 1.1rem;
  color: var(--secondary-text, #b0b0b0);
  font-weight: 500;
  margin-bottom: 0.2rem;
}

.main-card-info-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  font-size: 0.98rem;
  color: var(--secondary-text, #b0b0b0);
  margin-bottom: 18px;
}

/* Copy button and notification styles */
.copy-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 10px; /* Space below the timestamp */
}

.copy-button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px;
  color: var(--secondary-text, #b0b0b0); /* Use secondary text color for icon */
  transition: color 0.2s;
}

.copy-button:hover {
  color: var(--text-color, #fff); /* Change color on hover */
}

.copy-notification {
  font-size: 0.8rem;
  color: yellow; /* Yellow color for notification */
  margin-top: 5px;
  visibility: hidden; /* Initially hidden */
}

.main-card-divider {
  border: none;
  border-top: 1.5px solid #444;
  width: 100%;
  margin: 18px 0 18px 0;
}

.main-card-calculator {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.main-card-calculator-title {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--text-color, #fff);
  text-align: center;
  margin-bottom: 12px;
}

.main-card-calculator-input-row {
  width: 100%;
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.input-field {
  width: 100%;
  font-size: 1.15rem;
  padding: 10px 14px;
  border: 2px solid #4da3ff;
  border-radius: 6px;
  background: var(--input-bg, #181818);
  color: var(--text-color, #fff);
  outline: none;
  transition: border-color 0.2s;
}

.input-field:focus {
  border-color: #7dc3ff;
}

.conversion-result {
  width: 100%;
  font-size: 1.05rem;
  color: var(--secondary-text, #b0b0b0);
  text-align: center;
  margin-top: 2px;
  margin-bottom: 2px;
}

.main-card-no-rate {
  color: var(--secondary-text, #b0b0b0);
  text-align: center;
  font-size: 1.1rem;
  margin-bottom: 18px;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .main-card {
    padding: 18px 6vw 18px 6vw;
    max-width: 98vw;
  }
  .main-card-title {
    font-size: 2.5rem; /* Equivalent to h1 on smaller screens */
    color: #4da3ff !important; /* Ensure color is applied for mobile as well, with !important */
  }
  .main-card-rates-row {
    gap: 12px;
  }
  .main-card-rate-value {
    font-size: 1.6rem;
  }
  .main-card-info-row {
    font-size: 0.92rem;
    flex-direction: column;
    gap: 2px;
  }
}

/* Sticky Banner Styles */
.sticky-banner {
  position: fixed; /* Changed from sticky to fixed */
  left: 0;
  width: 100%;
  background-color: #1a4a6a; /* Darker background for banners in light mode.. */
  color: #ffffff; /* Light text for dark banner background in light mode */
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  z-index: 1000; /* Ensure banner is on top of other content */
  text-decoration: none; /* Remove underline from link */
  transition: background-color 0.3s;
}

.sticky-banner.top-banner {
  top: 0;
  border-bottom: 1px solid #e0e0e0;
}

.sticky-banner.bottom-banner {
  bottom: 0;
  border-top: 1px solid #e0e0e0;
}

.banner-logo {
  height: 30px; /* Adjust logo size as needed */
  width: auto;
  border-radius: 4px;
}

.banner-text {
  font-size: 1rem;
  font-weight: bold;
  text-align: center;
  /* Removed explicit color to rely on theme-specific rules */
  transition: color 0.3s;
}

.sticky-banner:hover .banner-text {
  color: #87CEEB; /* Light blue for hover in light mode */
}

[data-theme="dark"] .sticky-banner:hover .banner-text {
  color: #0056b3; /* Darker blue for hover in dark mode */
}

/* Dark mode adjustments for banners */
[data-theme="dark"] .sticky-banner {
  background-color: #e0f2f7; /* Lighter background for banners in dark mode */
  color: #333333; /* Dark text for light banner background in dark mode */
}


/* Responsive adjustments for banners */
@media (max-width: 600px) {
  .sticky-banner {
    padding: 8px 15px;
    gap: 10px;
  }

  .banner-logo {
    height: 25px;
  }

  .banner-text {
    font-size: 0.9rem;
  }
}

@media (min-width: 601px) {
  .sticky-banner {
    max-width: 800px; /* Center the banner on larger screens */
    left: 50%;
    transform: translateX(-50%);
  }
}

/* Ensure main content is not obscured by sticky banners */
body {
  padding-top: 50px; /* Height of top banner + some margin */
  padding-bottom: 50px; /* Height of bottom banner + some margin */
}


/* Adjust main content margin to account for sticky banners */
main {
  margin-top: 0;
  margin-bottom: 0;
}

