:root {
    --bg-dark: #050505;
    --card-bg: rgba(18, 18, 18, 0.65);
    --card-border: rgba(255, 255, 255, 0.12);
    --gold-primary: #d4af37;
    --gold-bright: #f1d592;
    --gold-dim: rgba(212, 175, 55, 0.15);
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --shadow-soft: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
    --glass-blur: blur(25px);
    
    /* Layout Control Variables */
    --container-width: 1200px;
    --layout-scale: 1;
    --card-padding: 20px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Cairo', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    background-image: radial-gradient(circle at 50% 0%, #1e1e1e 0%, #050505 100%);
    min-height: 100vh;
}

/* Enhanced Glass Effect */
.glass-effect {
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow-soft), inset 0 0 20px rgba(255, 255, 255, 0.02);
    /* Performance: Offload to GPU */
    transform: translateZ(0);
    will-change: transform;
}

.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(5, 5, 5, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.logo-box {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-d, .logo-img {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    object-fit: contain;
}

.logo-d {
    font-weight: 900;
    font-size: 1.6rem;
    color: var(--gold-bright);
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.2) 0%, rgba(212, 175, 55, 0.05) 100%);
    border: 2px solid var(--gold-primary);
    box-shadow: 0 0 15px var(--gold-dim), inset 0 0 8px rgba(212, 175, 55, 0.3);
    font-family: 'Inter', sans-serif;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

.logo-text {
    font-weight: 800;
    font-size: 1.1rem;
    color: #fff;
    letter-spacing: -0.5px;
}

/* Container */
.main-container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 1.5rem 1.5rem;
}

/* Header Section */
.page-header {
    text-align: right;
    margin-bottom: 2rem;
    border-right: 4px solid var(--gold-primary);
    padding-right: 20px;
}
.main-heading {
    font-family: 'Cairo', sans-serif;
    font-size: clamp(1.2rem, 6vw, 2.2rem);
    font-weight: 800;
    color: #fff;
    white-space: nowrap;
}
.header-actions {
    margin-top: 12px;
    display: flex;
    justify-content: flex-start;
}
.indicators-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--gold-bright);
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.2) 0%, rgba(212, 175, 55, 0.08) 100%);
    border: 1px solid rgba(212, 175, 55, 0.35);
    transition: all 0.25s ease;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}
.indicators-btn:hover {
    transform: translateY(-1px);
    border-color: var(--gold-primary);
    color: #fff6d9;
}
.indicators-btn .chart-icon {
    stroke: var(--gold-primary);
}
.market-status-group {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    background: rgba(255,255,255,0.03);
    border-radius: 100px;
    border: 1px solid rgba(255,255,255,0.05);
    font-size: 0.8rem;
}
.status-dot {
    width: 10px;
    height: 10px;
    background: var(--accent-green);
    border-radius: 50%;
    box-shadow: 0 0 12px var(--accent-green);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Dashboard Grid System */
.grid-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.2rem;
    margin-bottom: 3rem;
}

/* Premium Card Design */
.standard-card {
    position: relative;
    border-radius: 24px;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    content-visibility: auto;
    contain-intrinsic-size: 300px;
    /* 120Hz Optimization: Isolate layout and paint */
    contain: layout paint;
}

.standard-card:hover {
    transform: translateY(-8px);
    border-color: rgba(212, 175, 55, 0.4);
    box-shadow: 0 30px 60px rgba(0,0,0,0.5), 0 0 20px var(--gold-dim);
}

/* Subtle Golden Edge Glow for Gold Cards */
#standard-cards-grid .standard-card:not(.currency-card) {
    border-color: rgba(212, 175, 55, 0.25);
    box-shadow: var(--shadow-soft), 0 0 15px rgba(212, 175, 55, 0.08), inset 0 0 10px rgba(212, 175, 55, 0.05);
}

/* Subtle Green Edge Glow for Currency (Dollar) Cards */
.currency-card {
    border-color: rgba(52, 211, 153, 0.2);
    box-shadow: var(--shadow-soft), 0 0 15px rgba(52, 211, 153, 0.06), inset 0 0 10px rgba(52, 211, 153, 0.04);
}

/* Subtle Silver Edge Glow for Silver Cards */
#silver-cards-grid .standard-card {
    border-color: rgba(192, 192, 192, 0.25);
    box-shadow: var(--shadow-soft), 0 0 15px rgba(192, 192, 192, 0.08), inset 0 0 10px rgba(192, 192, 192, 0.05);
}

.card-header-main {
    padding: 24px 20px 12px;
    text-align: center;
}
.card-title {
    font-family: 'Cairo', sans-serif;
    font-size: 1.3rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 15px;
}

/* Price Layout: Side-by-Side */
.price-showcase {
    display: grid;
    grid-template-columns: 1fr 1px 1fr;
    gap: 0;
    padding: 0 24px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    align-items: center;
}
.price-split-divider {
    background: rgba(255, 255, 255, 0.15);
    height: 40px;
}

.price-box {
    text-align: center;
}
.price-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 10px;
    display: block;
}
.price-value-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.price-amount {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: #fff;
}
.price-curr {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gold-bright);
    margin-top: 4px;
}

/* Spread/Gap Info */
.spread-info {
    padding: 12px 15px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 16px;
    background: rgba(0,0,0,0.3);
}
.spread-item {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--gold-bright);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.spread-label { color: var(--text-secondary); font-weight: 500; }

/* Integrated Chart */
.chart-container-full {
    height: 160px;
    width: 100%;
    margin-top: auto;
    position: relative;
    overflow: hidden;
    background: rgba(0,0,0,0.1);
}
.chart-container-full iframe {
    width: 100%;
    height: 100%;
    border: none;
    filter: contrast(1.1) brightness(0.8);
}
.chart-overlay-gradient {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(to bottom, rgba(18,18,18,0.4) 0%, transparent 40%);
    pointer-events: none;
}

/* Sections */
.section-title {
    font-family: 'Cairo', sans-serif;
    font-size: 1.8rem;
    font-weight: 800;
    margin: 3rem 0 2rem;
    text-align: right;
    border-right: 4px solid var(--gold-primary);
    padding-right: 15px;
}

/* Basic Layout */
.layout-wrapper {
    display: flex;
    justify-content: center;
    max-width: 1440px;
    margin: 0 auto;
    position: relative;
}

.main-container {
    flex-grow: 1;
    max-width: var(--container-width);
    padding: 1.5rem;
    /* Faster touch response */
    touch-action: pan-y;
}

.section-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: #fff;
    margin: 3rem 0 1.5rem;
    padding-right: 1.5rem;
    border-right: 4px solid var(--gold-primary);
}

.main-footer {
    padding: 4rem 2rem;
    background: #080808;
    margin-top: 4rem;
    border-top: 1px solid rgba(255,255,255,0.05);
}
.currency-card {
    text-align: center;
}
.currency-card .card-header-main {
    justify-content: center;
    margin-bottom: 1.5rem;
}
.currency-card .price-showcase {
    display: block; /* Change to block for better vertical flow */
    text-align: center;
    margin-bottom: 2rem;
}
.currency-card .price-box {
    display: block;
    width: 100%;
}
.currency-card .price-label {
    display: block;
    width: 100%;
    margin: 0 auto 1.5rem;
    font-size: 1.1rem;
    opacity: 0.9;
    color: var(--text-secondary);
} ليه
.currency-card .price-value-wrap {
    display: inline-flex; /* Use inline-flex to anchor currency */
    align-items: center;
    justify-content: center;
    position: relative;
}
.currency-card .price-amount {
    font-size: 4rem;
    font-weight: 900;
    line-height: 1;
    color: #fff;
    text-shadow: 0 0 30px rgba(212, 175, 55, 0.4);
}
.currency-card .price-curr {
    font-size: 1.2rem;
    color: var(--gold-primary);
    position: absolute;
    right: 100%; /* Move to the opposite side of the price */
    margin-right: 15px;
    white-space: nowrap;
}
.currency-card .spread-info {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 2rem;
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 1rem;
}
.social-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1.5rem;
}
.social-link {
    color: #fff;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    opacity: 0.8;
}
.social-link:hover {
    opacity: 1;
    transform: translateY(-4px);
    color: var(--gold-primary);
}
.social-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}
.social-icon svg {
    width: 28px;
    height: 28px;
    stroke: currentColor;
}
.social-text {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Animations */
@keyframes flashUpdateGold {
    0% { color: var(--gold-bright); text-shadow: 0 0 20px var(--gold-bright); }
    100% { color: inherit; text-shadow: none; }
}
.flash-update {
    animation: flashUpdateGold 1.5s ease-out;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .grid-section {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    .price-amount {
        font-size: 1.35rem;
    }
    .chart-container-full {
        height: 140px;
    }
}

@media (max-width: 480px) {
    .main-container {
        padding: 0.5rem 0.5rem;
    }
    .grid-section {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    /* PERFORMANCE: Kill blur & heavy shadows on mobile for 60fps+ scroll */
    .glass-effect {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: rgba(20, 20, 20, 0.9) !important;
        box-shadow: 0 4px 12px rgba(0,0,0,0.5) !important;
        border-color: rgba(255,255,255,0.08) !important;
    }
    
    .standard-card {
        border-radius: 16px;
    }
    
    .card-header-main {
        padding: 15px 10px 8px;
    }
    .card-title {
        font-size: 1rem;
        margin-bottom: 10px;
    }
    .price-showcase {
        padding: 0 10px 15px;
    }
    .price-box {
        padding: 2px;
    }
    .price-label {
        font-size: 0.7rem;
        margin-bottom: 5px;
    }
    .price-amount {
        font-size: 1.15rem;
    }
    .price-curr {
        font-size: 0.7rem;
    }
    .spread-info {
        flex-direction: column;
        gap: 4px;
        padding: 8px 10px;
    }
    .spread-item {
        font-size: 0.65rem;
    }
    .card-footer-actions {
        padding: 10px 10px 15px;
    }
    .view-chart-btn {
        font-size: 0.75rem;
        padding: 6px 4px;
        white-space: nowrap;
        gap: 4px;
    }
    .view-chart-btn svg {
        width: 14px;
        height: 14px;
    }
}

/* Chart Button on Cards */
.card-footer-actions {
    padding: 15px 20px 20px;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: auto;
}
.view-chart-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 20px;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.15) 0%, rgba(212, 175, 55, 0.05) 100%);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 12px;
    color: var(--gold-bright);
    font-size: 0.95rem;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.3s ease;
    font-family: 'Cairo', sans-serif;
}
.view-chart-btn:hover {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.3) 0%, rgba(212, 175, 55, 0.1) 100%);
    border-color: var(--gold-primary);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(212, 175, 55, 0.2);
}
.view-chart-btn .chart-icon {
    stroke: var(--gold-primary);
}

/* Secondary Chart Page Styles */
.chart-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
    font-family: 'Cairo', sans-serif;
}
.back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}
.chart-page-title {
    font-family: 'Cairo', sans-serif;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--gold-primary);
    margin: 0;
}
.chart-page-container {
    height: 70vh;
    min-height: 500px;
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: #000;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.chart-page-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Show indicators on desktop, buttons on mobile */
.mobile-chart-action {
    display: none;
}

.desktop-chart-container {
    display: block;
}

@media (max-width: 768px) {
    .desktop-chart-container {
        display: none !important;
    }
    .mobile-chart-action {
        display: block !important;
    }
}

/* Silver Section - View Chart Button Overrides */
#silver-cards-grid .view-chart-btn {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.15) 0%, rgba(192, 192, 192, 0.05) 100%);
    border-color: rgba(192, 192, 192, 0.3);
    color: #e2e8f0;
}
#silver-cards-grid .view-chart-btn:hover {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.3) 0%, rgba(192, 192, 192, 0.1) 100%);
    border-color: #c0c0c0;
    box-shadow: 0 5px 15px rgba(192, 192, 192, 0.2);
}
#silver-cards-grid .view-chart-btn .chart-icon {
    stroke: #c0c0c0;
}

/* Dollar Section - View Chart Button Overrides */
#dollar-cards-grid .view-chart-btn {
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.1) 0%, rgba(52, 211, 153, 0.03) 100%);
    border-color: rgba(52, 211, 153, 0.2);
    color: #6ee7b7;
}
#dollar-cards-grid .view-chart-btn:hover {
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.2) 0%, rgba(52, 211, 153, 0.08) 100%);
    border-color: #34d399;
    box-shadow: 0 5px 15px rgba(52, 211, 153, 0.15);
}
#dollar-cards-grid .view-chart-btn .chart-icon {
    stroke: #34d399;
}
