/* ==========================================================================
   Dubai Gold Price Widget — Gold & White Dashboard theme (v3.1)
   Main accent : #D4AF37 (gold) — used everywhere per client spec.
   Text        : white (with translucent-white for secondary text so the
                 hierarchy still reads, since 100% white everywhere would
                 flatten the layout).
   Notes       : Full-bleed width on mobile/tablet (breaks out of the parent
                 container using the 100vw trick, not just width:100%, so it
                 is truly edge-to-edge regardless of the theme's padding).
                 7-day history collapses into stacked per-day cards on the
                 same breakpoint so the whole table is readable with no
                 side-scrolling on phones or tablets.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800;900&display=swap');

.dgp-widget {
  --bg: #0a0d13;
  --surface: #10141c;
  --card: #161b25;
  --card-hover: #1b222e;

  --gold: #d4af37;
  --gold-wash: rgba(212, 175, 55, 0.12);
  --gold-line: rgba(212, 175, 55, 0.45);

  --text: #ffffff;
  --text-dim: rgba(255, 255, 255, 0.66);
  --text-faint: rgba(255, 255, 255, 0.42);

  --border: #232a38;
  --border-soft: #1a202b;
  --live: #22c55e;
  --live-wash: rgba(34, 197, 94, 0.12);
  --live-glow: rgba(34, 197, 94, 0.35);
  --warn: #f87171;
  --warn-wash: rgba(248, 113, 113, 0.1);

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --font: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;

  max-width: 760px;
  margin: 32px auto;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px 26px 20px;
  font-family: var(--font);
  box-shadow: 0 24px 48px -30px rgba(0, 0, 0, 0.8);
  position: relative;
  box-sizing: border-box;
}

.dgp-widget::before {
  content: "";
  position: absolute;
  top: 0; left: 24px; right: 24px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.8;
}

/* numerals anywhere in the widget stay LTR even though the page is RTL */
.dgp-widget .dgp-value,
.dgp-widget .dgp-value-usd,
.dgp-widget .dgp-ounce-values,
.dgp-widget .dgp-hist-aed,
.dgp-widget .dgp-hist-usd,
.dgp-widget #dgp-last-updated {
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
}

/* ---------------- header ---------------- */
.dgp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  margin-bottom: 2px;
}

.dgp-title {
  font-size: 22px;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--text);
}

.dgp-subtitle {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
}

.dgp-subtitle #dgp-last-updated {
  color: var(--gold);
  font-weight: 700;
}

/* ---------------- live badge (blinking) ---------------- */
.dgp-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--live-wash);
  color: var(--live);
  border: 1px solid rgba(34, 197, 94, 0.3);
  padding: 7px 15px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}

.dgp-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 var(--live-glow);
  animation: dgp-blink 1.4s ease-in-out infinite;
}

@keyframes dgp-blink {
  0%   { box-shadow: 0 0 0 0 var(--live-glow); opacity: 1; }
  50%  { box-shadow: 0 0 0 6px rgba(34,197,94,0); opacity: 0.55; }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); opacity: 1; }
}

/* ---------------- price cards ---------------- */
.dgp-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.dgp-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 8px 14px;
  text-align: center;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.dgp-card:hover {
  transform: translateY(-2px);
  background: var(--card-hover);
  border-color: var(--gold-line);
}

.dgp-card-karat {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: #221a06;
  background: var(--gold);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
  letter-spacing: 0.01em;
}

.dgp-card-price-aed {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
}

.dgp-value {
  font-size: 21px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.dgp-currency {
  font-size: 11.5px;
  color: var(--text-dim);
  font-weight: 700;
}

.dgp-card-price-usd {
  margin-top: 5px;
}

.dgp-value-usd {
  font-size: 12px;
  color: var(--text-faint);
  font-weight: 600;
}

/* shimmer flash on live update */
.dgp-card.dgp-flash {
  animation: dgp-card-flash 0.8s ease-out;
}

@keyframes dgp-card-flash {
  0%   { background: var(--gold-wash); border-color: var(--gold); }
  100% { background: var(--card); border-color: var(--border); }
}

/* ---------------- ounce row ---------------- */
.dgp-ounce-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 8px;
}

.dgp-ounce-values {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.dgp-ounce-values strong {
  color: var(--gold);
  font-size: 16px;
  font-weight: 800;
}

.dgp-ounce-usd {
  color: var(--text-faint);
  font-size: 12.5px;
}

/* ---------------- error / notice ---------------- */
.dgp-error {
  padding: 14px 16px;
  border: 1px solid var(--warn);
  color: #ffffff;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  margin-bottom: 18px;
  background: var(--warn-wash);
  font-weight: 600;
}

.dgp-notice {
  padding: 12px 16px;
  border: 1px solid var(--gold-line);
  color: var(--text-dim);
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 16px;
  background: var(--gold-wash);
  font-weight: 500;
}

.dgp-error small,
.dgp-notice small {
  opacity: 0.85;
  font-weight: 400;
}

/* ---------------- history ---------------- */
.dgp-history h3 {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 12px;
}

.dgp-history h3::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--gold);
  margin-inline-end: 8px;
  vertical-align: middle;
}

.dgp-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.dgp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.dgp-table th {
  text-align: center;
  font-weight: 700;
  color: var(--text-dim);
  font-size: 11.5px;
  padding: 0 8px 10px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.dgp-table th:first-child { text-align: right; }

.dgp-table td {
  padding: 11px 8px;
  text-align: center;
  border-bottom: 1px solid var(--border-soft);
}

.dgp-table tr:hover td {
  background: rgba(212, 175, 55, 0.04);
}

.dgp-table td:first-child {
  text-align: right;
  color: var(--text-dim);
  font-weight: 600;
}

.dgp-hist-aed {
  display: block;
  font-weight: 700;
  color: var(--text);
}

.dgp-hist-usd {
  display: block;
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 1px;
}

.dgp-table tr:last-child td { border-bottom: none; }
.dgp-table tr:first-child .dgp-hist-aed { color: var(--gold); }

.dgp-history-empty {
  font-size: 13px;
  color: var(--text-dim);
}

/* ---------------- footer ---------------- */
.dgp-footer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text-faint);
}

/* ==========================================================================
   RESPONSIVE — tablet & mobile share one breakpoint (<= 768px) so this
   behaves the same on phones and small tablets.
   - Full-bleed width: breaks out of the parent container with the 100vw
     trick, since width:100% only fills the immediate parent, not the
     viewport, if the theme wraps the shortcode in a padded container.
   - History stays ONE single <table> (not stacked cards): fixed equal-width
     columns + smaller type let the date + all 4 karat columns fit on
     screen together, so all 7 rows are visible with no horizontal scroll.
   ========================================================================== */

@media (max-width: 768px) {
  .dgp-widget {
    max-width: 100vw;
    width: 100vw;
    margin: 16px calc(50% - 50vw);
    border-radius: 0;
    padding: 20px 16px 16px;
  }
  .dgp-widget::before { left: 16px; right: 16px; }

  .dgp-title { font-size: 19px; }
  .dgp-header { align-items: flex-start; }
  .dgp-cards { grid-template-columns: repeat(2, 1fr); }
  .dgp-value { font-size: 19px; }
  .dgp-ounce-row { flex-direction: column; align-items: flex-start; }

  /* ---- history: stays ONE real table, just compacted to fit — no side-scroll,
     no per-day card stack. Equal fixed-width columns + smaller type let all
     5 columns (date + 4 karats) sit on screen together. ---- */
  .dgp-table-scroll { overflow-x: visible; }

  .dgp-table {
    min-width: 0;
    table-layout: fixed;
    font-size: 11px;
  }

  .dgp-table th,
  .dgp-table td {
    padding: 7px 2px;
    word-break: break-word;
  }

  .dgp-table th {
    font-size: 9.5px;
    letter-spacing: 0;
    padding-bottom: 6px;
  }

  .dgp-hist-aed { font-size: 11.5px; }
  .dgp-hist-usd { font-size: 9px; }

  .dgp-ounce-row { font-size: 12px; }
}

@media (max-width: 360px) {
  .dgp-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .dgp-card { padding: 12px 8px 10px; }

  .dgp-table { font-size: 10px; }
  .dgp-table th { font-size: 8.5px; }
  .dgp-table th, .dgp-table td { padding: 6px 1px; }
  .dgp-hist-aed { font-size: 10.5px; }
  .dgp-hist-usd { font-size: 8px; }
}

/* ---------------- reduced motion ---------------- */
@media (prefers-reduced-motion: reduce) {
  .dgp-live-dot { animation: none; }
  .dgp-card.dgp-flash { animation: none; }
  .dgp-card { transition: none; }
}

/* ---------------- focus visibility ---------------- */
.dgp-widget a:focus-visible,
.dgp-widget button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
