/* Mobile Chart Stack (Revision 18) */

/* The Toggle Bar (Visible on Mobile) */
.mobile-chart-bar {
    display: none;
    /* Hidden on Desktop */
    width: 100%;
    height: 24px;
    /* Slim Bar */
    background: #fff;
    border-bottom: 1px solid var(--km-border);
    display: flex;
    align-items: center;
    justify-content: center;
    /* Center Icon */
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--km-text-secondary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    z-index: 10;
    transition: background 0.2s ease;
}

.mobile-chart-bar:active {
    background: var(--km-hover);
}

.mobile-chart-bar .toggle-icon {
    font-size: 0.8rem;
    color: var(--km-text-secondary);
    transition: transform 0.3s ease;
}

/* Rotate icon when open */
.mobile-chart-panel.active+.mobile-chart-bar .toggle-icon,
.mobile-chart-bar.active .toggle-icon {
    transform: rotate(180deg);
}

/* The Collapsible Panel */
.mobile-chart-panel {
    display: none;
    /* Hidden on Desktop */
    width: 100%;
    /* Start closed logic handled by JS class toggle usually, or max-height transition */
    height: 0;
    overflow: hidden;
    background: #fff;
    border-bottom: 1px solid var(--km-border);
    transition: height 0.3s ease-out;
    flex-direction: column;
}

/* Correct class is 'active' per console.js */
.mobile-chart-panel.active {
    height: 45vh;
    /* Allows seeing chat below */
    display: flex;
}

/* Compact Header (Combined Title + Toggles) */
.mobile-chart-header {
    background: #fafafa;
    border-bottom: 1px solid var(--km-border);
    padding: 6px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 40px;
    /* Fixed small height */
}

/* Chart Canvas Area */
.mobile-chart-panel .chart-canvas {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--km-background);
    overflow: hidden;
    position: relative;
    padding: 10px;
    /* Add padding so chart isn't glued to edges */
}

/* Force SVG scaling */
.mobile-chart-panel .chart-canvas svg {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
}

.mobile-chart-panel .chart-footer {
    height: 40px;
    border-top: 1px solid var(--km-border);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #fff;
}

/* Mobile Media Query */
@media screen and (max-width: 768px) {
    .mobile-chart-bar {
        display: flex;
    }

    /* Ensure panel follows bar */
    .mobile-chart-panel {
        /* display managed by JS/Classes, but initial state hidden height */
    }
}

/* Desktop Hide */
@media screen and (min-width: 769px) {

    .mobile-chart-bar,
    .mobile-chart-panel {
        display: none !important;
    }
}