:root {
  /* ========= PRIMARY (Forest) ========= */
  --primary-blue: #054239;
  --primary-dark: #002623;
  --primary-soft: #428177;

  /* ========= BACKGROUND (Golden Wheat) ========= */
  --bg-gray: #edebe0;
  --card-white: #ffffff;

  /* ========= TEXT (Charcoal) ========= */
  --text-dark: #161616;
  --text-gray: #3d3a3b;

  /* ========= SUCCESS ========= */
  --success-bg: #edebe0;
  --success-border: #b9a779;

  /* ========= WARNING (Deep Umber) ========= */
  --warning-bg: #fff3e8;
  --warning-border: #a1511e;
  --warning-text: #6b1f2a;
}

[data-theme="dark"] {
  /* ========= PRIMARY (Forest - Dark Mode) ========= */
  --primary-blue: #428177; /* Lighter for dark mode */
  --primary-dark: #054239;
  --primary-soft: #002623;

  /* ========= BACKGROUND (Dark) ========= */
  --bg-gray: #0f172a;
  --card-white: #1e293b;

  /* ========= TEXT (Light) ========= */
  --text-dark: #e2e8f0;
  --text-gray: #94a3b8;

  /* ========= SUCCESS ========= */
  --success-bg: #064e3b;
  --success-border: #059669;

  /* ========= WARNING ========= */
  --warning-bg: #451a03;
  --warning-border: #9a3412;
  --warning-text: #fdba74;
}

/* Splash Screen */
#splash-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--primary-blue);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.5s ease-out;
}

#splash-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.splash-logo {
  width: 180px;
  height: auto;
  animation: loaderPulse 1.5s infinite ease-in-out;
}

.splash-text-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  margin-top: -0.5rem;
}

.splash-subtitle {
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
}

.splash-text {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.8rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid white;
  border-radius: 50%;
  animation: spinnerSpin 1s linear infinite;
}

@keyframes spinnerSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes loaderPulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}

/* Dark Mode Specific Overrides */
[data-theme="dark"] .new-amount-card {
  background: #064e3b;
  border-color: #059669;
}
[data-theme="dark"] .new-amount-card .value,
[data-theme="dark"] .new-amount-card .label {
  color: #d1fae5;
}

[data-theme="dark"] .old-amount-card {
  background: #7f1d1d;
  border-color: #b91c1c;
}
[data-theme="dark"] .old-amount-card .value,
[data-theme="dark"] .old-amount-card .label {
  color: #fee2e2;
}

[data-theme="dark"] .banknote-row {
  background: #334155;
  color: #f1f5f9;
}

[data-theme="dark"] .modal-content {
  background: #1e293b;
  color: #f1f5f9;
}

[data-theme="dark"] .close-modal-btn {
  background: #475569;
  color: #fff;
}

[data-theme="dark"] .modal-desc {
  color: #cbd5e1;
}

[data-theme="dark"] .dev-label {
  color: #94a3b8;
}

[data-theme="dark"] .dev-name {
  color: #2dd4bf;
}

/* Theme Toggle Button */
.theme-toggle {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  top: auto;
  background: var(--card-white);
  border: 1px solid var(--primary-soft);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 100;
  padding: 0.75rem;
  border-radius: 50%;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
}

.theme-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

/* Language Toggle Button */
.lang-toggle {
  position: fixed;
  bottom: 5.5rem; /* Stacked above theme toggle */
  left: 1.5rem;
  top: auto;
  background: var(--card-white);
  border: 1px solid var(--primary-soft);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  z-index: 100;
  padding: 0;
  border-radius: 50%;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  font-family: 'Cairo', sans-serif;
  color: var(--primary-blue);
}

.lang-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

/* Install App Button */
.install-btn {
  position: fixed;
  bottom: 9.5rem; /* Stacked above lang toggle */
  left: 1.5rem;
  top: auto;
  background: var(--card-white);
  border: 1px solid var(--primary-soft);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 100;
  padding: 0;
  border-radius: 50%;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
}

.install-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

[data-theme="dark"] .install-btn {
  background: #334155;
  border-color: #475569;
  color: #e2e8f0;
}

[data-theme="dark"] .lang-toggle {
  background: #334155;
  border-color: #475569;
  color: #e2e8f0;
}

[data-theme="dark"] .theme-toggle {
  background: #334155;
  border-color: #475569;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  width: 100%;
  overflow-x: hidden;
}

body {
  font-family: "Cairo", sans-serif;
  background: var(--bg-gray);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow-x: hidden;
}

/* ================= HEADER ================= */

.main-header {
  background: var(--primary-blue);
  color: white;
  text-align: center;
  padding: 2.5rem 1rem 4rem;
  border-bottom-left-radius: 2rem;
  border-bottom-right-radius: 2rem;
  width: 100%;
}

.header-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.header-logo {
  width: 65px;
  height: auto;
}

.main-header h1 {
  font-size: 1.75rem; /* Slightly smaller to fit on one line with logo on mobile */
  min-width: 0;
  font-weight: 800;
}

.subtitle-row {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.subtitle {
  font-size: 1rem;
  opacity: 0.9;
}

.unofficial-text {
  font-size: 0.8rem;
  opacity: 0.7;
  background: rgba(0,0,0,0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ================= CONTAINER ================= */

.container {
  max-width: 600px;
  margin: -3rem auto 0;
  padding: 0 1rem;
  width: 100%;
  flex: 1;
}

/* ================= CARDS ================= */

.card {
  background: var(--card-white);
  border-radius: 1.25rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

/* ================= INPUT ================= */

.input-card label {
  display: block;
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.input-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-gray);
  border: 2px solid transparent;
  border-radius: 1rem;
  padding: 0.5rem 1rem;
  transition: all 0.3s ease;
}

.input-wrapper:focus-within {
  background: var(--card-white);
  border-color: var(--primary-blue);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .input-wrapper {
  background: #0f172a;
  border-color: #334155;
}

[data-theme="dark"] .input-wrapper:focus-within {
  background: #1e293b;
  border-color: var(--primary-blue);
}

.input-card input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  outline: none;
  font-size: 3rem;
  font-weight: 800;
  text-align: center;
  color: var(--primary-blue);
  direction: ltr;
  text-overflow: ellipsis;
}

@media (max-width: 600px) {
  .input-card input {
    font-size: 2rem;
  }
  .result-card .value {
    font-size: 1.5rem;
  }
}

.input-card input::placeholder {
  color: #c5c2b8;
  font-size: 2rem;
}

.currency {
  font-size: 1.1rem;
  color: #7a776f;
  font-weight: 600;
}

.input-underline {
  display: none;
}

.input-wrapper:focus-within + .input-underline {
  background: var(--primary-blue);
}

.error-message {
  margin-top: 0.5rem;
  text-align: center;
  color: #6b1f2a;
  font-weight: 600;
  font-size: 0.9rem;
}

/* ================= RESULTS ================= */

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.result-card {
  border-radius: 1.25rem;
  padding: 1.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0; /* Prevents grid blowout */
}

.result-card .label {
  font-size: 0.9rem;
  color: var(--text-gray);
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.result-card .value {
  font-size: 2rem;
  font-weight: 800;
  direction: ltr;
  word-break: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
  line-height: 1.2;
}

.new-amount-card {
  background: #d1fae5;
  border: 2px solid #059669;
}

.new-amount-card .value {
  color: #064e3b;
}

.new-amount-card .label {
  color: #065f46;
}

.usd-amount-card {
  background: #f1f5f9;
  border: 2px solid #cbd5e1;
}

.usd-amount-card .value {
  color: #334155;
}

.usd-amount-card .label {
  color: #475569;
}

[data-theme="dark"] .usd-amount-card {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .usd-amount-card .value {
  color: #e2e8f0;
}

[data-theme="dark"] .usd-amount-card .label {
  color: #94a3b8;
}

.old-amount-card {
  background: #fee2e2;
  border: 2px solid #b91c1c;
}

.old-amount-card .value {
  color: #7f1d1d;
}

.old-amount-card .label {
  color: #991b1b;
}

/* ================= RATE INPUT ================= */

.rate-input {
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  color: var(--text-gray);
  padding: 0.25rem 0;
}

[data-theme="dark"] .rate-input {
  color: #e2e8f0;
}

/* ================= PAYMENT ================= */

.payment-section {
  margin-top: 1.5rem;
}

.section-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  gap: 0.25rem;
}

.section-header p {
  font-size: 0.9rem;
  opacity: 0.8;
  font-weight: normal;
  margin: 0;
}

.section-header h2 {
  font-size: 1.25rem;
  font-weight: 800;
}

.banknotes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

@media (max-width: 600px) {
  .banknotes-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.banknote-card {
  background: var(--card-white);
  border-radius: 1rem;
  padding: 0.75rem;
  text-align: center;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s ease;
  opacity: 0.6;
  filter: grayscale(100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.banknote-card.active {
  opacity: 1;
  filter: grayscale(0%);
  border-color: var(--primary-soft);
  background: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.banknote-card.disabled {
  opacity: 0.3;
  background: #f0f0f0;
  pointer-events: auto;
}

.note-image-wrapper {
  position: relative;
  margin-bottom: 0.5rem;
  width: 100%;
}

.note-image-wrapper img {
  width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.note-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--primary-blue);
  color: white;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.8rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  z-index: 2;
  white-space: nowrap;
}

.note-decrement {
  position: absolute;
  top: -8px;
  left: -8px;
  background: #ef4444;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.2rem;
  line-height: 1;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  z-index: 3;
  border: none;
  cursor: pointer;
  padding: 0;
  padding-bottom: 2px; /* Visual alignment */
}

.note-decrement:hover {
  background: #dc2626;
  transform: scale(1.1);
}

.note-label {
  font-weight: 700;
  color: var(--text-gray);
  font-size: 0.9rem;
}

/* Dark mode overrides */
[data-theme="dark"] .banknote-card {
  background: #334155;
  color: #f1f5f9;
}
[data-theme="dark"] .banknote-card.active {
  background: #1e293b;
  border-color: #2dd4bf;
}
[data-theme="dark"] .banknote-card.disabled {
  background: #0f172a;
}
[data-theme="dark"] .note-label {
  color: #cbd5e1;
}

/* ================= WARNING ================= */

.warning-msg {
  margin-top: 1rem;
  background: var(--warning-bg);
  border: 2px solid var(--warning-border);
  border-radius: 1.25rem;
  padding: 1rem;
  font-weight: 700;
  color: var(--warning-text);
  text-align: center;
}

/* ================= EXTERNAL RATES ================= */

.exchange-rate-section {
  margin-top: 1rem;
  text-align: center;
}

.btn-primary {
  background-color: var(--primary-blue);
  color: white;
  border: none;
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-weight: 700;
  border-radius: 1rem;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s ease, background-color 0.15s ease;
  width: 100%;
}

.btn-primary:hover {
  background-color: var(--primary-dark);
  transform: translateY(-2px);
}

.btn-primary:active {
  transform: translateY(0);
}

/* Promo Button */
.promo-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #b89d4f;
  color: #054239;
  text-decoration: none;
  padding: 0.75rem 1.25rem;
  border-radius: 1rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  width: 100%;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.promo-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  background: #a68d45; /* Slightly darker */
}

.promo-text {
  flex-grow: 1;
  text-align: center;
  font-size: clamp(0.75rem, 3.5vw, 1.1rem);
  white-space: nowrap;
}

.promo-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  filter: brightness(0) invert(1); /* Make it white to match text */
}

.promo-arrow {
  font-size: 1.2rem;
  font-weight: bold;
}

.rates-container {
  background: var(--card-white);
  border-radius: 1rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  border: 1px solid #d6d3c9;
}

.rates-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background-color: #f5f4ee;
  border-bottom: 1px solid #d6d3c9;
}

.source-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-gray);
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-gray);
  cursor: pointer;
  padding: 0 0.5rem;
  line-height: 1;
}

.btn-close:hover {
  color: var(--text-dark);
}

.iframe-wrapper {
  position: relative;
  width: 100%;
  height: 500px;
  background-color: #f5f4ee;
}

.iframe-wrapper iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.disclaimer {
  font-size: 0.8rem;
  color: var(--text-gray);
  padding: 0.75rem;
  background-color: #f5f4ee;
  border-top: 1px solid #d6d3c9;
}

/* ================= FOOTER ================= */

.main-footer {
  text-align: center;
  padding: 1.25rem;
  font-size: 0.9rem;
  color: var(--text-gray);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer-disclaimer {
  font-size: 0.8rem;
  opacity: 0.8;
}

/* ================= UTIL ================= */

.hidden {
  display: none !important;
}

/* ================= MOBILE ================= */

@media (max-width: 480px) {
  .input-card input {
    font-size: 2.5rem;
  }

  .result-card .value {
    font-size: 1.75rem;
  }

  .iframe-wrapper {
    height: 70vh;
  }
}

/* Footer Link */
.footer-link {
  background: none;
  border: none;
  color: var(--primary-blue);
  text-decoration: underline;
  cursor: pointer;
  font-family: 'Cairo', sans-serif;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s ease;
}

/* Modal Content */
.modal-content {
  background: white;
  padding: 2rem;
  border-radius: 16px;
  width: 90%;
  max-width: 400px;
  text-align: center;
  position: relative;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  animation: slideUp 0.3s ease;
}

.close-modal-btn {
  position: absolute;
  top: 1rem;
  left: 1rem; /* RTL layout */
  background: #f3f4f6;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  color: #666;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-desc {
  color: #4b5563;
  line-height: 1.6;
  margin-bottom: 1rem;
}

.modal-alert {
  background: #fee2e2;
  color: #991b1b;
  padding: 0.5rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: bold;
  margin-bottom: 1.5rem;
}

.developer-section {
  border-top: 1px solid #e5e7eb;
  padding-top: 1.5rem;
}

.dev-label {
  font-size: 0.9rem;
  color: #6b7280;
  margin-bottom: 0.25rem;
}

.dev-name {
  font-size: 1.2rem;
  color: var(--primary-blue);
  margin-bottom: 1rem;
}

.social-links {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.social-btn {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  text-decoration: none;
  color: white;
  font-size: 0.9rem;
  transition: opacity 0.2s;
}

/* ================= LIVE RATE CARD ================= */
.live-rate-card {
  margin-top: 1.5rem;
  text-align: center;
  border: 1px solid var(--primary-soft);
}

.live-rate-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.live-rate-header h3 {
  font-size: 1.1rem;
  color: var(--primary-blue);
}

.live-badge {
  background: #ef4444;
  color: white;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: bold;
  animation: pulse 2s infinite;
}

.live-rate-content {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 0.5rem;
  margin: 1rem 0;
}

.rate-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-dark);
}

.currency-small {
  font-size: 1rem;
  color: var(--text-gray);
}

.api-source {
  font-size: 0.8rem;
  color: var(--text-gray);
  opacity: 0.7;
}

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

[data-theme="dark"] .live-rate-header h3 {
  color: #2dd4bf;
}


.social-btn.linkedin { background: #0077b5; }
.social-btn.facebook { background: #1877f2; }
.social-btn:hover { opacity: 0.9; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Currency Chips */
.currency-selector {
  display: flex;
  justify-content: center;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
  background: var(--bg-gray);
  padding: 0.25rem;
  border-radius: 0.75rem;
}

.currency-option {
  flex: 1;
  position: relative;
}

.currency-option input {
  display: none;
}

.currency-option .chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.4rem;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--text-gray);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 2px solid transparent;
  width: 100%;
}

.currency-option .chip:hover {
  background: rgba(0,0,0,0.05);
}

.currency-option input:checked + .chip {
  background: var(--card-white);
  color: var(--primary-blue);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transform: scale(1.02);
}

[data-theme="dark"] .currency-selector {
  background: #1e293b;
}

[data-theme="dark"] .currency-option .chip {
  color: #94a3b8;
}

[data-theme="dark"] .currency-option .chip:hover {
  background: rgba(255,255,255,0.05);
}

[data-theme="dark"] .currency-option input:checked + .chip {
  background: #334155;
  color: #fff;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  border-color: transparent;
}
