/* Crypto Treemap Widget - Optimized CSS */
:root {
    --crypto-primary-bg: #f5f5f5;
    --crypto-secondary-bg: #ffffff;
    --crypto-border-color: #e0e0e0;
    --crypto-text-primary: #212121;
    --crypto-text-secondary: #666;
    --crypto-success: #2e7d32;
    --crypto-danger: #d32f2f;
    --crypto-warning: #f57c00;
    --crypto-border-radius: 8px;
    --crypto-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --crypto-transition: all 0.3s ease;
}

.crypto-treemap-wrapper {
    all: initial;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    contain: layout style paint;
}

.crypto-treemap-wrapper * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.crypto-treemap-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background-color: var(--crypto-primary-bg);
    border-radius: var(--crypto-border-radius);
    box-shadow: var(--crypto-shadow);
}

/* Treemap Layout */
.crypto-treemap {
    width: 100%;
    height: 600px;
    position: relative;
    background-color: var(--crypto-secondary-bg);
    border-radius: var(--crypto-border-radius);
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Treemap Cell Styles */
.crypto-treemap-cell {
    position: absolute;
    overflow: hidden;
    box-sizing: border-box;
    border: 1px solid var(--crypto-secondary-bg);
    transition: var(--crypto-transition);
    padding: 8px;
    font-size: 12px;
    cursor: pointer;
    border-radius: 2px;
    will-change: transform;
    backface-visibility: hidden;
}

.crypto-treemap-cell:hover {
    z-index: 10;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transform: scale(1.02);
    border-color: rgba(255, 255, 255, 0.3);
}

.crypto-treemap-cell.green {
    background-color: var(--crypto-success);
    color: white;
}

.crypto-treemap-cell.red {
    background-color: var(--crypto-danger);
    color: white;
}

.crypto-treemap-cell-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100%;
    text-align: center;
}

/* Text Elements */
.crypto-treemap-symbol {
    font-weight: 600;
    margin-bottom: 2px;
    font-size: 110%;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.crypto-treemap-price {
    margin-bottom: 2px;
    font-size: 95%;
    opacity: 0.95;
}

.crypto-treemap-change {
    font-size: 85%;
    opacity: 0.9;
}

.crypto-treemap-volume {
    font-size: 75%;
    opacity: 0.8;
    margin-top: 2px;
}
/* Loading and Error States */
.crypto-treemap-loading,
.crypto-treemap-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px;
    text-align: center;
    border-radius: var(--crypto-border-radius);
    box-shadow: var(--crypto-shadow);
    z-index: 100;
    backdrop-filter: blur(10px);
}

.crypto-treemap-loading {
    background: rgba(248, 248, 248, 0.95);
    color: var(--crypto-text-secondary);
}

.crypto-treemap-error {
    background: rgba(244, 67, 54, 0.1);
    color: var(--crypto-danger);
    border: 1px solid var(--crypto-danger);
}

/* Connection Status */
.crypto-connection-status {
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 10px;
    text-align: center;
}

.crypto-connection-status.offline {
    background-color: var(--crypto-warning);
    color: white;
}

.crypto-connection-status.online {
    background-color: var(--crypto-success);
    color: white;
}

/* Header Elements */
.crypto-treemap-title {
    font-size: 1.5em;
    margin-bottom: 10px;
    text-align: center;
    font-weight: 600;
    color: var(--crypto-text-primary);
}

.crypto-treemap-updated {
    font-size: 0.8em;
    color: var(--crypto-text-secondary);
    margin-bottom: 15px;
    text-align: right;
    opacity: 0.8;
}

/* Animations */
.crypto-treemap-cell.updating {
    opacity: 0.7;
    transform: scale(0.98);
    transition: all 0.3s ease;
}

.crypto-treemap-cell.updated {
    opacity: 1;
    transform: scale(1.02);
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
    transition: all 0.3s ease;
}

.crypto-treemap-loading .crypto-spinner {
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-left: 3px solid var(--crypto-text-secondary);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: crypto-spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes crypto-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Performance optimizations */
.crypto-treemap-cell {
    transform: translateZ(0);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: all 0.3s ease;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .crypto-treemap-container {
        padding: 15px;
    }
    
    .crypto-treemap {
        height: 550px;
    }
}

@media (max-width: 768px) {
    .crypto-treemap-container {
        padding: 10px;
        border-radius: 4px;
    }
    
    .crypto-treemap {
        height: 500px;
    }
    
    .crypto-treemap-title {
        font-size: 1.3em;
    }
    
    .crypto-treemap-symbol {
        font-size: 105%;
    }
    
    .crypto-treemap-price {
        font-size: 90%;
    }
}

@media (max-width: 480px) {
    .crypto-treemap-container {
        padding: 8px;
        margin: 5px;
    }
    
    .crypto-treemap {
        height: 400px;
    }
    
    .crypto-treemap-title {
        font-size: 1.2em;
        margin-bottom: 8px;
    }
    
    .crypto-treemap-cell {
        padding: 4px;
        font-size: 11px;
    }
    
    .crypto-treemap-symbol {
        font-size: 95%;
    }
    
    .crypto-treemap-price {
        font-size: 85%;
    }
    
    .crypto-treemap-change,
    .crypto-treemap-volume {
        font-size: 75%;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .crypto-treemap-cell {
        border-width: 0.5px;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .crypto-treemap-cell {
        transition: none;
    }
    
    .crypto-treemap-cell:hover {
        transform: none;
    }
    
    .crypto-treemap-cell.blink {
        animation: none;
    }
    
    .crypto-spinner {
        animation: none;
    }
}

/* Header and Controls */
.crypto-treemap-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.crypto-treemap-controls {
    display: flex;
    gap: 10px;
}

.crypto-refresh-btn {
    background: var(--crypto-success);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: var(--crypto-transition);
}

.crypto-refresh-btn:hover {
    background: #1b5e20;
}

/* Meta Information */
.crypto-treemap-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

.crypto-offline-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    background: var(--crypto-warning);
    color: white;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.crypto-offline-icon {
    font-size: 14px;
}

/* Footer */
.crypto-treemap-footer {
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--crypto-text-secondary);
    flex-wrap: wrap;
    gap: 10px;
}

.crypto-data-source {
    opacity: 0.7;
}

.crypto-debug-info {
    opacity: 0.6;
    font-family: monospace;
}

/* Enhanced Error State */
.crypto-treemap-error h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
}

.crypto-retry-btn {
    background: var(--crypto-danger);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 10px;
    transition: var(--crypto-transition);
}

.crypto-retry-btn:hover {
    background: #b71c1c;
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus Management */
.crypto-treemap:focus {
    outline: 2px solid var(--crypto-success);
    outline-offset: 2px;
}

.crypto-treemap-cell:focus {
    outline: 2px solid var(--crypto-secondary-bg);
    outline-offset: 1px;
    z-index: 20;
}

/* Print Styles */
@media print {
    .crypto-treemap-wrapper {
        background: white !important;
        box-shadow: none !important;
    }
    
    .crypto-treemap-controls,
    .crypto-refresh-btn,
    .crypto-retry-btn {
        display: none !important;
    }
    
    .crypto-treemap {
        height: 400px !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --crypto-primary-bg: #1a1a1a;
        --crypto-secondary-bg: #2d2d2d;
        --crypto-border-color: #404040;
        --crypto-text-primary: #ffffff;
        --crypto-text-secondary: #cccccc;
        --crypto-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    }
    
    .crypto-treemap-loading {
        background: rgba(45, 45, 45, 0.95);
    }
} 