/* ==========================================================================
   Gold Price Widget (TH) - Style Definition
   ========================================================================== */

.gpw-container {
  font-family: 'Prompt', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Thai", sans-serif;
  color: #1e293b;
  width: 100%;
  box-sizing: border-box;
}

.gpw-container *,
.gpw-container *::before,
.gpw-container *::after {
  box-sizing: border-box;
}

/* Header Area */
.gpw-header {
  margin-bottom: 20px;
}

.gpw-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.gpw-icon-candlestick {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 28px;
}

.gpw-icon-candlestick span {
  width: 4.5px;
  border-radius: 3px;
  display: inline-block;
}

.gpw-icon-candlestick .c-green {
  background: #16a34a;
  height: 24px;
}

.gpw-icon-candlestick .c-red {
  background: #dc2626;
  height: 28px;
}

.gpw-icon-candlestick .c-green-2 {
  background: #16a34a;
  height: 18px;
}

.gpw-main-title {
  font-size: 26px;
  font-weight: 800;
  color: #111827;
  letter-spacing: -0.5px;
  line-height: 1.2;
  margin: 0;
  padding: 0;
}

/* Live Badge */
.gpw-live-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #059669;
  font-size: 11px;
  font-weight: 700;
  border-radius: 9999px;
  letter-spacing: 0.5px;
  user-select: none;
}

.gpw-live-dot {
  width: 7px;
  height: 7px;
  background-color: #10b981;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: gpw-live-pulse 1.8s infinite cubic-bezier(0.66, 0, 0, 1);
}

@keyframes gpw-live-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.8);
    transform: scale(0.95);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(16, 185, 129, 0);
    transform: scale(1.1);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    transform: scale(0.95);
  }
}

.gpw-date-sub {
  font-size: 13.5px;
  color: #64748b;
  font-weight: 400;
  padding-left: 2px;
  transition: opacity 0.25s ease;
}

.gpw-date-sub.gpw-date-fade {
  opacity: 0.3;
}

/* Main Layout Grid */
.gpw-layout-grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 20px;
  align-items: stretch;
}

@media (max-width: 900px) {
  .gpw-layout-grid {
    grid-template-columns: 1fr;
  }
}

/* Price List Rows */
.gpw-price-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: space-between;
}

.gpw-row-card {
  background: #F7F8F9;
  border-radius: 12px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background-color 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease, transform 0.2s ease;
  border: 1px solid #eef2f6;
  box-shadow: 0 2px 5px -1px rgba(0, 0, 0, 0.06), 0 8px 12px -2px rgba(0, 0, 0, 0.05);
  position: relative;
}

.gpw-row-card:hover {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.08);
}

/* Item Name & Unit */
.gpw-item-info {
  flex: 1.2;
  min-width: 140px;
}

.gpw-item-name {
  font-size: 16px;
  font-weight: 800;
  color: #1e293b;
  line-height: 1.3;
}

.gpw-item-unit {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
  margin-top: 2px;
}

/* Price Columns (Buy & Sell) */
.gpw-prices-group {
  display: flex;
  gap: 16px;
  flex: 1.8;
  justify-content: flex-end;
}

.gpw-price-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 100px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: background-color 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease;
}

/* Independent Column Flash when specific price updates */
.gpw-price-col.gpw-col-flash-up {
  background: #f0fdf4 !important;
  border-color: #86efac !important;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.25) !important;
}

.gpw-price-col.gpw-col-flash-down {
  background: #fef2f2 !important;
  border-color: #fca5a5 !important;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.25) !important;
}

/* Badges / Labels */
.gpw-badge {
  font-size: 12px;
  font-weight: 600;
  display: inline-block;
  line-height: 1.2;
  margin-bottom: 3px;
  letter-spacing: 0.2px;
}

.gpw-badge-buy {
  color: #E94949; /* TradeX Red */
}

.gpw-badge-sell {
  color: #17C161; /* TradeX Green */
}

/* Price Text & Dynamic Number Animation */
.gpw-price-value {
  font-size: 22px;
  font-weight: 800;
  color: #1e293b;
  letter-spacing: -0.3px;
  white-space: nowrap;
  display: inline-block;
  transition: color 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  will-change: transform, color;
}

/* Price Movement Animation - Up (Green Flash) */
.gpw-price-value.gpw-val-up {
  color: #15803d !important;
  animation: gpw-num-up 1.2s ease-out;
}

@keyframes gpw-num-up {
  0% {
    transform: translateY(0) scale(1);
    color: #16a34a;
  }
  25% {
    transform: translateY(-2px) scale(1.1);
    color: #15803d;
    text-shadow: 0 0 10px rgba(34, 197, 94, 0.4);
  }
  60% {
    transform: translateY(0) scale(1.03);
    color: #16a34a;
  }
  100% {
    transform: translateY(0) scale(1);
    color: #1e293b;
  }
}

/* Price Movement Animation - Down (Red Flash) */
.gpw-price-value.gpw-val-down {
  color: #b91c1c !important;
  animation: gpw-num-down 1.2s ease-out;
}

@keyframes gpw-num-down {
  0% {
    transform: translateY(0) scale(1);
    color: #dc2626;
  }
  25% {
    transform: translateY(2px) scale(1.1);
    color: #b91c1c;
    text-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
  }
  60% {
    transform: translateY(0) scale(1.03);
    color: #dc2626;
  }
  100% {
    transform: translateY(0) scale(1);
    color: #1e293b;
  }
}

/* Chart Container */
.gpw-chart-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  min-height: 380px;
}

.gpw-tv-container {
  width: 100%;
  height: 100%;
  min-height: 380px;
  flex: 1;
}

/* Error Notice */
.gpw-error-notice {
  margin-top: 14px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
}

@media (max-width: 480px) {
  .gpw-row-card {
    padding: 10px 12px;
  }
  .gpw-item-name {
    font-size: 13px;
  }
  .gpw-price-value {
    font-size: 15px;
  }
  .gpw-prices-group {
    gap: 10px;
  }
  .gpw-price-col {
    min-width: 75px;
  }
}
