/*
 * Stili centralizzati per AISystem GoogleChart v2.1:
 * barra del titolo stile finestra attaccata al box (con doppio click Zoom),
 * pulsanti integrati nella barra (Reset Serie, Export CSV, Download PNG, Zoom/Ripristina, Chiudi),
 * overlay fullscreen 90% su document.body e cursore interattivo su legenda SVG.
 */

.ai-chart-shell {
    position: relative;
    width: 100%;
    box-sizing: border-box;
    background: #ffffff;
    display: flex;
    flex-direction: column;
}

/* Barra del titolo stile finestra */
.ai-chart-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 34px;
    padding: 0 4px 0 12px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    user-select: none;
    -webkit-user-select: none;
    box-sizing: border-box;
}

.ai-chart-titlebar.is-zoomable {
    cursor: pointer;
}

.ai-chart-titlebar-text {
    font-size: 12.5px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 6px 0;
    flex: 1 1 auto;
}

.ai-chart-toolbar {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    flex: 0 0 auto;
}

.ai-chart-tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 26px;
    padding: 0 7px;
    font-size: 12px;
    line-height: 1;
    color: #475569;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.ai-chart-tool-btn:hover,
.ai-chart-tool-btn:focus {
    background: #e2e8f0;
    border-color: #cbd5e1;
    color: #0f172a;
    outline: none;
}

.ai-chart-tool-btn.is-reset-btn {
    display: none;
    gap: 4px;
    margin-right: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #0c4a6e;
    background: #e0f2fe;
    border-color: #7dd3fc;
}

.ai-chart-tool-btn.is-reset-btn:hover {
    background: #bae6fd;
    color: #0c4a6e;
}

.ai-chart-shell.has-hidden-series .ai-chart-tool-btn.is-reset-btn {
    display: inline-flex;
}

.ai-chart-tool-btn.is-close-btn {
    display: none;
    font-size: 13px;
}

.ai-chart-shell.is-zoomed .ai-chart-tool-btn.is-close-btn {
    display: inline-flex;
}

.ai-chart-tool-btn.is-close-btn:hover,
.ai-chart-tool-btn.is-close-btn:focus {
    background: #dc2626;
    border-color: #b91c1c;
    color: #ffffff;
}

/* Fallback toolbar flottante solo se showHeaderBar = false */
.ai-chart-shell.no-header-bar .ai-chart-toolbar {
    position: absolute;
    top: 4px;
    right: 6px;
    z-index: 15;
    opacity: 0.45;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #cbd5e1;
    border-radius: 3px;
    padding: 1px;
}

.ai-chart-shell.no-header-bar:hover .ai-chart-toolbar,
.ai-chart-shell.no-header-bar.is-zoomed .ai-chart-toolbar,
.ai-chart-shell.no-header-bar.has-hidden-series .ai-chart-toolbar {
    opacity: 1;
}

.ai-chart-body {
    width: 100%;
    padding: 6px 6px 4px 6px;
    box-sizing: border-box;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

.ai-chart-canvas {
    width: 100%;
    min-height: 160px;
    flex: 1 1 auto;
}

/* Placeholder anti-salto scroll durante lo Zoom */
.ai-chart-placeholder {
    width: 100%;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 3px;
    box-sizing: border-box;
}

/* Overlay Fullscreen 90% Viewport */
body.ai-chart-body-lock {
    overflow: hidden !important;
}

.ai-chart-zoom-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100500;
    background: rgba(15, 23, 42, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5vh 2.5vw;
    box-sizing: border-box;
}

.ai-chart-zoom-stage {
    width: 90vw;
    height: 90vh;
    max-width: 1680px;
    background: #ffffff;
    border: 1px solid #64748b;
    border-radius: 6px;
    box-shadow: 0 22px 50px rgba(15, 23, 42, 0.42);
    overflow: hidden;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.ai-chart-zoom-stage .ai-chart-shell.is-zoomed {
    flex: 1 1 auto;
    height: 100%;
}

.ai-chart-zoom-stage .ai-chart-titlebar {
    min-height: 40px;
    padding: 0 8px 0 16px;
    background: #f1f5f9;
    border-bottom: 1px solid #cbd5e1;
}

.ai-chart-zoom-stage .ai-chart-titlebar-text {
    font-size: 14px;
}

.ai-chart-zoom-stage .ai-chart-tool-btn {
    min-width: 32px;
    height: 30px;
    font-size: 13px;
}

.ai-chart-zoom-stage .ai-chart-body {
    padding: 10px 14px 12px 14px;
}