/**
 * Crypto Prices Display Styles for DexCash DAO Platform
 */

#crypto-prices-container {
    margin: 20px 0;
    padding: 20px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Currency selector */
#crypto-prices-container .fiat-selector {
    position: absolute;
    top: 24px; /* nudged down a bit from the top */
    right: 12px;
    z-index: 10;
}

.fiat-button {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.18);
    color: #e0e0e0;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.85rem;
    cursor: pointer;
}

.fiat-button:hover {
    background: rgba(255,255,255,0.15);
}

.fiat-menu {
    display: none;
    position: absolute;
    right: 0;
    margin-top: 6px;
    background: #1f1f1f;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    min-width: 160px;
    max-height: 60vh; /* Limit height to 60% of viewport */
    overflow-y: auto; /* Add vertical scrollbar when needed */
    box-shadow: 0 8px 20px rgba(0,0,0,0.35);
    padding: 6px;
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.fiat-menu.show { display: block; }

/* Custom scrollbar styling for WebKit browsers */
.fiat-menu::-webkit-scrollbar {
    width: 6px;
}

.fiat-menu::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
    border-radius: 3px;
}

.fiat-menu::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

.fiat-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.4);
}

.fiat-option {
    padding: 6px 8px;
    color: #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
}

.fiat-option:hover { background: rgba(255,255,255,0.08); }

/* Three-row layout for stat boxes: icon (top), value (middle), label (bottom) */
#crypto-prices-container .stat-box {
    display: grid;
    grid-template-rows: auto auto auto;
    align-items: center;
    justify-items: center;
    gap: 8px;
}

#crypto-prices-container .stat-icon-row {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 72px;
}

/* Remove right margin when icon is centered on its own row */
#crypto-prices-container .stat-icon-row #crypto-dcc-icon,
#crypto-prices-container .stat-icon-row #crypto-dcc-price-icon,
#crypto-prices-container .stat-icon-row #crypto-ddc-icon {
    margin-right: 0 !important;
}

/* Strong override: ensure 2x icons beat any id/attribute rules */
#crypto-prices-container #crypto-dcc-icon.scale-2x,
#crypto-prices-container #crypto-dcc-icon.scale-2x[style],
#crypto-prices-container #crypto-dcc-price-icon.scale-2x,
#crypto-prices-container #crypto-dcc-price-icon.scale-2x[style],
#crypto-prices-container #crypto-ddc-icon.scale-2x,
#crypto-prices-container #crypto-ddc-icon.scale-2x[style] {
    width: 64px !important;
    height: 64px !important;
    font-size: 32px !important;
    line-height: 64px !important;
    min-width: 64px !important;
    max-width: 64px !important;
    min-height: 64px !important;
    max-height: 64px !important;
}

#crypto-prices-container .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #E0E0E0;
}

#crypto-prices-container .stat-label {
    font-size: 0.95rem;
    color: #b0b0b0;
}

#crypto-prices-container .prices-subnote {
    grid-column: 1 / -1;
    margin-top: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: #cfcfcf;
    font-size: 0.9rem;
    line-height: 1.4;
}

#crypto-prices-container .prices-subnote-list {
    margin: 0;
    padding-left: 18px;
}

#crypto-prices-container .prices-subnote-list li {
    margin: 4px 0;
}

.crypto-prices-section {
    margin-bottom: 30px;
}

.prices-header {
    color: #00d4ff;
    font-size: 1.8em;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.crypto-prices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.crypto-price-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.crypto-price-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(0, 212, 255, 0.2);
    border-color: rgba(0, 212, 255, 0.3);
}

.crypto-price-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #00d4ff, #0099cc, #00d4ff);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.crypto-price-card:hover::before {
    opacity: 1;
}

.crypto-header {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.crypto-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d4ff, #0099cc);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    color: white;
    margin-right: 12px;
    box-shadow: 0 4px 12px rgba(0, 212, 255, 0.3);
}

.crypto-name {
    font-size: 1.1em;
    font-weight: 600;
    color: #ffffff;
    flex: 1;
}

.crypto-price {
    font-size: 1.8em;
    font-weight: bold;
    color: #00d4ff;
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.crypto-price.loading {
    color: #666;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.crypto-change {
    font-size: 0.9em;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    display: inline-block;
    margin-bottom: 12px;
}

.crypto-change.positive {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.crypto-change.negative {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.crypto-fiats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.fiat-price {
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.85em;
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
}

.fiat-price:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.05);
}

/* Crypto Price Icons - Make them larger and consistent with maximum specificity */
.stat-box .stat-label #crypto-dcc-icon,
.stat-box .stat-label #crypto-dcc-price-icon,
.stat-box .stat-label #crypto-ddc-icon,
#crypto-dcc-icon,
#crypto-dcc-price-icon,
#crypto-ddc-icon {
    width: 32px !important;
    height: 32px !important;
    font-size: 16px !important;
    line-height: 30px !important;
    margin-right: 8px !important;
    display: inline-block !important;
    vertical-align: middle !important;
    min-width: 32px !important;
    max-width: 32px !important;
    min-height: 32px !important;
    max-height: 32px !important;
    box-sizing: border-box !important;
}

/* Override any conflicting inline styles at the highest level */
#crypto-prices-container #crypto-dcc-icon[style],
#crypto-prices-container #crypto-dcc-price-icon[style],
#crypto-prices-container #crypto-ddc-icon[style] {
    width: 32px !important;
    height: 32px !important;
    font-size: 16px !important;
    line-height: 30px !important;
    transform-origin: center center;
}

/* Allow 2x scaling when requested */
#crypto-prices-container .scale-2x {
    width: 64px !important;
    height: 64px !important;
    font-size: 32px !important;
    line-height: 60px !important;
}

/* Optional hover boost for icons */
#crypto-prices-container span[id^="crypto-"]:not(.scale-2x):hover {
    transform: scale(1.4);
}

@media (max-width: 480px) {
    #crypto-prices-container .stat-value {
        font-size: 1.5rem;
    }
}

/* DDC Block Height Section */
.ddc-block-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.ddc-block-section h4 {
    color: #00d4ff;
    margin-bottom: 15px;
    font-size: 1.4em;
    text-align: center;
    font-weight: 600;
}

.block-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.block-height,
.ddc-price-internal,
.btc-ratio {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.block-height .label,
.ddc-price-internal .label,
.btc-ratio .label {
    display: block;
    font-size: 0.9em;
    color: #b0b0b0;
    margin-bottom: 4px;
    font-weight: 500;
}

.block-height .value,
.ddc-price-internal .value,
.btc-ratio .value {
    display: block;
    font-size: 1.2em;
    font-weight: bold;
    color: #00d4ff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.block-height .value {
    font-size: 1.4em;
    color: #ff6b6b;
}

/* Error styling */
.crypto-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
}

/* Last updated timestamp */
#prices-last-updated {
    display: block;
    text-align: center;
    margin-top: 20px;
    color: #888;
    font-size: 0.9em;
}

/* When placed inside the 3-column grid, span full width and center */
#crypto-prices-container #prices-last-updated {
    grid-column: 1 / -1;
    justify-self: center;
}

/* Loading state */
.loading {
    color: #666 !important;
    animation: pulse 2s infinite;
}

/* Responsive design */
@media (max-width: 768px) {
    .crypto-prices-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .crypto-price-card {
        padding: 15px;
    }

    .crypto-price {
        font-size: 1.5em;
    }

    .crypto-logo {
        width: 35px;
        height: 35px;
        font-size: 12px;
    }

    .block-info {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .crypto-fiats {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    #crypto-prices-container {
        margin: 10px 0;
        padding: 15px;
    }

    .prices-header {
        font-size: 1.5em;
    }

    .crypto-price-card {
        padding: 12px;
    }

    .crypto-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .crypto-logo {
        align-self: center;
    }

    .crypto-fiats {
        flex-direction: column;
        align-items: center;
    }

    .fiat-price {
        text-align: center;
        width: 100%;
        max-width: 120px;
    }
}

/* Special styling for DDC card */
.crypto-price-card:first-child {
    border-color: rgba(0, 212, 255, 0.4);
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
}

.crypto-price-card:first-child .crypto-logo {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
}

.crypto-price-card:first-child .crypto-price {
    color: #ff6b6b;
}

/* Animation for price updates */
.price-update {
    animation: priceUpdate 0.5s ease-in-out;
}

@keyframes priceUpdate {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Dark theme adjustments */
@media (prefers-color-scheme: dark) {
    #crypto-prices-container {
        background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 100%);
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .crypto-price-card {
        border-width: 2px;
    }

    .crypto-change {
        border-width: 2px;
    }
}
