/* ==========================================================================
   CSS for /gold-graph/ (รวมกราฟราคาทองคำวันนี้ & สถิติกราฟย้อนหลัง) - raakaadee.com
   High Performance & WCAG 2.1 AA Compliant
   ========================================================================== */

:root {
  --graph-bg: #07090d;
  --graph-panel-bg: rgba(13, 20, 32, 0.76);
  --graph-card-bg: rgba(18, 27, 45, 0.88);
  --graph-border: rgba(245, 196, 81, 0.22);
  --graph-border-hover: rgba(245, 196, 81, 0.6);
  --graph-gold: #f5c451;
  --graph-gold-light: #ffe08a;
  --graph-gold-dark: #b8860b;
  --graph-text: #f3f6fa;
  --graph-muted: #a6b7cc; /* WCAG AA 4.5:1+ contrast on #07090d */
  --graph-up: #2ecc71;
  --graph-down: #ff5252;
  --graph-radius: 16px;
  --graph-radius-sm: 10px;
  --graph-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  --graph-glow: 0 0 24px rgba(245, 196, 81, 0.14);
}

/* Base resets & layout container */
body.gold-graph-page {
  background-color: var(--graph-bg);
  color: var(--graph-text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans Thai", sans-serif;
  line-height: 1.6;
  margin: 0;
  padding: 0;
}

.gold-graph-container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Glassmorphism utility */
.graph-glass {
  background: var(--graph-panel-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--graph-border);
  border-radius: var(--graph-radius);
  box-shadow: var(--graph-shadow);
}

/* Breadcrumb */
.graph-breadcrumb {
  padding: 16px 0 8px;
}

.graph-breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.88rem;
  color: var(--graph-muted);
}

.graph-breadcrumb li + li::before {
  content: "›";
  margin-right: 8px;
  color: var(--graph-border);
  font-weight: bold;
}

.graph-breadcrumb a {
  color: var(--graph-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.graph-breadcrumb a:hover,
.graph-breadcrumb a:focus-visible {
  color: var(--graph-gold-light);
  text-decoration: underline;
}

.graph-breadcrumb [aria-current="page"] {
  color: var(--graph-gold);
  font-weight: 700;
}

/* Hero Section */
.graph-hero {
  padding: 18px 0 28px;
}

.graph-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(245, 196, 81, 0.12);
  border: 1px solid rgba(245, 196, 81, 0.35);
  border-radius: 999px;
  color: var(--graph-gold);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.graph-pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--graph-up);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--graph-up);
  animation: pulse-live 1.8s infinite;
}

@keyframes pulse-live {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.35); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.graph-hero h1 {
  font-size: clamp(1.6rem, 3.2vw, 2.45rem);
  font-weight: 800;
  line-height: 1.3;
  color: #ffffff;
  margin: 0 0 14px;
  letter-spacing: -0.01em;
}

.graph-hero-lead {
  font-size: clamp(0.95rem, 1.8vw, 1.12rem);
  color: var(--graph-muted);
  max-width: 960px;
  margin: 0 0 22px;
  line-height: 1.7;
}

/* Quick Jump Navigation */
.graph-jump-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 12px 16px;
  margin-bottom: 24px;
  border-radius: 14px;
  border: 1px solid rgba(245, 196, 81, 0.25);
  background: rgba(245, 196, 81, 0.06);
}

.graph-jump-nav span {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--graph-text);
}

.graph-jump-nav a {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--graph-gold-light);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  transition: all 0.2s ease;
}

.graph-jump-nav a:hover,
.graph-jump-nav a:focus-visible {
  background: rgba(245, 196, 81, 0.22);
  color: #ffffff;
  outline: 2px solid var(--graph-gold);
}

/* Metric Summary Grid */
.graph-metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 30px;
}

.metric-card {
  padding: 18px 20px;
  border-radius: var(--graph-radius);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: var(--graph-border-hover);
}

.metric-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--graph-gold);
}

.metric-card.is-up::after { background: var(--graph-up); }
.metric-card.is-down::after { background: var(--graph-down); }

.metric-label {
  font-size: 0.86rem;
  color: var(--graph-muted);
  font-weight: 600;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.metric-value {
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  font-weight: 800;
  color: #ffffff;
  line-height: 1.2;
  margin-bottom: 6px;
}

.metric-sub {
  font-size: 0.82rem;
  color: var(--graph-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.metric-sub strong.is-up { color: var(--graph-up); font-weight: 800; }
.metric-sub strong.is-down { color: var(--graph-down); font-weight: 800; }

/* Main Chart Panels */
.graph-panel {
  padding: clamp(20px, 3.5vw, 32px);
  margin-bottom: 32px;
}

.graph-panel-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 16px;
}

.graph-panel-title-area h2 {
  font-size: clamp(1.2rem, 2.4vw, 1.6rem);
  font-weight: 800;
  color: #ffffff;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.graph-panel-title-area p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--graph-muted);
}

/* Timeframe Selector Button Bar */
.timeframe-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: rgba(0, 0, 0, 0.45);
  padding: 4px;
  border-radius: 999px;
  border: 1px solid rgba(245, 196, 81, 0.2);
}

.timeframe-btn {
  background: transparent;
  border: none;
  color: var(--graph-muted);
  font-size: 0.84rem;
  font-weight: 700;
  min-height: 38px;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.timeframe-btn:hover,
.timeframe-btn:focus-visible {
  color: var(--graph-gold-light);
  background: rgba(245, 196, 81, 0.15);
  outline: 2px solid var(--graph-gold);
}

.timeframe-btn.is-active {
  background: var(--graph-gold);
  color: #1a1300;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(245, 196, 81, 0.35);
}

/* Chart Canvas Wrapper */
.chart-viewport-wrapper {
  position: relative;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(5, 8, 14, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.chart-viewport {
  width: 100%;
  height: clamp(420px, 48vw, 560px);
  min-height: 420px;
}

/* Loading Overlay */
.chart-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(7, 9, 13, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--graph-gold-light);
  font-weight: 700;
  font-size: 0.95rem;
  z-index: 10;
  transition: opacity 0.35s ease, visibility 0.35s ease;
  pointer-events: none;
}

.chart-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(245, 196, 81, 0.2);
  border-top-color: var(--graph-gold);
  border-radius: 50%;
  animation: tv-spin 0.8s linear infinite;
  margin-right: 12px;
  flex-shrink: 0;
}

@keyframes tv-spin {
  to { transform: rotate(360deg); }
}

.chart-caption-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  font-size: 0.84rem;
  color: var(--graph-muted);
}

.chart-legend-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.gold-sell { background-color: #f5c451; }
.legend-dot.gold-high { background-color: #2ecc71; }
.legend-dot.gold-low { background-color: #ff5252; }
.legend-dot.gold-spot { background-color: #38bdf8; }

/* Stats Summary Table (1M to 20Y) */
.stats-summary-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 20px;
  border-radius: var(--graph-radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(5, 8, 14, 0.6);
}

.stats-summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  text-align: right;
  white-space: nowrap;
}

.stats-summary-table caption {
  caption-side: bottom;
  text-align: left;
  font-size: 0.82rem;
  color: var(--graph-muted);
  padding: 10px 14px 4px;
}

.stats-summary-table th,
.stats-summary-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.stats-summary-table th {
  background: rgba(14, 22, 38, 0.95);
  color: var(--graph-gold);
  font-weight: 700;
  font-size: 0.88rem;
}

.stats-summary-table th:first-child,
.stats-summary-table td:first-child {
  text-align: left;
}

.stats-summary-table tbody tr:hover {
  background: rgba(245, 196, 81, 0.06);
}

.stats-badge-tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(245, 196, 81, 0.15);
  color: var(--graph-gold-light);
  font-size: 0.78rem;
  font-weight: 700;
  margin-right: 6px;
}

.stats-view-btn {
  padding: 5px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--graph-border);
  color: var(--graph-gold-light);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.stats-view-btn:hover {
  background: var(--graph-gold);
  color: #07090d;
  box-shadow: 0 4px 12px rgba(245, 196, 81, 0.35);
}

/* Interactive Simulator / Formula Calculator */
.simulator-panel {
  padding: clamp(20px, 3.5vw, 32px);
  margin-bottom: 32px;
  border: 1px solid rgba(245, 196, 81, 0.28);
  background: linear-gradient(135deg, rgba(18, 27, 45, 0.92) 0%, rgba(13, 20, 32, 0.95) 100%);
}

.simulator-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  align-items: center;
}

.formula-display-box {
  background: rgba(0, 0, 0, 0.45);
  padding: 16px 20px;
  border-radius: 12px;
  border: 1px dashed rgba(245, 196, 81, 0.35);
  font-family: monospace, sans-serif;
  font-size: 0.92rem;
  color: #ffecb3;
  margin-bottom: 18px;
  word-break: break-all;
}

.sim-input-group {
  margin-bottom: 16px;
}

.sim-input-group label {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--graph-text);
  margin-bottom: 6px;
}

.sim-input-group label span {
  color: var(--graph-gold);
}

.sim-input-field {
  width: 100%;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 700;
  box-sizing: border-box;
  transition: border-color 0.2s ease;
}

.sim-input-field:focus {
  outline: 2px solid var(--graph-gold);
  border-color: var(--graph-gold);
}

.sim-range-slider {
  width: 100%;
  margin-top: 8px;
  accent-color: var(--graph-gold);
  min-height: 24px;
}

.sim-result-card {
  background: rgba(245, 196, 81, 0.1);
  border: 1px solid rgba(245, 196, 81, 0.35);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  box-shadow: var(--graph-glow);
}

.sim-result-title {
  font-size: 0.92rem;
  color: var(--graph-gold-light);
  font-weight: 700;
  margin-bottom: 8px;
}

.sim-result-price {
  font-size: clamp(2rem, 3.8vw, 2.75rem);
  font-weight: 900;
  color: #ffffff;
  line-height: 1.1;
  margin-bottom: 8px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.sim-result-note {
  font-size: 0.84rem;
  color: var(--graph-muted);
}

/* History Navigation Rows (Matching Image 4) */
.history-period-navigation {
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid rgba(245, 196, 81, 0.18);
}

.history-nav-row {
  margin-bottom: 24px;
}

.history-nav-row h3 {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--graph-text);
  letter-spacing: -0.01em;
}

.history-filter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
}

.history-filter-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 16px;
  border: 1px solid rgba(245, 196, 81, 0.3);
  border-radius: 999px;
  background: rgba(245, 196, 81, 0.08);
  color: #f7e7bd;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.history-filter-button:hover,
.history-filter-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(245, 196, 81, 0.72);
  background: rgba(245, 196, 81, 0.18);
  color: #ffffff;
  outline: 2px solid var(--graph-gold);
}

.history-filter-button.is-active {
  border-color: #ffe08a;
  background: linear-gradient(135deg, #ffe08a 0%, #f5c451 100%);
  box-shadow: 0 8px 24px rgba(245, 196, 81, 0.25);
  color: #2e2100;
}

.history-filter-button.is-active::before {
  content: "✓";
  margin-right: 6px;
  font-weight: 900;
}

/* Educational Guide & E-E-A-T Articles */
.gold-guide-section {
  padding: clamp(24px, 4vw, 40px);
  margin-bottom: 32px;
}

.gold-guide-section h2 {
  font-size: clamp(1.3rem, 2.6vw, 1.85rem);
  color: #ffffff;
  margin-top: 0;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(245, 196, 81, 0.18);
}

.gold-guide-section h3 {
  font-size: 1.25rem;
  color: var(--graph-gold-light);
  margin-top: 28px;
  margin-bottom: 12px;
}

.gold-guide-section p, 
.gold-guide-section li {
  color: var(--graph-muted);
  font-size: 0.98rem;
  line-height: 1.75;
}

.gold-guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin: 22px 0;
}

.guide-feature-box {
  background: rgba(0, 0, 0, 0.35);
  padding: 20px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.guide-feature-box h3,
.guide-feature-box h4 {
  margin: 0 0 10px;
  font-size: 1.05rem;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.guide-feature-box p {
  margin: 0;
  font-size: 0.92rem;
}

/* Comparison Table */
.gold-comparison-table-wrapper {
  overflow-x: auto;
  margin: 24px 0;
  border-radius: 12px;
  border: 1px solid rgba(245, 196, 81, 0.2);
}

.gold-comparison-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.94rem;
}

.gold-comparison-table th {
  background: rgba(245, 196, 81, 0.14);
  color: var(--graph-gold-light);
  padding: 14px 16px;
  font-weight: 700;
  border-bottom: 1px solid rgba(245, 196, 81, 0.2);
}

.gold-comparison-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--graph-text);
}

.gold-comparison-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

/* FAQ Section */
.graph-faq-section {
  padding: clamp(24px, 4vw, 40px);
  margin-bottom: 32px;
}

.faq-item {
  margin-bottom: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.32);
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.faq-item[open] {
  border-color: rgba(245, 196, 81, 0.4);
  background: rgba(245, 196, 81, 0.04);
}

.faq-item summary {
  padding: 16px 20px;
  font-weight: 700;
  font-size: 1rem;
  color: #ffffff;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  font-size: 1.4rem;
  color: var(--graph-gold);
  line-height: 1;
  transition: transform 0.2s ease;
}

.faq-item[open] summary::after {
  content: "−";
  transform: rotate(180deg);
}

.faq-answer {
  padding: 0 20px 20px;
  color: var(--graph-muted);
  font-size: 0.96rem;
  line-height: 1.7;
}

/* AdSense & Ezoic compliant ad containers - High Contrast & No Deception */
.ad-slot-container {
  margin: 28px 0;
  padding: 16px;
  text-align: center;
  background: rgba(0, 0, 0, 0.25);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ad-label {
  font-size: 0.78rem;
  color: var(--graph-muted); /* WCAG compliant contrast */
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

/* Compliance Disclaimer Box */
.compliance-disclaimer-box {
  margin-top: 24px;
  padding: 16px 20px;
  background: rgba(255, 152, 0, 0.06);
  border-left: 4px solid var(--graph-gold);
  border-radius: 0 10px 10px 0;
  font-size: 0.88rem;
  color: var(--graph-muted);
  line-height: 1.6;
}

.compliance-disclaimer-box strong {
  color: var(--graph-gold-light);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .graph-panel-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .timeframe-bar {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 6px;
  }
  
  .timeframe-btn {
    padding: 6px 12px;
    font-size: 0.82rem;
  }
  
  .history-filter-button {
    min-height: 38px;
    padding: 7px 14px;
    font-size: 0.85rem;
  }
}
