/* =============================================================================
   Gold Price Manager — Premium Frontend Goldbox Styles
   Luxury Red & Gold design system with glassmorphism and animations.
   ============================================================================= */

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

:root {
    --gold-brand-color: #8D1B1B;
    --gold-brand-light: #B71C1C;
    --gold-accent: #D4AF37;
    --gold-accent-light: #F3C63F;
    --gold-accent-dark: #AA7C11;
    --gold-header-text: #ffffff;
    --gold-title-color: #333333;
    --gold-buy-color: #C62828;
    --gold-buy-bg: rgba(198, 40, 40, 0.05);
    --gold-buy-border: rgba(198, 40, 40, 0.12);
    --gold-sell-color: #2E7D32;
    --gold-sell-bg: rgba(46, 125, 50, 0.05);
    --gold-sell-border: rgba(46, 125, 50, 0.12);
    --gold-hover-bg: rgba(212, 175, 55, 0.06);
    --gold-border: #f0f0f0;
    --gold-narration-bg: #FCFAF5;
    --gold-action-bg: #fdfdfd;
    --gold-radius: 16px;
    --gold-font: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --glass-shadow: 0 10px 30px rgba(141, 27, 27, 0.08);
}

/* ---------- Wrapper ---------- */
.goldbox {
    max-width: 100%;
    border-radius: var(--gold-radius);
    box-shadow: var(--glass-shadow);
    overflow: hidden;
    margin-bottom: 30px;
    font-family: var(--gold-font);
    background: #ffffff;
    border: 1px solid rgba(212, 175, 55, 0.25);
    box-sizing: border-box;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.goldbox:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(141, 27, 27, 0.12);
}

/* ---------- Header ---------- */
.goldbox-head {
    background: linear-gradient(135deg, #7A1212 0%, #9F2222 50%, #7A1212 100%);
    color: var(--gold-header-text);
    padding: 22px 24px;
    position: relative;
    overflow: hidden;
    border-bottom: 3px solid var(--gold-accent);
}

/* Shimmer animation effect */
.goldbox-head::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -60%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0) 40%,
        rgba(255, 255, 255, 0.08) 50%,
        rgba(255, 255, 255, 0) 60%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: goldbox-shimmer 6s infinite linear;
    pointer-events: none;
}

@keyframes goldbox-shimmer {
    0% { transform: translate(-30%, -30%) rotate(0deg); }
    100% { transform: translate(30%, 30%) rotate(0deg); }
}

.goldbox-title {
    font-family: var(--gold-font);
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 6px;
    letter-spacing: 0.5px;
    line-height: 1.3;
    text-transform: uppercase;
}

.goldbox-head .goldbox-title {
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.goldbox-updated {
    font-size: 0.85rem;
    opacity: 0.9;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.goldbox-updated svg {
    stroke: var(--gold-accent-light);
}

.goldbox-updated::before {
    display: none; /* remove emoji fallback */
}

/* ---------- Price Table ---------- */
.goldbox-table-wrap {
    overflow-x: auto;
}

.goldbox-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.goldbox-table thead th {
    background: #fdfcf9;
    color: #444444;
    padding: 14px 18px;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
    border-bottom: 2px solid #eaeaea;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.goldbox-table thead th:first-child {
    text-align: left;
}

.goldbox-table tbody td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--gold-border);
    font-size: 0.95rem;
    vertical-align: middle;
    transition: background 0.2s ease;
}

.goldbox-table tbody tr {
    transition: all 0.2s ease;
}

.goldbox-table tbody td:first-child {
    font-weight: 600;
    color: #1a1a1a;
    font-size: 0.95rem;
    letter-spacing: 0.2px;
}

/* Price Cells Styling */
.goldbox-table tbody td.goldbox-buy {
    text-align: right;
    font-weight: 700;
    color: var(--gold-buy-color);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.goldbox-table tbody td.goldbox-sell {
    text-align: right;
    font-weight: 700;
    color: var(--gold-sell-color);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Format inner value like pill button */
.goldbox-table tbody td.goldbox-buy,
.goldbox-table tbody td.goldbox-sell {
    font-size: 1.05rem;
}

/* Hover row highlight with golden glow */
.goldbox-table tbody tr:hover {
    background: var(--gold-hover-bg);
}

/* Zebra striping */
.goldbox-table tbody tr:nth-child(even) {
    background: #fbfbf9;
}

.goldbox-table tbody tr:nth-child(even):hover {
    background: var(--gold-hover-bg);
}

.goldbox-table tbody tr:last-child td {
    border-bottom: none;
}

/* ---------- Narration Block ---------- */
.goldbox-narration {
    padding: 20px 24px;
    background: var(--gold-narration-bg);
    border-top: 1px solid rgba(212, 175, 55, 0.15);
    border-left: 4px solid var(--gold-accent);
    font-size: 0.9rem;
    color: #555;
    line-height: 1.8;
    margin: 15px 24px;
    border-radius: 8px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.02);
}

.goldbox-narration p {
    margin: 8px 0;
}

.goldbox-narration p:first-child {
    margin-top: 0;
}

.goldbox-narration p:last-child {
    margin-bottom: 0;
}

.goldbox-narration strong {
    color: #1a1a1a;
    font-weight: 600;
}

/* ---------- Action Buttons ---------- */
.goldbox-actions {
    display: flex;
    gap: 12px;
    padding: 20px 24px;
    background: var(--gold-action-bg);
    border-top: 1px solid #f0f0f0;
}

.goldbox-actions a,
.goldbox-actions .goldbox-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px 16px;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    color: #ffffff !important;
    text-decoration: none !important;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    line-height: 1.2;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Gold Gradient Button (History) */
.goldbox-actions a:first-child,
.goldbox-actions .goldbox-btn:first-child {
    background: linear-gradient(135deg, var(--gold-brand-color) 0%, #B71C1C 100%) !important;
    box-shadow: 0 4px 15px rgba(141, 27, 27, 0.2);
}

.goldbox-actions a:first-child:hover,
.goldbox-actions .goldbox-btn:first-child:hover {
    background: linear-gradient(135deg, #A82525 0%, #D32F2F 100%) !important;
    box-shadow: 0 8px 25px rgba(141, 27, 27, 0.35);
}

/* Secondary Gold Accent Gradient (Prediction) */
.goldbox-actions a:nth-child(2),
.goldbox-actions .goldbox-btn:nth-child(2) {
    background: linear-gradient(135deg, var(--gold-accent) 0%, var(--gold-accent-dark) 100%) !important;
    box-shadow: 0 4px 15px rgba(170, 124, 17, 0.2);
}

.goldbox-actions a:nth-child(2):hover,
.goldbox-actions .goldbox-btn:nth-child(2):hover {
    background: linear-gradient(135deg, var(--gold-accent-light) 0%, var(--gold-accent) 100%) !important;
    box-shadow: 0 8px 25px rgba(170, 124, 17, 0.35);
}

.goldbox-actions a:hover,
.goldbox-actions .goldbox-btn:hover {
    transform: translateY(-2px);
}

.goldbox-actions a:active,
.goldbox-actions .goldbox-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.goldbox-actions svg {
    width: 20px;
    height: 20px;
}

/* ---------- History Panel ---------- */
.goldbox-history {
    border-top: 1px solid #f0f0f0;
    background: #ffffff;
    padding: 24px;
}

.goldbox-history-spinner {
    text-align: center;
    padding: 35px 20px;
    color: #666;
    font-size: 0.95rem;
    font-weight: 500;
}

.goldbox-history-spinner::before {
    content: '';
    display: inline-block;
    width: 26px;
    height: 26px;
    border: 3px solid #f0f0f0;
    border-top-color: var(--gold-brand-color);
    border-radius: 50%;
    animation: goldbox-spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 10px;
}

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

.goldbox-history select {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid #e0e0e0;
    border-radius: 10px;
    font-size: 0.95rem;
    margin-bottom: 20px;
    background: #fdfdfd;
    cursor: pointer;
    font-family: var(--gold-font);
    font-weight: 500;
    transition: all 0.2s;
}

.goldbox-history select:focus {
    border-color: var(--gold-accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

/* Stats grid */
.goldbox-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.goldbox-stat-card {
    background: #fdfcf9;
    border-radius: 12px;
    padding: 16px 12px;
    text-align: center;
    border: 1px solid rgba(212, 175, 55, 0.15);
    box-shadow: 0 4px 10px rgba(0,0,0,0.02);
}

.goldbox-stat-card .stat-label {
    font-size: 0.75rem;
    color: #777;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
    margin-bottom: 6px;
}

.goldbox-stat-card .stat-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1a1a1a;
    font-variant-numeric: tabular-nums;
}

/* Chart container */
.goldbox-chart-wrap {
    margin: 24px 0;
    padding: 16px;
    background: #fafafa;
    border-radius: 12px;
    border: 1px solid #eeeeee;
}

/* Daily list */
.goldbox-daily-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.goldbox-day-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid #eee;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.goldbox-day-card:hover {
    background: var(--gold-hover-bg);
    border-color: rgba(212, 175, 55, 0.2);
}

.goldbox-day-card .day-date {
    font-weight: 600;
    color: #222;
    min-width: 95px;
}

.goldbox-day-card .day-change {
    font-weight: 700;
    font-size: 0.85rem;
    padding: 4px 10px;
    border-radius: 6px;
}

.goldbox-day-card .day-change.up {
    color: #2e7d32;
    background: #e8f5e9;
}

.goldbox-day-card .day-change.down {
    color: #c62828;
    background: #ffebee;
}

.goldbox-day-card .day-change.flat {
    color: #666;
    background: #f5f5f5;
}

.goldbox-day-card .day-prices {
    font-variant-numeric: tabular-nums;
    color: #444;
    font-weight: 500;
}

/* ---------- Prediction Panel ---------- */
.goldbox-predict {
    border-top: 1px solid #f0f0f0;
    background: #ffffff;
    padding: 24px;
}

.goldbox-predict-spinner {
    text-align: center;
    padding: 45px 20px;
    color: #666;
    font-size: 0.95rem;
    font-weight: 500;
}

.goldbox-predict-spinner::before {
    content: '';
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid #f0f0f0;
    border-top-color: var(--gold-accent);
    border-radius: 50%;
    animation: goldbox-spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 10px;
}

/* Prediction table */
.goldbox-predict-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin: 20px 0;
}

.goldbox-predict-table thead th {
    background: #fcfbfa;
    padding: 10px 12px;
    font-weight: 700;
    font-size: 0.85rem;
    color: #444;
    text-align: center;
    border-bottom: 2px solid #eaeaea;
}

.goldbox-predict-table thead th:first-child {
    text-align: left;
}

.goldbox-predict-table tbody td {
    padding: 12px;
    border-bottom: 1px solid #f5f5f5;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.goldbox-predict-table tbody td:first-child {
    text-align: left;
    font-weight: 600;
    color: #111;
}

/* Trend icons */
.goldbox-trend-up {
    color: #2e7d32;
    font-weight: 800;
}

.goldbox-trend-down {
    color: #c62828;
    font-weight: 800;
}

.goldbox-trend-flat {
    color: #777;
    font-weight: 600;
}

/* News summary card */
.goldbox-news-card {
    background: linear-gradient(135deg, #fdfcfb, #ffffff);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.01);
}

.goldbox-news-card h4 {
    margin: 0 0 12px;
    font-size: 1.05rem;
    color: #1a1a1a;
    font-weight: 700;
}

.goldbox-news-scores {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.goldbox-score-pill {
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.goldbox-score-pill.bullish {
    background: #e8f5e9;
    color: #2e7d32;
}

.goldbox-score-pill.neutral {
    background: #fff3e0;
    color: #e65100;
}

.goldbox-score-pill.bearish {
    background: #ffebee;
    color: #c62828;
}

/* Factors lists */
.goldbox-factors {
    margin: 16px 0;
}

.goldbox-factors h5 {
    margin: 0 0 8px;
    font-size: 0.9rem;
    font-weight: 600;
}

.goldbox-factors ul {
    margin: 0;
    padding-left: 20px;
    font-size: 0.88rem;
    line-height: 1.6;
    color: #555;
}

.goldbox-factors.bull h5 {
    color: #2e7d32;
}

.goldbox-factors.bear h5 {
    color: #c62828;
}

/* Vietnam Analysis specific */
.goldbox-vn-section {
    background: #fffdf5;
    border: 1px solid #ffe8d1;
    border-radius: 10px;
    padding: 16px;
    margin: 18px 0;
    font-size: 0.9rem;
    color: #5d4037;
    line-height: 1.7;
}

.goldbox-vn-section h4 {
    margin: 0 0 8px;
    color: #d84315;
    font-size: 0.95rem;
    font-weight: 700;
}

/* Evaluation section */
.goldbox-evaluation {
    background: #fbf8ff;
    border: 1px solid #ebdeff;
    border-radius: 10px;
    padding: 16px;
    margin: 18px 0;
    font-size: 0.9rem;
    color: #4a148c;
    line-height: 1.7;
}

.goldbox-evaluation h4 {
    margin: 0 0 8px;
    font-size: 0.95rem;
    font-weight: 700;
}

/* Impact prediction */
.goldbox-impact {
    background: #f4faff;
    border: 1px solid #d2e9ff;
    border-radius: 10px;
    padding: 16px;
    margin: 18px 0;
    font-size: 0.9rem;
    color: #1565c0;
    line-height: 1.7;
}

.goldbox-impact h4 {
    margin: 0 0 8px;
    font-size: 0.95rem;
    font-weight: 700;
}

/* Disclaimer */
.goldbox-disclaimer {
    background: #fdfdfd;
    border-radius: 8px;
    padding: 14px;
    margin-top: 20px;
    font-size: 0.8rem;
    color: #888;
    line-height: 1.6;
    font-style: italic;
    border-left: 3px solid #ccc;
}

/* ---------- Responsive: max-width 600px ---------- */
@media (max-width: 600px) {
    .goldbox-head {
        padding: 16px;
    }

    .goldbox-title {
        font-size: 1.15rem;
    }

    .goldbox-table thead th,
    .goldbox-table tbody td {
        padding: 12px 10px;
        font-size: 0.85rem;
    }

    .goldbox-table tbody td.goldbox-buy,
    .goldbox-table tbody td.goldbox-sell {
        font-size: 0.95rem;
    }

    .goldbox-actions {
        flex-direction: column;
        gap: 8px;
        padding: 16px;
    }

    .goldbox-actions a,
    .goldbox-actions .goldbox-btn {
        font-size: 14px;
        padding: 14px 10px;
    }

    .goldbox-stats-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .goldbox-narration {
        padding: 14px 16px;
        font-size: 0.85rem;
        margin: 10px 16px;
    }

    .goldbox-day-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        padding: 12px;
    }

    .goldbox-predict-table thead th,
    .goldbox-predict-table tbody td {
        padding: 8px;
        font-size: 0.82rem;
    }
}

/* ---------- Responsive: max-width 400px ---------- */
@media (max-width: 400px) {
    .goldbox-table thead th,
    .goldbox-table tbody td {
        padding: 10px 6px;
        font-size: 0.8rem;
    }
}

/* ---------- Dark Mode Support ---------- */
.hm-dark .goldbox {
    background: #151522;
    border-color: rgba(212, 175, 55, 0.2);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.hm-dark .goldbox-head {
    background: linear-gradient(135deg, #5c0b0b 0%, #7d1515 50%, #5c0b0b 100%);
    border-bottom-color: var(--gold-accent);
}

.hm-dark .goldbox-table thead th {
    background: #1a1a2e;
    color: #ccc;
    border-bottom-color: #2a2a3e;
}

.hm-dark .goldbox-table tbody td {
    border-color: #222232;
    color: #ddd;
}

.hm-dark .goldbox-table tbody td:first-child {
    color: #ffffff;
}

.hm-dark .goldbox-table tbody tr:nth-child(even) {
    background: #19192b;
}

.hm-dark .goldbox-table tbody tr:hover {
    background: rgba(212, 175, 55, 0.04);
}

.hm-dark .goldbox-narration {
    background: #19192c;
    color: #bbb;
    border-top-color: rgba(212, 175, 55, 0.15);
}

.hm-dark .goldbox-narration strong {
    color: #ffffff;
}

.hm-dark .goldbox-actions {
    background: #11111c;
    border-top-color: #222232;
}

.hm-dark .goldbox-history,
.hm-dark .goldbox-predict {
    background: #151522;
    border-top-color: #222232;
}

.hm-dark .goldbox-history select {
    background: #1a1a2e;
    border-color: #333;
    color: #ddd;
}

.hm-dark .goldbox-stat-card {
    background: #19192b;
    border-color: rgba(212, 175, 55, 0.15);
}

.hm-dark .goldbox-stat-card .stat-value {
    color: #ffffff;
}

.hm-dark .goldbox-chart-wrap {
    background: #19192b;
    border-color: #2a2a3e;
}

.hm-dark .goldbox-day-card {
    background: #151522;
    border-color: #2a2a3e;
    color: #ccc;
}

.hm-dark .goldbox-day-card .day-date {
    color: #ffffff;
}

.hm-dark .goldbox-news-card {
    background: #19192b;
    border-color: rgba(212, 175, 55, 0.15);
}

.hm-dark .goldbox-news-card h4 {
    color: #ffffff;
}

.hm-dark .goldbox-vn-section {
    background: #1e1e10;
    border-color: #3e3e20;
    color: #bbb;
}

.hm-dark .goldbox-evaluation {
    background: #18112b;
    border-color: #38215c;
    color: #bbb;
}

.hm-dark .goldbox-impact {
    background: #0d1a33;
    border-color: #213c6e;
    color: #aaccff;
}

.hm-dark .goldbox-disclaimer {
    background: #11111c;
    color: #777;
    border-left-color: #333;
}

.hm-dark .goldbox-predict-table thead th {
    background: #19192b;
    color: #bbb;
    border-bottom-color: #2a2a3e;
}

.hm-dark .goldbox-predict-table tbody td {
    border-bottom-color: #222232;
    color: #ccc;
}

/* ---------- Print Styles ---------- */
@media print {
    .goldbox {
        box-shadow: none;
        border: 1px solid #ccc;
    }

    .goldbox-actions {
        display: none;
    }

    .goldbox-table tbody tr:hover {
        background: none;
    }
}
