/* 
   Gold Price Tracker v2 - Premium Design System 
   Theme: "Midnight Gold"
*/

:root {
    /* Color Palette - Deep Luxury */
    --bg-deep: #0f172a;
    /* Slate 900 */
    --bg-card: #1e293b;
    /* Slate 800 */
    --bg-surface: #334155;
    /* Slate 700 */

    --gold-primary: #D4AF37;
    /* Classic Gold */
    --gold-light: #FCD34D;
    /* Bright Gold */
    --gold-dark: #B4941F;
    /* Deep Gold */

    --text-main: #f8fafc;
    /* Slate 50 */
    --text-muted: #94a3b8;
    /* Slate 400 */

    --accent-red: #ef4444;
    /* Trend Down */
    --accent-green: #10b981;
    /* Trend Up */

    /* Effects */
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --gold-glow: 0 0 20px rgba(212, 175, 55, 0.15);

    /* Typography */
    --font-head: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-deep);
    color: var(--text-main);
    font-family: var(--font-body);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

/* --- Layout --- */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

/* --- Header --- */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
    position: relative;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-icon {
    filter: drop-shadow(0 0 5px rgba(212, 175, 55, 0.5));
}

.app-title h1 {
    font-family: var(--font-head);
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--gold-light), var(--gold-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.app-title p {
    font-size: 0.85rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* --- Navigation --- */
.main-nav {
    display: flex;
    gap: 20px;
}

.main-nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.main-nav a:hover,
.main-nav a.active {
    color: var(--gold-primary);
    background: rgba(212, 175, 55, 0.1);
}

/* --- Controls (Currency/Unit) --- */
.controls-area {
    display: flex;
    gap: 15px;
}

.toggle-btn {
    background: var(--bg-surface);
    border: var(--glass-border);
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--font-head);
    font-weight: 600;
}

.toggle-btn.active {
    background: linear-gradient(135deg, var(--gold-dark), var(--gold-primary));
    color: #000;
    border-color: var(--gold-primary);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
}

/* --- Hero / Status --- */
.status-bar {
    text-align: center;
    margin-bottom: 20px;
}

.last-updated {
    font-size: 0.9rem;
    color: var(--gold-primary);
    font-weight: 500;
    background: rgba(212, 175, 55, 0.1);
    padding: 5px 15px;
    border-radius: 20px;
    display: inline-block;
    border: 1px solid rgba(212, 175, 55, 0.2);
}

/* --- Price Grid --- */
.price-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 25px;
}

.price-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 25px;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.price-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, transparent, var(--gold-primary), transparent);
    opacity: 0.5;
}

.price-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--gold-glow);
    border-color: rgba(212, 175, 55, 0.3);
}

.card-title {
    font-family: var(--font-head);
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: block;
}

.card-price {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
    display: block;
    margin-bottom: 5px;
    font-variant-numeric: tabular-nums;
}

.card-unit {
    font-size: 0.8rem;
    color: var(--gold-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- Chart Section --- */
.chart-container {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 20px;
    height: 400px;
    position: relative;
}

/* --- History Table --- */
.history-section {
    background: var(--bg-card);
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.section-header {
    background: rgba(0, 0, 0, 0.2);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.section-title {
    font-family: var(--font-head);
    color: var(--gold-light);
    font-size: 1.2rem;
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-muted);
    font-weight: 600;
    text-align: left;
    padding: 15px h20px;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

td {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-deep);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-surface);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gold-primary);
}

/* Responsive */
@media (max-width: 768px) {
    .main-header {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }

    .controls-area {
        width: 100%;
        justify-content: center;
    }

    .price-grid {
        grid-template-columns: 1fr;
        /* Full width cards on mobile */
    }
}

/* --- Filters --- */
.filter-group {
    display: flex;
    gap: 10px;
}

.filter-group select {
    padding: 8px 12px;
    font-size: 0.9rem;
    background: rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    cursor: pointer;
}

.filter-group select:hover {
    border-color: var(--gold-primary);
    color: var(--text-main);
}

/* --- Footer --- */
.main-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding: 40px 20px;
    margin-top: 40px;
    text-align: center;
}

.footer-nav {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.footer-nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.3s;
}

.footer-nav a:hover {
    color: var(--gold-primary);
}

.footer-nav span {
    color: rgba(255, 255, 255, 0.1);
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 25px;
}

.social-links a {
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.social-links a:hover {
    color: var(--gold-primary);
    border-color: var(--gold-primary);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.copyright {
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.85rem;
}

/* --- Calculators (v2 Investment) --- */
.calculator-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 20px;
}

.calc-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 30px;
    position: relative;
    overflow: hidden;
}

.calc-card h3 {
    color: var(--gold-light);
    font-size: 1.4rem;
    font-family: var(--font-head);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 8px;
    font-weight: 500;
}

.input-row {
    display: flex;
    gap: 10px;
}

input[type="number"],
select {
    width: 100%;
    background: var(--bg-deep);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    padding: 12px 15px;
    border-radius: 10px;
    font-family: var(--font-body);
    font-size: 1rem;
    transition: all 0.3s ease;
}

input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--gold-primary);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.2);
}

.btn-action {
    width: 100%;
    background: linear-gradient(135deg, var(--gold-dark), var(--gold-primary));
    color: #000;
    font-weight: 700;
    padding: 14px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    font-family: var(--font-head);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(212, 175, 55, 0.3);
}

.result-box {
    margin-top: 20px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    border: 1px dashed rgba(255, 255, 255, 0.1);
    display: none;
    /* Hidden by default */
    animation: fadeIn 0.4s ease forwards;
}

.result-box.show {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.profit-positive {
    color: var(--accent-green);
    font-weight: 700;
}

.profit-negative {
    color: var(--accent-red);
    font-weight: 700;
}