/* CSS Variables for Colors and Spacing */
:root {
  --font-primary: 'Cairo', 'Tajawal', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
  --border-radius-sm: 8px;
  --border-radius-md: 16px;
  --border-radius-lg: 24px;
  
  /* Theme Light (Default) */
  --bg-app: #fbf9f6; /* Warm sand background */
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-solid: #ffffff;
  --border-color: rgba(209, 213, 219, 0.5);
  --border-focus: #0d9488;
  --inflation-bg: #fffbeb;
  --inflation-text-title: #78350f;
  --inflation-text-desc: #92710a;
  
  --text-primary: #1f2937;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  
  --primary-50: #f0fdfa;
  --primary-100: #ccfbf1;
  --primary-600: #0d9488; /* Teal primary */
  --primary-700: #0f766e;
  --primary-900: #134e4a;
  
  --accent-gold: #d4a017; /* Sand/gold accent */
  --accent-gold-light: #fef08a;
  --accent-gold-bg: rgba(212, 160, 23, 0.08);
  
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --success: #10b981;
  --success-light: #d1fae5;
  
  --warning-bg: #fffbeb;
  --warning-border: var(--accent-gold);
  --warning-text: #78350f;
  --danger-bg: var(--danger-light);
  --danger-border: var(--danger);
  --danger-text: #7f1d1d;

  --backdrop-blur: blur(12px);
}

/* Theme Dark */
[data-theme="dark"] {
  --bg-app: #0f172a; /* Slate 900 */
  --bg-card: rgba(30, 41, 59, 0.7); /* Slate 800 blur */
  --bg-card-solid: #1e293b;
  --border-color: rgba(51, 65, 85, 0.5);
  --border-focus: #2dd4bf;
  --inflation-bg: #451a03;
  --inflation-text-title: #fef08a;
  --inflation-text-desc: #fbbf24;
  
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  
  --primary-50: #0f172a;
  --primary-100: #115e59;
  --primary-600: #2dd4bf; /* Mint/teal accent */
  --primary-700: #14b8a6;
  --primary-900: #0f766e;
  
  --accent-gold: #fbbf24;
  --accent-gold-light: #451a03;
  --accent-gold-bg: rgba(251, 191, 36, 0.1);
  
  --danger: #ef4444;
  --danger-light: #450a0a;
  --success: #10b981;
  --success-light: #064e3b;

  --warning-bg: rgba(251, 191, 36, 0.15);
  --warning-border: var(--accent-gold);
  --warning-text: #fef08a;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --danger-border: var(--danger);
  --danger-text: #fee2e2;
}

/* Screen-reader-only utility (hides visually, keeps accessible to crawlers & assistive tech) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Reset and Global Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-primary);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

/* RTL Specific adjustment */
[dir="rtl"] {
  text-align: right;
}

[dir="ltr"] {
  text-align: left;
}

a {
  color: var(--primary-600);
  text-decoration: none;
  transition: var(--transition-smooth);
}

a:hover {
  color: var(--primary-700);
}

h1, h2, h3, h4, h5 {
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.5em;
  color: var(--text-primary);
}

/* UI Container & Grid Layout */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.app-header {
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-card);
  backdrop-filter: var(--backdrop-blur);
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 1rem 0;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 40px;
  height: 40px;
}

.brand .brand-name {
  font-weight: 700;
  line-height: 1.3;
  font-size: 1.5rem;
  margin-bottom: 0;
  background: linear-gradient(135deg, var(--primary-600) 0%, var(--accent-gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* App Main Grid */
.app-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  margin-top: 2rem;
  margin-bottom: 4rem;
  min-width: 0;
}

.app-grid > * {
  min-width: 0;
}

.calc-container {
  min-width: 0;
}

@media (min-width: 1024px) {
  .app-grid {
    grid-template-columns: 350px 1fr; /* Desktop: Sidebar on left (when RTL, logic places sidebar on left, main on right) */
  }
  
  [dir="rtl"] .app-grid {
    grid-template-columns: 350px 1fr;
  }
}

/* General Card Design (Glassmorphism) */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  backdrop-filter: var(--backdrop-blur);
  margin-bottom: 1.5rem;
  transition: var(--transition-smooth);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card-title {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--primary-100);
  padding-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Onboarding Modal/Card */
.onboarding-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s ease;
  padding: 1rem;
}

.onboarding-card {
  max-width: 500px;
  width: 100%;
  border-radius: var(--border-radius-lg);
}

/* Form Styling & Custom Input Types */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  height: 42px;
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-card-solid);
  color: var(--text-primary);
  font-family: var(--font-primary);
  font-size: 1rem;
  outline: none;
  transition: var(--transition-smooth);
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

select.form-control {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 0.75rem center; /* Adjusted for RTL */
  padding-left: 2.5rem;
  padding-right: 1rem;
}

[dir="ltr"] select.form-control {
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
  padding-left: 1rem;
}

/* Custom button styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-primary);
  font-size: 1rem;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: var(--border-radius-sm);
  border: none;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background-color: var(--primary-600);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background-color: var(--primary-700);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--border-color);
  color: var(--text-primary);
}

.btn-danger {
  background-color: var(--danger);
  color: white;
}

.btn-danger:hover {
  background-color: #b91c1c;
}

.btn-gold {
  background: linear-gradient(135deg, var(--accent-gold) 0%, #b8860b 100%);
  color: white;
}

.btn-gold:hover {
  background: linear-gradient(135deg, #e5b228 0%, var(--accent-gold) 100%);
}

.btn-icon {
  padding: 0.5rem;
  border-radius: 50%;
  font-size: 1.2rem;
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}

.btn-icon:hover {
  background-color: var(--border-color);
  color: var(--text-primary);
}

/* Sticky Real-Time Summary Panel (Sidebar) */
.summary-panel {
  align-self: start;
}

@media (min-width: 1024px) {
  .summary-panel {
    position: sticky;
    top: 5rem;
    max-height: calc(100vh - 7rem);
    overflow-y: auto;
  }
}

.summary-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color);
}

.summary-stat:last-child {
  border-bottom: none;
}

.summary-stat-label {
  font-weight: 600;
  color: var(--text-secondary);
}

.summary-stat-val {
  font-weight: 700;
  font-size: 1.1rem;
}

.summary-grand-total {
  background: var(--primary-50);
  border-radius: var(--border-radius-sm);
  padding: 1rem;
  margin-top: 1rem;
  border-right: 4px solid var(--primary-600);
}

[dir="ltr"] .summary-grand-total {
  border-right: none;
  border-left: 4px solid var(--primary-600);
}

.summary-grand-total .summary-stat-label {
  color: var(--primary-900);
  font-size: 1.1rem;
}

.summary-grand-total .summary-stat-val {
  font-size: 1.5rem;
  color: var(--primary-700);
}

/* Progress bar customization */
.progress-bar-container {
  width: 100%;
  height: 8px;
  background-color: var(--border-color);
  border-radius: 4px;
  margin-top: 0.5rem;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  transition: width 0.5s ease-out, background-color 0.3s ease;
  border-radius: 4px;
}

.bg-success { background-color: var(--success); }
.bg-warning { background-color: var(--accent-gold); }
.bg-danger { background-color: var(--danger); }

/* Sticky bottom bar for mobile screens */
.mobile-summary-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--bg-card-solid);
  box-shadow: 0 -4px 15px rgba(0,0,0,0.1);
  padding: 0.75rem 1.2rem;
  z-index: 45;
  border-top: 1px solid var(--border-color);
  backdrop-filter: var(--backdrop-blur);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 1023px) {
  body {
    padding-bottom: 80px;
  }

  .mobile-summary-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .summary-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--bg-card-solid);
    border-top-left-radius: var(--border-radius-lg);
    border-top-right-radius: var(--border-radius-lg);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.25);
    z-index: 1000;
    padding: 1.5rem 1.5rem 2rem 1.5rem;
    max-height: 85vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .summary-panel.active-mobile {
    transform: translateY(0);
  }

  .summary-panel .card {
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    padding: 0;
    margin-bottom: 1.5rem;
  }

  #closeSidebarBtn {
    background-color: transparent;
    color: var(--text-primary);
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

@media (max-width: 767px) {
  .sub-calculator-grid > div:first-child {
    border-left: none !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    border-bottom: 1px dashed var(--border-color) !important;
    padding-bottom: 1.5rem !important;
  }
  .sub-calculator-grid > div:nth-child(2) {
    padding-left: 0 !important;
    padding-right: 0 !important;
    padding-top: 0.5rem !important;
  }
}

@media (max-width: 600px) {
  .onboarding-overlay {
    align-items: flex-start;
    overflow-y: auto;
    padding-top: 2rem;
    padding-bottom: 2rem;
  }

  .onboarding-card {
    padding: 1.25rem !important;
  }

  .item-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    align-items: end;
    width: 100%;
  }

  .item-field-container {
    min-width: 0;
    max-width: none;
    flex: none;
    width: 100%;
  }

  .item-field-container-sm {
    min-width: 0;
    max-width: none;
    width: 100%;
  }

  .field-label {
    min-height: auto;
    margin-bottom: 0.25rem;
  }

  .item-field-container:nth-child(3):last-child {
    grid-column: span 2;
  }

  .benchmark-table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
  }

  .card:has(#shareWhatsappBtn) > div {
    display: flex;
    flex-direction: column;
    gap: 0.5rem !important;
    width: 100%;
  }

  .card:has(#shareWhatsappBtn) .btn {
    width: 100% !important;
    margin-right: 0 !important;
    margin-left: 0 !important;
  }

  main {
    padding-bottom: 5rem;
  }

  .gold-price-box {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .gold-price-box > div {
    flex-wrap: wrap;
    justify-content: center;
  }

  .gold-price-box button {
    width: 100%;
  }
}

/* Tab System Navigation */
.tabs-container {
  margin-bottom: 1.5rem;
}

.tabs-nav {
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid var(--border-color);
  overflow-x: auto;
  scrollbar-width: none; /* Hide scrollbar for clean view */
  -webkit-overflow-scrolling: touch;
}

.tabs-nav::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  padding: 0.75rem 1.25rem;
  font-family: var(--font-primary);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  border: none;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: var(--transition-smooth);
}

.tab-btn:hover {
  color: var(--primary-600);
}

.tab-btn.active {
  color: var(--primary-600);
  border-bottom-color: var(--primary-600);
}

.tab-pane {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-pane.active {
  display: block;
}

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

/* Line Item Rows in Tables / Lists */
.item-row {
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0;
  border-bottom: 1px dashed var(--border-color);
  gap: 0.75rem;
}

.item-row:last-child {
  border-bottom: none;
}

.item-info {
  flex: 1;
}

.item-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.item-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.item-inputs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.item-field-container {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 120px;
  flex: 1;
}

.item-field-container-sm {
  min-width: 80px;
  max-width: 100px;
}

.field-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-height: 34px;
  display: flex;
  align-items: flex-end;
  line-height: 1.2;
}

.item-total-badge {
  background-color: var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-sm);
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  height: 42px;
}

/* Dynamic Inputs Styling */
.item-mahr {
  background-color: var(--accent-gold-bg);
  border: 1px solid var(--accent-gold);
  border-radius: var(--border-radius-sm);
  padding: 1rem;
  border-right: 5px solid var(--accent-gold);
  animation: shimmer 2s infinite linear;
  background-size: 200% auto;
  background-image: linear-gradient(to right, rgba(212,160,23,0.08) 0%, rgba(251,191,36,0.15) 50%, rgba(212,160,23,0.08) 100%);
}

[dir="ltr"] .item-mahr {
  border-right: none;
  border-left: 5px solid var(--accent-gold);
}

@keyframes shimmer {
  0% { background-position: 0% center; }
  100% { background-position: -200% center; }
}

/* Gold Price Header Input */
.gold-price-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background-color: var(--accent-gold-bg);
  border: 1px solid var(--accent-gold);
  border-radius: var(--border-radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

/* Suggestions Box */
.suggestion-card {
  background-color: var(--primary-50);
  border: 1px solid var(--primary-600);
  border-right-width: 4px;
  border-radius: var(--border-radius-sm);
  padding: 0.85rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: var(--primary-900);
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  box-shadow: var(--shadow-sm);
}

[dir="ltr"] .suggestion-card {
  border-right-width: 1px;
  border-left-width: 4px;
  border-left-color: var(--primary-600);
}

.suggestion-card.warning {
  background-color: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning-text);
}

.suggestion-card.danger {
  background-color: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-text);
}

/* Timeline & Analytics Dashboards */
.charts-container {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
  margin-top: 1rem;
}

@media (min-width: 768px) {
  .charts-container {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.charts-container > div {
  min-width: 0;
}

.chart-wrapper {
  background-color: var(--bg-card-solid);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 1rem;
  height: 250px;
  position: relative;
  overflow: hidden;
  width: 100%;
}

.chart-wrapper canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* Calculators: Monthly savings and Inflation */
.sub-calculator-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .sub-calculator-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.calc-output-box {
  background-color: var(--primary-50);
  border: 1px solid var(--primary-600);
  border-radius: var(--border-radius-sm);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.inflation-warning-box {
  background-color: var(--inflation-bg) !important;
  border: 1px solid var(--accent-gold) !important;
  border-radius: var(--border-radius-sm);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.inflation-warning-box .title {
  color: var(--inflation-text-title) !important;
  font-weight: bold;
}

.inflation-warning-box .desc {
  color: var(--inflation-text-desc) !important;
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.calc-output-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary-600);
  margin-top: 0.5rem;
}

.calc-output-warning {
  font-size: 0.85rem;
  color: var(--danger);
  margin-top: 0.5rem;
  font-weight: 600;
}

/* Scenarios Side-By-Side View */
.scenarios-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

@media (min-width: 768px) {
  .scenarios-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.scenario-card {
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 1.25rem;
  text-align: center;
  transition: var(--transition-smooth);
  background-color: var(--bg-card-solid);
}

.scenario-card.active {
  border-color: var(--primary-600);
  background-color: var(--primary-50);
  box-shadow: var(--shadow-md);
}

.scenario-card-header {
  font-weight: 700;
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
}

.scenario-card-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.scenario-card-price {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary-700);
}

/* Modals overlays styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 1rem;
}

.modal-content {
  background-color: var(--bg-card-solid);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  width: 100%;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  padding: 2rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.modal-body {
  margin-bottom: 1.5rem;
}

/* FAQ Accordion Styling */
.faq-item {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  margin-bottom: 0.75rem;
  overflow: hidden;
  background-color: var(--bg-card-solid);
}

.faq-question {
  width: 100%;
  padding: 1rem 1.25rem;
  text-align: right;
  font-weight: 600;
  font-family: var(--font-primary);
  font-size: 1rem;
  background-color: var(--bg-card);
  border: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition-smooth);
}

[dir="ltr"] .faq-question {
  text-align: left;
}

.faq-question::after {
  content: '▼';
  font-size: 0.75rem;
  color: var(--text-secondary);
  transition: transform 0.3s ease;
}

.faq-item.active .faq-question::after {
  transform: rotate(180deg);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out, padding 0.3s ease;
  background-color: var(--bg-card-solid);
  padding: 0 1.25rem;
}

.faq-item.active .faq-answer {
  max-height: 300px;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-color);
}

/* Article Styling */
.seo-article {
  margin-top: 3rem;
  border-top: 1px solid var(--border-color);
  padding-top: 2rem;
}

.seo-article h1,
.seo-article h2 {
  font-size: 1.5rem;
  margin-top: 2rem;
}

.seo-article h3 {
  font-size: 1.2rem;
  margin-top: 1.5rem;
}

.seo-article p {
  margin-bottom: 1rem;
  color: var(--text-secondary);
  text-align: justify;
}

.seo-article ul {
  margin-bottom: 1.5rem;
  margin-right: 1.5rem;
}

[dir="ltr"] .seo-article ul {
  margin-right: 0;
  margin-left: 1.5rem;
}

.seo-article li {
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.benchmark-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}

.benchmark-table th, .benchmark-table td {
  border: 1px solid var(--border-color);
  padding: 0.75rem 1rem;
  text-align: center;
}

.benchmark-table th {
  background-color: var(--primary-50);
  font-weight: 700;
}

/* Floating sharing button or footer actions */
.footer {
  border-top: 1px solid var(--border-color);
  padding: 2rem 0;
  margin-top: 4rem;
  background-color: var(--bg-card);
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: center;
}

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

/* Onboarding modal dismiss control (Critical SEO fix: modal must not trap first-time visitors) */
.onboarding-card {
  position: relative;
}

.onboarding-close-btn {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-card-solid);
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.onboarding-close-btn:hover {
  background: var(--primary-600);
  color: #fff;
  border-color: var(--primary-600);
}

/* Visible above-the-fold benchmark answer block (surfaces countries.js data as crawlable text,
   independent of the onboarding modal or JS execution) */
.benchmark-answer-box {
  background: linear-gradient(135deg, var(--primary-600) 0%, var(--accent-gold) 100%);
  color: #fff;
  text-align: center;
  padding: 1.25rem 1rem;
}

.benchmark-answer-label {
  font-size: 0.95rem;
  font-weight: 600;
  opacity: 0.9;
  margin-bottom: 0.35rem;
}

.benchmark-answer-value {
  font-size: 1.75rem;
  font-weight: 800;
}

.benchmark-answer-note {
  font-size: 0.85rem;
  opacity: 0.9;
  margin-top: 0.35rem;
}

.benchmark-answer-note a {
  color: #fff;
  text-decoration: underline;
}

/* Article byline (E-E-A-T) & methodology/source disclosure */
.article-meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.methodology-note {
  font-size: 0.85rem;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 0.85rem 1rem;
  margin-top: 1.5rem;
}

/* Visible FAQ section (mirrors FAQPage JSON-LD as real page text for crawlers/AI citation) */
.faq-section {
  margin-top: 2.5rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
}

.faq-section h2 {
  font-size: 1.4rem;
  margin-bottom: 1rem;
}

.faq-item {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
  background: var(--bg-card-solid);
}

.faq-item summary {
  cursor: pointer;
  font-weight: 700;
}

.faq-item p {
  margin-top: 0.6rem;
  margin-bottom: 0;
  color: var(--text-secondary);
}

.noscript-banner {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Mobile tab-bar scroll affordance: fade hint so users know more tabs exist off-screen */
.tabs-container {
  position: relative;
}

.tabs-container::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 2px;
  left: 0;
  width: 28px;
  pointer-events: none;
  background: linear-gradient(to left, transparent, var(--bg-card-solid, var(--bg-card)));
}

@media (min-width: 900px) {
  .tabs-container::after {
    display: none;
  }
}

/* Comfortable 48px+ touch target for the theme toggle */
#themeToggle {
  min-width: 48px;
  min-height: 48px;
}

/* Homepage geo-suggestion banner */
.geo-suggest-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--bg-card);
  border: 1px solid var(--primary-600);
  border-radius: var(--border-radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}

.geo-suggest-banner a {
  font-weight: 700;
  color: var(--primary-600);
}

.geo-suggest-banner .geo-dismiss {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 1rem;
}

/* PRINT MEDIA OVERRIDES */
@media print {
  body {
    background: white !important;
    color: black !important;
    font-size: 12pt;
    direction: rtl;
  }
  
  .app-header, 
  .nav-actions, 
  .tabs-nav, 
  .btn, 
  .onboarding-overlay, 
  .modal-overlay,
  .mobile-summary-bar,
  .faq-section,
  .seo-article,
  .footer,
  .gold-price-box,
  .calc-container input {
    display: none !important;
  }
  
  .app-grid {
    display: block !important;
  }
  
  .summary-panel {
    border: 1px solid #ccc !important;
    padding: 1rem !important;
    margin-bottom: 2rem !important;
    page-break-after: avoid;
    width: 100% !important;
  }
  
  .card {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    page-break-inside: avoid;
  }
  
  .tab-pane {
    display: block !important; /* Force printing all items */
    opacity: 1 !important;
  }
  
  .item-row {
    border-bottom: 1px solid #ccc !important;
    padding: 0.5rem 0 !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
  }
  
  .item-inputs {
    display: none !important; /* Hide input fields */
  }
  
  .item-total-print-value {
    display: inline !important;
    font-weight: bold;
  }
}

.item-total-print-value {
  display: none;
}

/* CUSTOM MONTH PICKER STYLES */
/* Elevate any card containing an active popover to prevent z-index clipping due to stacking contexts */
.card:has(.custom-month-popover.active) {
  position: relative;
  z-index: 10;
}

.custom-month-container {
  position: relative;
  width: 100%;
}

.custom-month-trigger {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--bg-card-solid);
  user-select: none;
  font-family: var(--font-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 0.75rem 1rem;
  font-size: 1rem;
  color: var(--text-primary);
  transition: var(--transition-smooth);
}

.custom-month-trigger:focus,
.custom-month-trigger.active {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.custom-month-value {
  flex-grow: 1;
}

.custom-month-icon {
  margin-right: 0.5rem;
  opacity: 0.7;
}

[dir="ltr"] .custom-month-icon {
  margin-right: 0;
  margin-left: 0.5rem;
}

.custom-month-popover {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 0.5rem;
  background-color: var(--bg-card-solid);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  width: 100%;
  min-width: 280px;
  padding: 1rem;
  box-sizing: border-box;
  animation: fadeIn 0.2s ease;
  backdrop-filter: var(--backdrop-blur);
}

.custom-month-popover.active {
  display: block;
}

.custom-month-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.custom-month-year-select {
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--border-radius-sm);
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  outline: none;
  text-align: center;
  transition: var(--transition-smooth);
}

.custom-month-year-select:hover {
  background-color: var(--border-color);
}

.custom-month-year-select option {
  background-color: var(--bg-card-solid);
  color: var(--text-primary);
  font-weight: normal;
}

.custom-month-header button {
  background: none;
  border: none;
  color: var(--primary-600);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.25rem 0.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  transition: var(--transition-smooth);
}

.custom-month-header button:hover {
  background-color: var(--border-color);
}

.custom-month-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.custom-month-grid button {
  font-family: var(--font-primary);
  font-size: 0.9rem;
  padding: 0.5rem 0.25rem;
  border: 1px solid transparent;
  border-radius: var(--border-radius-sm);
  background-color: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-smooth);
  text-align: center;
}

.custom-month-grid button:hover {
  background-color: var(--border-color);
  color: var(--text-primary);
}

.custom-month-grid button.selected {
  background-color: var(--primary-600);
  color: white !important;
  font-weight: 600;
}

.custom-month-footer {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  border-top: 1px solid var(--border-color);
  padding-top: 0.75rem;
}

.custom-month-footer button {
  font-family: var(--font-primary);
  font-size: 0.85rem;
  padding: 0.4rem 0.8rem;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: var(--transition-smooth);
  border: none;
  font-weight: 600;
}

.custom-month-footer .btn-today {
  background-color: var(--primary-50);
  color: var(--primary-600);
  flex: 1;
}

.custom-month-footer .btn-today:hover {
  background-color: var(--primary-100);
}

.custom-month-footer .btn-clear {
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  flex: 1;
}

.custom-month-footer .btn-clear:hover {
  background-color: var(--border-color);
  color: var(--text-primary);
}

@media print {
  .custom-month-container {
    display: none !important;
  }
}


/* Cited-sources list at the foot of each country article */
.seo-article .sources-list {
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.seo-article .sources-list li {
  margin-bottom: 0.5rem;
}

.seo-article .sources-list a {
  color: var(--primary-600);
}
