/* ============================================================
   SAGHA MASR — Custom Stylesheet
   Sections:
     1. Base / Reset
     2. Typography
     3. Layout & Page Structure
     4. Components — Navbar
     5. Components — Header
     6. Components — Toggle Switch
     7. Components — Price Cards
     8. Components — FAQ
     9. Components — Footer
    10. Components — Forms (Calculator / Converter pages)
    11. Utilities & Animations
    12. Responsive
   ============================================================ */

/* ============================================================
   1. BASE / RESET
   ============================================================ */
html,
body {
  background-color: #273449;
  color: #e5e7eb;
}

/* ============================================================
   2. TYPOGRAPHY
   ============================================================ */
.cairo {
  font-family: "Cairo", sans-serif;
  font-optical-sizing: auto;
  font-weight: 700;
  font-style: normal;
  font-variation-settings: "slnt" 0;
}

/* ============================================================
   3. LAYOUT & PAGE STRUCTURE
   ============================================================ */
.headerpaddingtop {
  /* Applied via responsive rules below */
}

/* ============================================================
   4. COMPONENTS — NAVBAR
   ============================================================ */
.custom-navbar {
  background: #111827;
  border-bottom: 2px solid #c89116;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
}

.custom-navbar .navbar-brand {
  color: #facc15 !important;
  font-size: 1.3rem;
}

.custom-navbar .nav-link {
  color: #e5e7eb !important;
  margin: 0 8px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.custom-navbar .nav-link:hover,
.custom-navbar .nav-link.active {
  color: #facc15 !important;
  text-shadow: 0 0 6px rgba(250, 204, 21, 0.6);
}

.navbar-toggler {
  border-color: rgba(250, 204, 21, 0.6);
}

/* Smart (auto-hide on scroll) navbar */
.smart-navbar {
  top: 0;
  width: 100%;
  z-index: 1050;
  transition: transform 0.3s ease-in-out;
}

/* ============================================================
   5. COMPONENTS — HEADER
   ============================================================ */
/* Header gradient — applied inline in HTML, kept here as reference class */
.header-gradient {
  background: linear-gradient(to bottom, #c89116, #000000 97%);
}

/* Brand text animation */
#brand-text {
  display: inline-block;
  min-width: 100px;
  text-align: center;
  transition: opacity 0.5s ease-in-out;
}

/* Market status container */
#market-status-container {
  display: flex;
  flex-direction: row-reverse;
  justify-content: center;
  align-items: center;
  margin-top: 5px;
  gap: 8px;
}

/* ============================================================
   6. COMPONENTS — TOGGLE SWITCH
   ============================================================ */
.toggle-wrapper {
  position: relative;
  width: 390px;
  height: 44px;
  background: #111827;
  border-radius: 50px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  padding: 4px;
  box-sizing: border-box;
  max-width: 100%;
}

.toggle-thumb {
  position: absolute;
  top: 4px;
  width: calc(33.333% - 8px);
  height: 36px;
  background: linear-gradient(135deg, #facc15, #c89116);
  border-radius: 50px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(250, 204, 21, 0.5);
}

.toggle-btn {
  flex: 1;
  height: 36px;
  background: none;
  border: none;
  font-weight: bold;
  z-index: 2;
  cursor: pointer;
  transition: color 0.3s;
}

.toggle-btn--active {
  color: #000;
}

.toggle-btn--inactive {
  color: #9ca3af;
}

/* ============================================================
   7. COMPONENTS — PRICE CARDS
   ============================================================ */
.card-gold-edge {
  text-align: center;
  padding: 24px;
  border-radius: 16px;
  background: linear-gradient(135deg, #1f2933, #111827);
  color: #ffffff;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  width: 100%;
  position: relative;
  border: 2px solid #facc15;
  box-sizing: border-box;
}

/* Icon badge floating above card */
.gold-icon {
  width: 70px;
  height: 70px;
  margin: -50px auto 16px;
  background: #000;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
}

.gold-icon img {
  width: 45px;
  height: 45px;
  object-fit: contain;
}

.gold-title {
  font-size: 20px;
  font-weight: bold;
  margin: 10px 0;
  letter-spacing: 0.5px;
}

.gold-price-box {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 22px;
  font-weight: bold;
}

.gold-price {
  color: #facc15;
}

.gold-currency {
  font-size: 16px;
  opacity: 0.8;
  margin-right: 4px;
}

/* ============================================================
   8. COMPONENTS — FAQ
   ============================================================ */
.faq-section {
  background: linear-gradient(to bottom, #1f2933, #111827);
}

.faq-title {
  text-align: right;
  font-size: x-large;
}

.faq-item {
  text-align: right;
}

.faq-question {
  width: 100%;
  background: #111827;
  border: none;
  padding: 15px 20px;
  font-size: 18px;
  color: #facc15;
  font-weight: bold;
  border-radius: 10px;
  cursor: pointer;
  text-align: right;
  transition: background 0.3s;
}

.faq-question:hover {
  background: #1f2933;
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
  background: #1f2933;
  color: #ffffff;
  padding: 0 20px;
  border-radius: 0 0 10px 10px;
  margin-top: 2px;
}

.faq-item.active .faq-answer {
  max-height: 500px;
  padding: 10px 20px;
}

/* ============================================================
   9. COMPONENTS — FOOTER
   ============================================================ */
.site-footer {
  background-color: #222;
  font-weight: 400;
}

/* ============================================================
   10. COMPONENTS — FORMS (Calculator / Converter pages)
   ============================================================ */

/* Section background for calculator / converter pages */
.section-dark {
  background: #273449;
}

/* Custom form inputs */
.custom-input,
.custom-input:focus {
  background-color: #1f2933 !important;
  color: #ffffff;
  border: 1px solid #facc15;
  box-shadow: 0 0 8px rgba(250, 204, 21, 0.4);
  outline: none;
}

/* Override Bootstrap's default focus style for form controls */
input.form-control:focus,
select.form-select:focus {
  background-color: #1f2933 !important;
  color: #ffffff;
}

/* Remove number input spinners */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

/* Result box */
.result-box {
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  background-color: #1f2933;
  border: 1px solid #facc15;
  border-radius: 0.75rem;
  color: #fff;
  word-break: break-word;
}

/* Badge */
.badge-custom {
  background-color: #1f2933;
  border: 1px solid #facc15;
  color: #facc15;
}

/* Page headings on subpages */
.page-heading {
  color: #e5e7eb;
}

/* ============================================================
   11. UTILITIES & ANIMATIONS
   ============================================================ */

/* Market status dot */
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  animation: flash 1s infinite;
}

.open-dot {
  background-color: green;
}

.closed-dot {
  background-color: red;
}

.open {
  color: green;
}

.closed {
  color: red;
}

/* Price update glow animation */
.price-update-animation {
  position: relative;
  animation: goldGlow 2s ease-in-out;
  animation-fill-mode: both;
}

/* Scroll-to-top button (injected by inline script) */
.softr-back-to-top-button {
  /* Styles are applied dynamically via JS */
}

/* ============================================================
   KEYFRAMES
   ============================================================ */
@keyframes flash {
  0%,
  50%,
  100% {
    opacity: 1;
  }
  25%,
  75% {
    opacity: 0;
  }
}

@keyframes goldGlow {
  0% {
    transform: translateY(0);
    text-shadow: 0 0 0px rgba(250, 204, 21, 0);
  }
  25% {
    transform: translateY(-3px);
    text-shadow: 0 0 10px rgba(250, 204, 21, 0.7);
  }
  50% {
    transform: translateY(-6px);
    text-shadow: 0 0 20px rgba(250, 204, 21, 1);
  }
  75% {
    transform: translateY(-3px);
    text-shadow: 0 0 10px rgba(250, 204, 21, 0.7);
  }
  100% {
    transform: translateY(0);
    text-shadow: 0 0 0px rgba(250, 204, 21, 0);
  }
}

@keyframes fadeInOut {
  0%,
  20% {
    opacity: 0;
  }
  30%,
  70% {
    opacity: 1;
  }
  80%,
  100% {
    opacity: 0;
  }
}

/* ============================================================
   13. COMPONENTS — SEO CONTENT SECTION
   ============================================================ */
.seo-content {
  background: linear-gradient(to bottom, #111827, #1f2933);
  color: #e5e7eb;
}

.seo-content__inner {
  border-top: 2px solid #c89116;
  padding-top: 2.5rem;
}

.seo-content__heading {
  color: #facc15;
  font-size: 1.75rem;
  margin-bottom: 1rem;
}

.seo-content__subheading {
  color: #facc15;
  font-size: 1.25rem;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  padding-right: 0.75rem;
  border-right: 3px solid #c89116;
}

.seo-content__text {
  color: #d1d5db;
  line-height: 2;
  font-size: 1rem;
  margin-bottom: 1rem;
}

/* Tip cards inside the SEO section */
.seo-tip-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(200, 145, 22, 0.35);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  height: 100%;
}

.seo-tip-card__icon {
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
  display: block;
}

.seo-tip-card__title {
  color: #facc15;
  font-size: 1rem;
  margin-bottom: 0.4rem;
}

.seo-tip-card__body {
  color: #9ca3af;
  font-size: 0.9rem;
  line-height: 1.8;
  margin: 0;
}

/* ============================================================
   12. RESPONSIVE
   ============================================================ */

/* Mobile & tablet — fixed + auto-hide navbar */
@media (max-width: 991.98px) {
  .smart-navbar {
    position: fixed;
  }

  .smart-navbar.nav-hidden {
    transform: translateY(-100%);
  }

  .headerpaddingtop {
    padding-top: 60px;
  }

  /* Subpage display-6 scaling */
  .display-6 {
    font-size: 2rem;
  }

  /* Constrain toggle width on small screens */
  .toggle-wrapper {
    width: 100%;
    max-width: 390px;
  }
}

/* Desktop — sticky navbar */
@media (min-width: 992px) {
  .smart-navbar {
    position: sticky;
    transform: none !important;
  }

  body {
    padding-top: 0;
  }
}

/* ============================================================
   14. COMPONENTS — GOLD CALCULATOR PAGE
   (Scoped to body.gold-calculator-page to prevent
    cross-page style bleed)
   ============================================================ */

/* CSS custom properties for the calculator page */
body.gold-calculator-page {
  --gold-primary: #facc15;
  --gold-secondary: #c89116;
  --gold-dark: #7a5800;
  --surface-1: #111827;
  --surface-2: #1f2933;
  --surface-3: #273449;
  --profit-green: #10b981;
  --profit-green-bg: rgba(16,185,129,0.12);
  --loss-red: #ef4444;
  --loss-red-bg: rgba(239,68,68,0.12);
  --neutral: #6b7280;
  --text-primary: #f9fafb;
  --text-muted: #9ca3af;
}

/* Price status bar */
body.gold-calculator-page .price-status-bar {
  background: var(--surface-1);
  border-bottom: 1px solid rgba(200,145,22,0.3);
  padding: 10px 0;
}
body.gold-calculator-page .price-status-bar .status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(250,204,21,0.08);
  border: 1px solid rgba(250,204,21,0.25);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 0.8rem;
  color: var(--gold-primary);
  font-family: 'Cairo', sans-serif;
}
body.gold-calculator-page .price-status-bar .live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--profit-green);
  animation: calc-pulse-dot 1.5s infinite;
}
body.gold-calculator-page .price-status-bar .loading-dot {
  background: var(--gold-primary);
}
body.gold-calculator-page .price-status-bar .error-dot {
  background: var(--loss-red);
}
@keyframes calc-pulse-dot {
  0%,100% { opacity:1; transform:scale(1); }
  50%      { opacity:0.4; transform:scale(0.7); }
}

/* Karat row cards */
body.gold-calculator-page .karat-card {
  background: linear-gradient(135deg, var(--surface-2), var(--surface-1));
  border: 1px solid rgba(250,204,21,0.2);
  border-radius: 16px;
  padding: 20px;
  transition: border-color 0.3s, box-shadow 0.3s;
  position: relative;
  overflow: hidden;
}
body.gold-calculator-page .karat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 4px; height: 100%;
  background: linear-gradient(to bottom, var(--gold-primary), var(--gold-secondary));
  border-radius: 0 16px 16px 0;
}
body.gold-calculator-page .karat-card:focus-within {
  border-color: rgba(250,204,21,0.6);
  box-shadow: 0 0 0 3px rgba(250,204,21,0.1);
}

/* Karat badge */
body.gold-calculator-page .karat-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--gold-primary), var(--gold-secondary));
  color: #000;
  font-family: 'Cairo', sans-serif;
  font-weight: 900;
  font-size: 0.85rem;
  border-radius: 8px;
  padding: 4px 12px;
  margin-bottom: 14px;
}

/* Karat input row grid */
body.gold-calculator-page .karat-inputs-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 480px) {
  body.gold-calculator-page .karat-inputs-row {
    grid-template-columns: 1fr;
  }
}

/* Input group inside karat cards */
body.gold-calculator-page .input-group-custom {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
body.gold-calculator-page .input-group-custom label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: 'Cairo', sans-serif;
  font-weight: 600;
}
body.gold-calculator-page .input-group-custom input {
  background: rgba(0,0,0,0.3) !important;
  border: 1px solid rgba(250,204,21,0.25) !important;
  border-radius: 10px !important;
  color: #fff !important;
  padding: 10px 14px !important;
  font-family: 'Cairo', sans-serif !important;
  font-size: 1rem !important;
  font-weight: 600 !important;
  transition: border-color 0.2s, box-shadow 0.2s !important;
}
body.gold-calculator-page .input-group-custom input:focus {
  border-color: rgba(250,204,21,0.7) !important;
  box-shadow: 0 0 0 3px rgba(250,204,21,0.1) !important;
  outline: none !important;
  background: rgba(0,0,0,0.4) !important;
}
body.gold-calculator-page .input-group-custom input::placeholder {
  color: rgba(156,163,175,0.5);
  font-weight: 400;
}

/* Karat result strip */
body.gold-calculator-page .karat-result-strip {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
@media (max-width: 480px) {
  body.gold-calculator-page .karat-result-strip {
    grid-template-columns: 1fr;
  }
}

/* Result chips inside karat strips */
body.gold-calculator-page .result-chip {
  background: rgba(0,0,0,0.3);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: center;
}
body.gold-calculator-page .result-chip .chip-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: 'Cairo', sans-serif;
  display: block;
  margin-bottom: 3px;
}
body.gold-calculator-page .result-chip .chip-value {
  font-size: 0.95rem;
  font-weight: 700;
  font-family: 'Cairo', sans-serif;
  color: var(--gold-primary);
}
body.gold-calculator-page .result-chip .chip-value.profit { color: var(--profit-green); }
body.gold-calculator-page .result-chip .chip-value.loss   { color: var(--loss-red); }
body.gold-calculator-page .result-chip .chip-value.neutral { color: var(--text-muted); }

/* Market rate chip */
body.gold-calculator-page .market-rate-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(250,204,21,0.07);
  border: 1px solid rgba(250,204,21,0.2);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: 'Cairo', sans-serif;
  margin-bottom: 14px;
}
body.gold-calculator-page .market-rate-chip span {
  color: var(--gold-primary);
  font-weight: 700;
}

/* Portfolio summary box */
body.gold-calculator-page .portfolio-summary {
  background: linear-gradient(135deg, #0d1117, var(--surface-1));
  border: 2px solid rgba(250,204,21,0.35);
  border-radius: 20px;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
body.gold-calculator-page .portfolio-summary::after {
  content: '⬡';
  position: absolute;
  bottom: -20px; left: -10px;
  font-size: 120px;
  color: rgba(250,204,21,0.03);
  pointer-events: none;
  line-height: 1;
}

/* Summary title bar */
body.gold-calculator-page .summary-title {
  font-family: 'Cairo', sans-serif;
  font-weight: 900;
  color: var(--gold-primary);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(250,204,21,0.15);
}

/* Summary stat grid */
body.gold-calculator-page .summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 576px) {
  body.gold-calculator-page .summary-grid {
    grid-template-columns: 1fr;
  }
}

/* Individual stat cells */
body.gold-calculator-page .summary-stat {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px;
  padding: 14px 16px;
}
body.gold-calculator-page .summary-stat .stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: 'Cairo', sans-serif;
  margin-bottom: 4px;
  display: block;
}
body.gold-calculator-page .summary-stat .stat-value {
  font-size: 1.15rem;
  font-weight: 800;
  font-family: 'Cairo', sans-serif;
  color: var(--text-primary);
}
body.gold-calculator-page .summary-stat.highlight {
  background: rgba(250,204,21,0.07);
  border-color: rgba(250,204,21,0.25);
}
body.gold-calculator-page .summary-stat.highlight .stat-value {
  color: var(--gold-primary);
}

/* P&L display panel */
body.gold-calculator-page .pnl-display {
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}
body.gold-calculator-page .pnl-display.profit-bg {
  background: var(--profit-green-bg);
  border: 1px solid rgba(16,185,129,0.3);
}
body.gold-calculator-page .pnl-display.loss-bg {
  background: var(--loss-red-bg);
  border: 1px solid rgba(239,68,68,0.3);
}
body.gold-calculator-page .pnl-display.neutral-bg {
  background: rgba(107,114,128,0.1);
  border: 1px solid rgba(107,114,128,0.2);
}

/* P&L typography */
body.gold-calculator-page .pnl-label {
  font-family: 'Cairo', sans-serif;
  font-size: 0.85rem;
  color: var(--text-muted);
}
body.gold-calculator-page .pnl-amount {
  font-family: 'Cairo', sans-serif;
  font-weight: 900;
  font-size: 1.5rem;
}
body.gold-calculator-page .pnl-amount.profit { color: var(--profit-green); }
body.gold-calculator-page .pnl-amount.loss   { color: var(--loss-red); }
body.gold-calculator-page .pnl-amount.neutral { color: var(--text-muted); }

/* P&L percentage badge */
body.gold-calculator-page .pnl-pct {
  font-family: 'Cairo', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  padding: 4px 12px;
  border-radius: 999px;
}
body.gold-calculator-page .pnl-pct.profit {
  background: rgba(16,185,129,0.2);
  color: var(--profit-green);
}
body.gold-calculator-page .pnl-pct.loss {
  background: rgba(239,68,68,0.2);
  color: var(--loss-red);
}
body.gold-calculator-page .pnl-pct.neutral {
  background: rgba(107,114,128,0.15);
  color: var(--text-muted);
}

/* Reset button */
body.gold-calculator-page .btn-reset {
  background: transparent;
  border: 1px solid rgba(239,68,68,0.4);
  color: var(--loss-red);
  font-family: 'Cairo', sans-serif;
  font-weight: 700;
  border-radius: 10px;
  padding: 10px 24px;
  transition: all 0.2s;
  cursor: pointer;
  font-size: 0.9rem;
}
body.gold-calculator-page .btn-reset:hover {
  background: rgba(239,68,68,0.1);
  border-color: var(--loss-red);
}

/* Loading skeleton shimmer */
body.gold-calculator-page .skeleton {
  background: linear-gradient(90deg,
    rgba(255,255,255,0.04) 25%,
    rgba(255,255,255,0.09) 50%,
    rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: calc-shimmer 1.5s infinite;
  border-radius: 6px;
  display: inline-block;
}
@keyframes calc-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Error state banner */
body.gold-calculator-page .error-banner {
  background: var(--loss-red-bg);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--loss-red);
  font-family: 'Cairo', sans-serif;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Section heading with decorative rule */
body.gold-calculator-page .section-heading {
  font-family: 'Cairo', sans-serif;
  font-weight: 900;
  color: var(--text-primary);
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
body.gold-calculator-page .section-heading::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to left, transparent, rgba(250,204,21,0.3));
}

/* Last-updated micro-text */
body.gold-calculator-page .last-updated-text {
  font-family: 'Cairo', sans-serif;
  font-size: 0.75rem;
  color: var(--text-muted);
}
