/* Common styles for both modes */
html, body {
    margin: 0;
    padding: 0;
    /*min-height: 100vh;*/
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    -webkit-overflow-scrolling: touch;
}

body {
    background-image: url('bg-light.png');
    background-repeat: repeat;
    background-position: center;
    color: #333333;
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
}

.price-container {
    max-width: 100%;
    margin: 10px auto;
    padding: 0 8px;
    box-sizing: border-box;
}

.price-header {
    color: #4F4F4F;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 20px;
    text-align: center;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.column-headers {
    display: flex;
    padding: 0 8px;
}

.header-gold {
    width: 160px;
    min-width: 160px;
    padding-left: 28px;
    color: #6D6D6D;
    font-family: 'Poppins', sans-serif;
    font-weight: 300;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.header-prices {
    display: flex;
    gap: 40px;
    margin-left: auto;
}

.header-buy, .header-sell {
    width: 80px;
    text-align: left;
    color: #6D6D6D;
    font-family: 'Poppins', sans-serif;
    font-weight: 300;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.price-row {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    margin-bottom: 4px;
    border-radius: 10px;
    background-color: #f1efed;
    box-shadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    width: 100%;
    transform: translateZ(0);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.gold-type {
    width: 160px;
    min-width: 160px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.gold-type::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    background-image: url('icon.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.gold-text {
    display: flex;
    flex-direction: column;
    gap: 0px;
}

.gold-name {
    color: #4F4F4F;
    font-weight: 600;
    font-size: 18px;
    line-height: 1.2;
}

.gold-description {
    color: #6D6D6D;
    font-weight: 300;
    font-size: 14px;
    line-height: 1.2;
}

.price-values {
    display: flex;
    gap: 40px;
    padding-right: 8px;
    margin-left: auto;
}

.buy-price, .sell-price {
    width: 80px;
    text-align: left;
    color: #4F4F4F;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 18px;
}

.last-update {
    font-family: 'Poppins', sans-serif;
    color: #6D6D6D;
    font-weight: 400;
    font-size: 14px;
    text-align: center;
    margin-top: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Dark mode */
body.dark-mode {
    background-image: url('bg-dark.png');
    background-repeat: repeat;
    background-position: center;
    background-color: #1a1a1a;
}

.dark-mode .price-header {
    color: #F1EFED;
}

.dark-mode .price-row {
    background-color: #3A443D;
}

.dark-mode .price-row:nth-child(even) {
    background-color: #36403a;
}

.dark-mode .header-gold,
.dark-mode .header-buy,
.dark-mode .header-sell {
    color: #D4D4D4;
}

.dark-mode .gold-name,
.dark-mode .buy-price,
.dark-mode .sell-price {
    color: #F1EFED;
}

.dark-mode .gold-description {
    color: #FFB43E;
}

.dark-mode .last-update {
    color: #D4D4D4;
}

/* Update text elements with better rendering */
.price-header,
.gold-name,
.gold-description,
.buy-price,
.sell-price,
.header-gold,
.header-buy,
.header-sell,
.last-update {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Price change animations for light mode */
@keyframes priceIncrease {
    0% { color: #4F4F4F; }
    50% { color: #28a745; }
    100% { color: #4F4F4F; }
}

@keyframes priceDecrease {
    0% { color: #4F4F4F; }
    50% { color: #dc3545; }
    100% { color: #4F4F4F; }
}

/* Price change animations for dark mode */
@keyframes priceIncreaseDark {
    0% { color: #F1EFED; }
    50% { color: #28a745; }
    100% { color: #F1EFED; }
}

@keyframes priceDecreaseDark {
    0% { color: #F1EFED; }
    50% { color: #dc3545; }
    100% { color: #F1EFED; }
}

/* Light mode price changes */
.price-up {
    animation: priceIncrease 1s ease;
}

.price-down {
    animation: priceDecrease 1s ease;
}

/* Dark mode price changes */
.dark-mode .price-up {
    animation: priceIncreaseDark 1s ease;
}

.dark-mode .price-down {
    animation: priceDecreaseDark 1s ease;
}

/* Media query for larger screens */
@media screen and (min-width: 768px) {
    .price-container {
        max-width: 600px;
        padding: 0 20px;
    }
}

/* Even larger screens */
@media screen and (min-width: 1200px) {
    .price-container {
        max-width: 800px;
    }
}

/* Loading States */
.price-row.loading {
    position: relative;
    overflow: hidden;
    animation: slideIn 0.3s ease forwards;
    opacity: 0;
    transform: translateX(-20px);
}

/* Faster sequential loading delays */
.price-row.loading:nth-child(3) { animation-delay: 0s; }    /* First row */
.price-row.loading:nth-child(4) { animation-delay: 0.05s; }
.price-row.loading:nth-child(5) { animation-delay: 0.1s; }
.price-row.loading:nth-child(6) { animation-delay: 0.15s; }
.price-row.loading:nth-child(7) { animation-delay: 0.2s; }
.price-row.loading:nth-child(8) { animation-delay: 0.25s; }
.price-row.loading:nth-child(9) { animation-delay: 0.3s; }
.price-row.loading:nth-child(10) { animation-delay: 0.35s; }
.price-row.loading:nth-child(11) { animation-delay: 0.4s; }
.price-row.loading:nth-child(12) { animation-delay: 0.45s; }

/* Shimmer effect */
.price-row.loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(241, 239, 237, 0.2) 15%,
        rgba(241, 239, 237, 0.2) 85%,
        transparent 100%
    );
    animation: shine 1.5s infinite;
    opacity: 0.7;
}

/* Dark mode shimmer */
.dark-mode .price-row.loading::before {
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(58, 68, 61, 0.3) 15%,
        rgba(58, 68, 61, 0.3) 85%,
        transparent 100%
    );
}

/* Loading content styles */
.price-row.loading .gold-name,
.price-row.loading .gold-description,
.price-row.loading .buy-price,
.price-row.loading .sell-price {
    position: relative;
    color: transparent;
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: loadingText 2s infinite;
    border-radius: 4px;
}

.dark-mode .price-row.loading .gold-name,
.dark-mode .price-row.loading .gold-description,
.dark-mode .price-row.loading .buy-price,
.dark-mode .price-row.loading .sell-price {
    background: linear-gradient(
        90deg,
        #3A443D 25%,
        #36403a 50%,
        #3A443D 75%
    );
    background-size: 200% 100%;
}

/* Animation Keyframes */
@keyframes slideIn {
    0% {
        opacity: 0;
        transform: translateX(-20px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

@keyframes loadingText {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Last Update Loading State */
.last-update.loading {
    opacity: 0;
    transform: translateY(20px);
    animation: slideUpFade 0.3s ease forwards;
    animation-delay: 0.5s; /* Synced with last row */
}

@keyframes slideUpFade {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}