:root {
    --primary: #d4af37;
    --primary-light: #f9e27d;
    --primary-dark: #aa8a2e;
    --silver: #c0c0c0;
    --silver-light: #e0e0e0;
    --bg-dark: #050505;
    --card-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-main: #ffffff;
    --text-dim: #94a3b8;
    --accent-gold: #fbbf24;
    --shadow-gold: rgba(212, 175, 55, 0.2);
    --trend-up: #4ade80;
    --trend-down: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: radial-gradient(circle at 50% 0%, #1a1a1a 0%, #050505 100%);
    overflow-x: hidden;
}

.container {
    max-width: 900px;
    width: 95%;
    margin: 40px auto;
    position: relative;
    /* Context for absolute positioning */
}

/* Hero Section */
.hero-image-container {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: -40px;
    margin-top: 60px;
    /* Push down to avoid overlap with absolute header controls */
    perspective: 1000px;
}

.hero-image {
    width: 380px;
    height: auto;
    filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.8));
    transform: rotateX(5deg);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 2;
}

.hero-image:hover {
    transform: rotateX(0deg) scale(1.05);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    position: relative;
    z-index: 1;
    padding: 15px 0;
    flex-wrap: wrap;
    /* Allow wrapping for mobile */
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 2;
    /* Ensure above clock if overlap */
}

.app-logo {
    width: 140px !important;
    height: 140px !important;
    min-width: 140px;
    object-fit: contain;
}

header h1 {
    font-size: 2.2rem;
    margin: 0;
    /* Reset gradient for small header logo text */
    background: none;
    -webkit-text-fill-color: var(--text-main);
    color: var(--text-main);
    letter-spacing: 0;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 2;
}

/* Language Switcher Buttons */
.lang-switch {
    display: flex;
    gap: 8px;
    background: var(--card-bg);
    /* Optional container background */
    padding: 4px;
    border-radius: 14px;
    /* Container rounded */
    border: 1px solid var(--glass-border);
}

.lang-switch button {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 8px 16px;
    /* Medium size padding */
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    transition: all 0.2s ease;
    min-width: 44px;
    /* Minimum touch target */
}

.lang-switch button:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.lang-switch button.active {
    background: var(--primary);
    color: #000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Clock Styles */
.live-clock {
    font-size: 0.85rem;
    color: var(--text-dim);
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    /* Desktop: Absolute Center */
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    text-align: center;
    border-bottom: 1px solid transparent;
}

/* Mobile Responsive Header */
@media (max-width: 700px) {
    header {
        margin-bottom: 30px;
        padding-bottom: 0;
    }

    .live-clock {
        position: relative;
        left: auto;
        transform: none;
        width: 100%;
        order: 3;
        margin-top: 15px;
        padding-top: 10px;
        border-top: 1px solid var(--glass-border);
        font-size: 0.75rem;
        color: var(--primary);
        /* Highlight a bit on mobile */
    }
}

.header-main h1 {
    font-size: 3.5rem;
    font-weight: 900;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #fff 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1.5px;
}

.subtitle {
    color: var(--text-dim);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 5px;
}

.subtitle i {
    color: #4ade80;
    margin-right: 8px;
    font-size: 0.8rem;
}

/* Tabs */
.metal-tabs {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
}

.tab-btn {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-dim);
    padding: 5px 20px;
    border-radius: 100px;
    font-weight: 700;
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(10px);
}

.tab-btn i {
    font-size: 1.2rem;
}

.tab-btn.active {
    color: #000;
    border-color: var(--primary);
}

.tab-btn[data-tab="gold"].active {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    box-shadow: 0 10px 20px var(--shadow-gold);
}

.tab-btn[data-tab="silver"].active {
    background: linear-gradient(135deg, var(--silver-light), var(--silver));
    box-shadow: 0 10px 20px rgba(192, 192, 192, 0.2);
}

.tab-content {
    display: none;
    animation: fadeIn 0.5s ease-out;
}

.tab-content.active {
    display: block;
}

/* Main Price Card */
.main-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
    backdrop-filter: blur(30px);
    border: 1px solid var(--glass-border);
    border-radius: 40px;
    padding: 50px;
    text-align: center;
    box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.7);
    margin-bottom: 40px;
    position: relative;
    overflow: hidden;
}

.main-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(212, 175, 55, 0.05) 0%, transparent 70%);
    pointer-events: none;
}

.price-label {
    font-size: 1.1rem;
    color: var(--text-dim);
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.current-price {
    font-size: 5rem;
    font-weight: 900;
    margin: 10px 0;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 15px;
}

.current-price .currency {
    font-size: 1.8rem;
    color: var(--primary);
    font-weight: 500;
}

.usd-price {
    font-size: 1.8rem;
    color: var(--text-dim);
    font-weight: 500;
    opacity: 0.8;
}

/* Grid */
.purity-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 40px;
}

.purity-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 25px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.purity-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary);
    transform: translateY(-8px);
}

.purity-name {
    color: var(--primary);
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.purity-price {
    font-size: 2rem;
    font-weight: 800;
}

.unit {
    font-size: 0.8rem;
    color: var(--text-dim);
    font-weight: 400;
    text-transform: none;
}

/* Calculator Section */
.calculator-section {
    margin-top: 60px;
    width: 100%;
}

.section-header {
    text-align: center;
    margin-bottom: 30px;
}

.section-header h2 {
    font-size: 2rem;
    margin-bottom: 5px;
}

.section-header p {
    color: var(--text-dim);
}

.calc-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    padding: 30px;
    display: flex;
    gap: 40px;
    align-items: center;
}

.calc-inputs {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.input-group select,
.input-group input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    color: #fff;
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 1.1rem;
    outline: none;
    transition: all 0.3s;
}

.input-group select:focus,
.input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.1);
}

.calc-result {
    flex: 1;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.1) 0%, transparent 100%);
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    border: 1px solid rgba(212, 175, 55, 0.2);
}

.result-label {
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.result-value {
    font-size: 3rem;
    font-weight: 900;
    color: var(--primary);
}

.result-usd {
    font-size: 1.2rem;
    color: var(--text-dim);
    margin-top: 5px;
}

.fee-breakdown {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.fee-label {
    color: var(--text-dim);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.fee-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--silver-light);
}

.unit-small {
    font-size: 0.8rem;
    color: var(--text-dim);
    font-weight: 400;
}

.result-divider {
    height: 1px;
    background: rgba(212, 175, 55, 0.3);
    margin: 15px 0;
    display: none;
    /* Controlled by JS */
}

/* Footer Stats */
.status-footer {
    margin-top: 50px;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-dim);
    font-size: 0.9rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 15px #4ade80;
}

.btn-refresh {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 8px 18px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-refresh:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.syncing .dot {
    background: var(--primary);
    box-shadow: 0 0 20px var(--primary);
    animation: pulse 1.5s infinite;
}

.syncing .fa-sync-alt {
    animation: spin 1s linear infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Main Header Text Area */
.header-main {
    text-align: center;
    margin-top: 20px;
    margin-bottom: 20px;
}

/* Exchange Rates Section */
.exchange-rates-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 10px 25px;
    margin: 15px auto 35px auto;
    /* Centered with auto margins */
    gap: 25px;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    width: fit-content;
    /* Ensure it doesn't stretch */
}

.rate-card {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rate-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.rate-card.official .rate-icon {
    background: rgba(74, 222, 128, 0.1);
    color: #4ade80;
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.1);
}

.rate-card.sagha .rate-icon {
    background: rgba(212, 175, 55, 0.1);
    color: var(--primary);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.1);
}

.rate-info {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.rate-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 2px;
}

.rate-value {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-main);
}

.rate-currency {
    font-size: 0.7rem;
    color: var(--text-dim);
    vertical-align: middle;
}

.rate-divider {
    width: 1px;
    height: 30px;
    background: var(--glass-border);
}

/* Responsive adjustments for exchange rates */
@media (max-width: 600px) {
    .exchange-rates-container {
        flex-direction: column;
        gap: 15px;
        width: 100%;
        padding: 15px;
    }

    .rate-divider {
        width: 100%;
        height: 1px;
    }

    .rate-card {
        width: 100%;
        justify-content: center;
    }
}

/* Responsive */
@media (max-width: 768px) {
    h1 {
        font-size: 2.5rem;
    }

    .current-price {
        font-size: 3.5rem;
    }

    .purity-grid {
        grid-template-columns: 1fr;
    }

    .calc-card {
        flex-direction: column;
    }

    .status-footer {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
}

/* 3D Bar Animation */
.bar-scene {
    width: 40px;
    height: 24px;
    perspective: 400px;
    margin-right: 12px;
    display: inline-block;
    vertical-align: middle;
}

.bar-3d {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    animation: rotateBar 6s infinite linear;
}

.bar-face {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 6px;
    font-weight: bold;
    backface-visibility: hidden;
    background-size: 200% 200%;
}

/* Shapes & Positions */
/* Width: 40, Height: 16, Depth: 12 */
.bar-face.front {
    width: 40px;
    height: 16px;
    transform: rotateY(0deg) translateZ(6px);
}

.bar-face.back {
    width: 40px;
    height: 16px;
    transform: rotateY(180deg) translateZ(6px);
}

.bar-face.right {
    width: 12px;
    height: 16px;
    transform: rotateY(90deg) translateZ(20px);
}

.bar-face.left {
    width: 12px;
    height: 16px;
    transform: rotateY(-90deg) translateZ(20px);
}

.bar-face.top {
    width: 40px;
    height: 12px;
    transform: rotateX(90deg) translateZ(6px);
}

.bar-face.bottom {
    width: 40px;
    height: 12px;
    transform: rotateX(-90deg) translateZ(10px);
}

/* Colors - Gold */
.gold-bar .bar-face {
    background: linear-gradient(135deg, #bf953f, #fcf6ba, #b38728, #fbf5b7, #aa771c);
    border: 1px solid #7c5c1d;
    box-shadow: inset 0 0 5px rgba(255, 255, 255, 0.5);
}

/* Colors - Silver */
.silver-bar .bar-face {
    background: linear-gradient(135deg, #e0e0e0, #ffffff, #a8a8a8, #d4d4d4);
    border: 1px solid #7a7a7a;
    box-shadow: inset 0 0 5px rgba(255, 255, 255, 0.5);
}

/* Glow Effect */
.gold-bar {
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.6));
}

.silver-bar {
    filter: drop-shadow(0 0 8px rgba(192, 192, 192, 0.6));
}

@keyframes rotateBar {
    0% {
        transform: rotateX(-20deg) rotateY(0deg);
    }

    100% {
        transform: rotateX(-20deg) rotateY(360deg);
    }
}

/* Adjust Tab Button */
.tab-btn {
    padding-left: 20px;
    padding-right: 20px;
    overflow: visible;
}

/* Language Switcher */
/* Language Switcher & Clock Row */
.header-top-row {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    /* Side padding */
    z-index: 20;
}

.lang-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: var(--text-dim);
    padding: 6px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    backdrop-filter: blur(5px);
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border-color: var(--primary);
}

.lang-text {
    font-family: 'Cairo', sans-serif;
}

/* RTL Support - Arabic */
html[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] body {
    font-family: 'Cairo', sans-serif;
}

html[dir="rtl"] .rate-info {
    text-align: right;
}

html[dir="rtl"] .main-card,
html[dir="rtl"] .calc-card,
html[dir="rtl"] .purity-card {
    text-align: right;
}

html[dir="rtl"] .status-footer {
    flex-direction: row-reverse;
}

html[dir="rtl"] .rate-card {
    flex-direction: row;
}

html[dir="rtl"] .subtitle i {
    margin-right: 0;
    margin-left: 8px;
}

html[dir="rtl"] .tab-btn {
    padding-left: 30px;
    padding-right: 20px;
}

html[dir="rtl"] .bar-scene {
    margin-right: 0;
    margin-left: 12px;
}

/* Fix Flex directions */
html[dir="rtl"] .current-price {
    flex-direction: row;
    /* Keep number logic same? LTR numbers usually preferred even in Arabic for finance, but alignment right */
}

/* 3D Bar Animation Adjustment for RTL? 
   The bar rotates. If margin is flipped, it should look fine.
*/
/* Gram Difference Colors */
.diff-red {
    color: #ef4444 !important;
    text-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
}

.diff-green {
    color: #4ade80 !important;
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.3);
}

.rate-card.diff .rate-icon {
    background: rgba(255, 255, 255, 0.05);
    /* Neutral background */
    color: var(--text-dim);
}

.model-container {
    width: 100px;
    height: 60px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 5px;
}

html[dir="rtl"] .model-container {
    margin-right: 0;
    margin-left: 5px;
}

html[dir="rtl"] .usd-price {
    text-align: center;
}

/* Header Updates */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(212, 175, 55, 0.1);
    position: relative;
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-logo {
    height: 40px;
    width: auto;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--gold-primary);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    font-family: 'Playfair Display', serif;
    /* Or similar serif */
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.3s ease;
    padding: 5px;
}

.icon-btn:hover {
    color: var(--gold-primary);
}

/* Footer Styles */
footer {
    text-align: center;
    padding: 2rem 1rem;
    margin-top: 3rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.3);
}

.copyright {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.developer {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.developer a {
    color: var(--gold-primary);
    text-decoration: none;
    transition: color 0.3s;
}

.developer a:hover {
    color: var(--gold-light);
    text-decoration: underline;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s;
}

.modal-content {
    background: linear-gradient(145deg, #1a1a1a, #0d0d0d);
    margin: 5% auto;
    padding: 0;
    border: 1px solid var(--gold-dark);
    width: 90%;
    max-width: 400px;
    /* Mobile width */
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), 0 0 20px rgba(212, 175, 55, 0.2);
    text-align: center;
    position: relative;
    color: var(--text-primary);
    animation: slideUp 0.4s ease-out;
}

.close-modal {
    color: var(--text-muted);
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 15px;
    right: 20px;
    cursor: pointer;
    line-height: 1;
    z-index: 10;
}

.close-modal:hover,
.close-modal:focus {
    color: var(--gold-primary);
    text-decoration: none;
    cursor: pointer;
}

.about-header {
    background: linear-gradient(180deg, rgba(212, 175, 55, 0.1) 0%, rgba(0, 0, 0, 0) 100%);
    padding: 40px 20px 20px;
    border-radius: 20px 20px 0 0;
}

.about-logo {
    width: 100px;
    height: auto;
    margin-bottom: 15px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}

.about-header h2 {
    color: var(--gold-primary);
    margin: 0;
    font-size: 1.8rem;
    font-family: 'Playfair Display', serif;
}

.about-header .version {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 5px;
}

.about-body {
    padding: 20px 30px 40px;
}

.developer-info {
    margin: 25px 0;
}

.developer-info p {
    color: var(--text-muted);
    margin: 0 0 5px;
    font-size: 0.9rem;
}

.developer-info h3 {
    color: #fff;
    margin: 0 0 5px;
    font-size: 1.4rem;
    font-weight: 600;
}

.developer-info a {
    color: var(--gold-primary);
    font-size: 0.9rem;
    text-decoration: none;
    opacity: 0.8;
}

.contact-btn {
    display: inline-block;
    background: linear-gradient(90deg, var(--gold-dark), var(--gold-primary));
    color: #ffffff;
    padding: 12px 30px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: bold;
    margin: 20px 0;
    transition: transform 0.2s, box-shadow 0.2s;
}

.contact-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(212, 175, 55, 0.4);
}

.legal-links {
    margin-top: 10px;
    margin-bottom: 20px;
    font-size: 0.85rem;
}

.legal-links a {
    color: var(--text-muted);
    text-decoration: none;
    margin: 0 5px;
    transition: color 0.3s;
}

.legal-links a:hover {
    color: var(--gold-light);
}

.modal-copyright {
    font-size: 0.8rem;
    color: #444;
    margin-top: 10px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Mobile responsive fixes */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.8rem;
    }
}

/* Trend Indicators */
.trend-icon {
    font-size: 0.8em;
    margin-left: 8px;
    vertical-align: middle;
}

[dir="rtl"] .trend-icon {
    margin-left: 0;
    margin-right: 8px;
}

.trend-up {
    color: var(--trend-up);
}

.trend-down {
    color: var(--trend-down);
}

/* Visitor Counter Badge */
.visitor-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 15px;
    border: 1px solid var(--glass-border);
}

.visitor-badge i {
    color: var(--gold-primary);
}

/* Install Buttons */
.install-section {
    margin-bottom: 25px;
}

.install-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.store-btn {
    display: flex;
    align-items: center;
    background: #000;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 8px 20px;
    color: #fff;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    min-width: 160px;
}

.store-btn:hover {
    transform: translateY(-2px);
    background: #1a1a1a;
    border-color: var(--gold-primary);
}

.store-btn i {
    font-size: 2rem;
    margin-right: 12px;
}

.store-btn .btn-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
}

.store-btn .small-text {
    font-size: 0.7rem;
    opacity: 0.8;
}

.store-btn .big-text {
    font-size: 1.1rem;
    font-weight: bold;
}

/* iOS Guide Modal */
.modal-content.ios-guide {
    max-width: 350px;
    text-align: left;
    padding: 30px;
}

.ios-content h3 {
    text-align: center;
    color: var(--text-main);
}

.ios-content .step {
    margin-bottom: 15px;
    font-size: 0.95rem;
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.05);
    padding: 10px;
    border-radius: 8px;
}

.ios-content .step strong {
    color: var(--text-main);
}

.ios-content .step i {
    margin: 0 5px;
    font-size: 1.1rem;
}

/* Digital Clock Styles */
.live-clock {
    border: none !important;
    padding: 0 !important;
    font-family: 'Orbitron', monospace;
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, rgba(20, 20, 20, 0.9), rgba(0, 0, 0, 0.9));
    border-radius: 16px;
    padding: 12px 20px !important;
    border: 1px solid rgba(212, 175, 55, 0.4) !important;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.2), inset 0 0 10px rgba(212, 175, 55, 0.1);
    white-space: nowrap;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    overflow: hidden;
    animation: goldGlow 3s infinite alternate;
}

@keyframes goldGlow {
    0% {
        box-shadow: 0 0 15px rgba(212, 175, 55, 0.3), inset 0 0 5px rgba(212, 175, 55, 0.1);
        border-color: rgba(212, 175, 55, 0.4);
    }

    100% {
        box-shadow: 0 0 30px rgba(212, 175, 55, 0.6), inset 0 0 15px rgba(212, 175, 55, 0.2);
        border-color: rgba(212, 175, 55, 0.8);
    }
}

.live-clock::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.1) 0%, transparent 60%);
    pointer-events: none;
    animation: rotateSheen 10s linear infinite;
}

@keyframes rotateSheen {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.d-clock-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.d-clock-time-group {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.d-clock-ampm {
    font-size: 0.9rem;
    color: var(--gold-primary);
    font-weight: 700;
}

.d-clock-time {
    font-size: 2.2rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    line-height: 1;
}

.d-clock-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    padding-left: 12px;
    line-height: 1.1;
}

.d-clock-seconds {
    font-size: 1.2rem;
    color: var(--text-dim);
    font-weight: 600;
}

.d-clock-date {
    font-size: 0.75rem;
    color: var(--gold-primary);
    letter-spacing: 1px;
    margin-top: 2px;
}

.d-clock-day {
    font-size: 0.7rem;
    color: var(--text-main);
    opacity: 0.8;
}

/* Mobile Adjustments for Clock */
@media (max-width: 700px) {
    .live-clock {
        position: relative;
        left: auto;
        transform: none;
        margin: 20px auto 0 auto;
        width: fit-content !important;
        display: inline-flex !important;
        background: rgba(0, 0, 0, 0.6);
        order: 3;
    }

    header {
        flex-wrap: wrap;
    }

    /* Fix Performance Indicator on Mobile */
    .current-price {
        flex-wrap: wrap;
        /* Allow wrapping */
        justify-content: center;
        gap: 10px;
        /* Space between wrapped elements */
    }

    .daily-change {
        margin-left: 0;
        margin-top: 5px;
        font-size: 1rem;
        /* Slightly smaller on mobile */
        width: 100%;
        /* Take full width to force new line if needed, or stick to auto */
        display: inline-flex;
        justify-content: center;
    }

    .d-clock-time {
        font-size: 1.8rem;
    }

    .d-clock-seconds {
        font-size: 1rem;
    }
}

/* --- New Features Styling --- */

/* 1. Daily Performance Indicator */
.daily-change {
    font-size: 1.2rem;
    font-weight: 700;
    margin-left: 15px;
    padding: 5px 12px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    vertical-align: middle;
}

.daily-change.positive {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, 0.3);
}

.daily-change.negative {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* 2. Floating WhatsApp Button */
.whatsapp-float {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background-color: #25d366;
    color: #fff;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    text-align: center;
    font-size: 30px;
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4);
    z-index: 1000;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border: none;
}

.whatsapp-float:hover {
    transform: scale(1.1) rotate(10deg);
    background-color: #20bd5a;
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.6);
}

/* 3. Skeleton Loading State */
.skeleton {
    color: transparent !important;
    background: #2a2a2a;
    background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 6px;
    display: inline-block;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Apply skeleton to specific elements when loading */
.loading .purity-price,
.loading .current-price,
.loading .rate-value,
.loading .result-value,
.loading .fee-value {
    color: transparent !important;
    background: #2a2a2a;
    background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
    min-width: 80px;
    /* Force width */
}

/* --- News Ticker --- */
.ticker-container {
    width: 100%;
    background: #000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    height: 44px;
    display: flex;
    align-items: center;
    position: relative;
    z-index: 100;
}

.ticker-track {
    display: flex;
    align-items: center;
    gap: 40px;
    white-space: nowrap;
    animation: tickerScroll 40s linear infinite;
    padding-left: 20px;
}

.ticker-item {
    font-size: 0.9rem;
    color: var(--text-dim);
    font-weight: 500;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
}

.ticker-value {
    color: #fff;
    margin-left: 8px;
    font-weight: 700;
}

.ticker-change {
    font-size: 0.75rem;
    margin-left: 6px;
    font-weight: 600;
}

.ticker-change.up {
    color: var(--trend-up);
}

.ticker-change.down {
    color: var(--trend-down);
}

@keyframes tickerScroll {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-50%);
    }

    /* We will duplicate content in JS */
}

/* RTL Support for Ticker */
html[dir="rtl"] .ticker-track {
    animation-direction: reverse;
    /* For RTL, we might want it to flow Left to Right, but standard ticker is usually R-L. 
       If we want it to flow "naturally" for reading Arabic, it should probably still move R-L or L-R? 
       Actually, stock tickers usually continuously scroll one way. Let's keep it consistent. */
}

html[dir="rtl"] .ticker-value {
    margin-left: 0;
    margin-right: 8px;
}

html[dir="rtl"] .ticker-change {
    margin-left: 0;
    margin-right: 6px;
}

.ticker-container:hover .ticker-track {
    animation-play-state: paused;
}

:root {
    --primary: #d4af37;
    --primary-light: #f9e27d;
    --primary-dark: #aa8a2e;
    --silver: #c0c0c0;
    --silver-light: #e0e0e0;
    --bg-dark: #050505;
    --card-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-main: #ffffff;
    --text-dim: #94a3b8;
    --accent-gold: #fbbf24;
    --shadow-gold: rgba(212, 175, 55, 0.2);
    --trend-up: #4ade80;
    --trend-down: #ef4444;
}

/* Light Theme Variables */
[data-theme="light"] {
    --bg-dark: #f3f4f6;
    --card-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(0, 0, 0, 0.1);
    --text-main: #111827;
    --text-dim: #4b5563;
    --primary: #b08d26;
    /* Darker gold for contrast */
}

/* Light Theme Body Override */
[data-theme="light"] body {
    background: radial-gradient(circle at 50% 0%, #ffffff 0%, #f3f4f6 100%);
}

/* Keep Ticker Dark in Light Mode for contrast */
[data-theme="light"] .ticker-container {
    background: #111827;
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .ticker-item {
    color: #9ca3af;
}

[data-theme="light"] .ticker-value {
    color: #fff;
}

/* Light Mode Input/Select overrides */
[data-theme="light"] .input-group select,
[data-theme="light"] .input-group input {
    background: rgba(255, 255, 255, 0.9);
    color: #111827;
    border-color: rgba(0, 0, 0, 0.15);
}

/* Light Mode specific shadows */
[data-theme="light"] .main-card,
[data-theme="light"] .calc-card {
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.7) 100%);
}

/* Theme Toggle Button Style */
.theme-toggle {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

[data-theme="light"] .theme-toggle {
    color: #1a1a1a;
    background: rgba(0, 0, 0, 0.05);
    /* Slight background for better visibility */
}

.theme-toggle:hover {
    color: var(--primary);
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .theme-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
}