/* tradingview-chart.css */
/* Stili per TradingView Lightweight Charts */

/* Container del chart */
#tradingview-chart-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: #ffffff;
}

/* Overlay loading durante il caricamento dati */
.chart-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.loading-spinner {
    text-align: center;
    color: #2962FF;
}

.loading-spinner i {
    margin-bottom: 1rem;
    color: #2962FF;
}

.loading-spinner p {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    color: #666;
}

/* Animazione fade-in per il chart */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

#tradingview-chart-container.loaded {
    animation: fadeIn 0.3s ease-in;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #tradingview-chart-container {
        min-height: 400px;
    }
}

/* Ensure proper sizing in chart-canvas */
.chart-canvas {
    position: relative;
}

.chart-canvas > div {
    width: 100%;
    height: 100%;
}

/* Legenda OHLC e Indicatori - Stile compatto e allineato con CSS Grid */
.ohlc-legend {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 3px 16px rgba(0, 0, 0, 0.08),
                0 1px 6px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.06);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    width: fit-content;
    min-width: auto;
    max-width: calc(100vw - 32px);
}

.ohlc-legend:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.10),
                0 2px 8px rgba(0, 0, 0, 0.06);
    background: rgba(255, 255, 255, 0.98);
}

/* Riga della legenda - Layout flex compatto */
.legend-row {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 4px;
    padding: 4px 9px;
    transition: background-color 0.2s ease;
}

/* Prima riga: OHLC prezzi */
.legend-row-price {
    padding: 5px 10px;
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.04) 0%, rgba(33, 150, 243, 0.02) 100%);
    border-radius: 8px 8px 0 0;
}

/* Righe indicatori */
.legend-row-indicator {
    padding: 3px 9px;
}

.legend-row-indicator:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.legend-row-indicator:last-child {
    border-radius: 0 0 8px 8px;
}

/* Flex container per nome asset + valori OHLC */
.legend-price-content {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
}

/* Nome asset */
.legend-asset-name {
    font-weight: 700;
    color: #1a1a1a;
    font-size: 11.5px;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

/* Separatore visivo */
.legend-separator {
    color: #cbd5e0;
    font-size: 9px;
    padding: 0 1px;
    user-select: none;
}

/* Etichette (Open, High, Low, Close, Data) */
.ohlc-legend-label {
    font-weight: 600;
    color: #64748b;
    font-size: 10px;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

/* Valori numerici */
.ohlc-legend-value {
    font-weight: 600;
    color: #1e293b;
    font-size: 10.5px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Linea separatrice tra prezzi e indicatori */
.legend-divider {
    height: 1px;
    background: linear-gradient(to right,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, 0.08) 50%,
        rgba(0, 0, 0, 0) 100%);
    margin: 2px 8px;
}

/* Container indicatori */
.legend-indicators-container {
    display: flex;
    flex-direction: column;
}

/* Icona colorata indicatore */
.legend-indicator-icon {
    width: 8px;
    height: 8px;
    border-radius: 1.5px;
    display: inline-block;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

/* Flex container per nome indicatore + valori */
.legend-indicator-content {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
    flex: 1;
}

/* Nome indicatore con parametri */
.legend-indicator-name {
    font-weight: 600;
    color: #334155;
    font-size: 10px;
    letter-spacing: 0.005em;
    white-space: nowrap;
}

/* Data dell'indicatore */
.legend-indicator-date {
    font-weight: 500;
    color: #64748b;
    font-size: 9.5px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Valori dell'indicatore */
.legend-indicator-values {
    display: flex;
    gap: 5px;
    flex-wrap: nowrap;
    overflow: hidden;
}

.legend-indicator-value {
    font-weight: 600;
    color: #475569;
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Responsive adjustments per la legenda */
@media (max-width: 768px) {
    .ohlc-legend {
        top: 8px;
        left: 8px;
        max-width: calc(100vw - 32px);
    }

    .legend-row-price {
        padding: 4px 8px;
    }

    .legend-row-indicator {
        padding: 2px 7px;
    }

    .legend-asset-name {
        font-size: 10.5px;
    }

    .ohlc-legend-label {
        font-size: 9px;
    }

    .ohlc-legend-value {
        font-size: 9.5px;
    }

    .legend-indicator-name {
        font-size: 9px;
    }

    .legend-indicator-value {
        font-size: 9px;
    }

    .legend-divider {
        margin: 1px 6px;
    }

    .legend-price-content {
        gap: 3px;
    }

    .legend-indicator-content {
        gap: 3px;
    }
}

/* Badge scala logaritmica nella legenda */
.legend-scale-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 9px;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 4px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    box-shadow: 0 1px 3px rgba(102, 126, 234, 0.3);
    white-space: nowrap;
}

/* Badge nella toolbar */
.toolbar-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 8px;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 3px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    box-shadow: 0 1px 2px rgba(102, 126, 234, 0.3);
}
