/* Fullscreen Toggle Button */
.bmt-fullscreen-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999999;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
    color: #fff;
}

/* === AUTO-HIDE TOGGLE BUTTON WHEN IDLE (v1.1) === */
/* Fade out the toggle button when user is idle in fullscreen mode */
body.bmt-fullscreen-active.bmt-idle .bmt-fullscreen-btn {
    opacity: 0 !important;
    pointer-events: none;
    transform: scale(0.8);
}

.bmt-fullscreen-btn:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.bmt-fullscreen-btn:active {
    transform: scale(0.95);
}

.bmt-fullscreen-btn svg {
    width: 24px;
    height: 24px;
    transition: transform 0.3s ease;
}

/* Icon toggle on fullscreen state */
body.bmt-fullscreen-active .bmt-fullscreen-btn .expand-icon {
    display: none;
}

/* Animation for entering/exiting fullscreen */
@keyframes fullscreenFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

body.bmt-fullscreen-active #boldmen-terminal-container {
    animation: fullscreenFadeIn 0.3s ease-out;
}

/* Smart Idle Behavior: Hide scrollbar and cursor when idle */
body.bmt-fullscreen-active.bmt-idle,
body.bmt-fullscreen-active.bmt-idle #boldmen-terminal-container,
body.bmt-fullscreen-active.bmt-idle .boldmen-terminal-wrapper,
body.bmt-fullscreen-active.bmt-idle .bmt-table-wrapper,
body.bmt-fullscreen-active.bmt-idle .bmt-terminal-container,
body.bmt-fullscreen-active.bmt-idle [class*="terminal"] {
    cursor: none;
    /* Hide cursor */
}

/* Hide scrollbar ONLY when idle */
body.bmt-fullscreen-active.bmt-idle::-webkit-scrollbar,
body.bmt-fullscreen-active.bmt-idle .bmt-terminal-container::-webkit-scrollbar,
body.bmt-fullscreen-active.bmt-idle .bmt-table-wrapper::-webkit-scrollbar,
body.bmt-fullscreen-active.bmt-idle #boldmen-terminal-container::-webkit-scrollbar,
body.bmt-fullscreen-active.bmt-idle [class*="terminal"]::-webkit-scrollbar {
    display: none !important;
}

body.bmt-fullscreen-active.bmt-idle,
body.bmt-fullscreen-active.bmt-idle .bmt-terminal-container,
body.bmt-fullscreen-active.bmt-idle .bmt-table-wrapper,
body.bmt-fullscreen-active.bmt-idle #boldmen-terminal-container,
body.bmt-fullscreen-active.bmt-idle [class*="terminal"] {
    -ms-overflow-style: none !important;
    /* IE and Edge */
    scrollbar-width: none !important;
    /* Firefox */
}

/* === EMERGENCY REFINEMENT (v1.3) === */
/* Force Header and Indices Bar to STAY VISIBLE with maximum specificity */
/* Use block display for header to fix alignment (eyebrow above brand name) */
body.bmt-fullscreen-active .bmt-terminal-container.bmt-fullscreen-mode .bmt-header-container,
body.bmt-fullscreen-active .bmt-terminal-container.bmt-fullscreen-mode.bmt-toolbar-hidden .bmt-header-container {
    opacity: 1 !important;
    max-height: 500px !important;
    visibility: visible !important;
    display: block !important;
    overflow: visible !important;
    transition: opacity 0.5s ease;
    margin-bottom: 20px !important;
}

body.bmt-fullscreen-active .bmt-terminal-container.bmt-fullscreen-mode .bmt-indices-bar,
body.bmt-fullscreen-active .bmt-terminal-container.bmt-fullscreen-mode.bmt-toolbar-hidden .bmt-indices-bar {
    opacity: 1 !important;
    max-height: 500px !important;
    visibility: visible !important;
    display: flex !important;
    overflow: visible !important;
    transition: opacity 0.5s ease;
    margin-bottom: 15px !important;
}

/* Ensure Eyebrow and Brand Name inside header stack correctly */
body.bmt-fullscreen-active .bmt-header-container .bmt-eyebrow,
body.bmt-fullscreen-active .bmt-header-container .bmt-brand-name {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Smoothly fade out only the Toolbar and Expand the Table */
.bmt-terminal-container.bmt-fullscreen-mode .bmt-toolbar {
    transition: max-height 0.5s ease, opacity 0.5s ease, margin 0.5s ease, padding 0.5s ease;
    overflow: hidden;
}

/* Idle state: Hide Toolbar with high specificity */
body.bmt-fullscreen-active .bmt-terminal-container.bmt-fullscreen-mode.bmt-toolbar-hidden .bmt-toolbar {
    max-height: 0 !important;
    opacity: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
    pointer-events: none !important;
    overflow: hidden !important;
}

/* Adjust Table Wrapper Height when Toolbar is hidden */
.bmt-terminal-container.bmt-fullscreen-mode .bmt-table-wrapper {
    max-height: calc(100vh - 120px) !important;
    transition: max-height 0.5s ease;
}

.bmt-terminal-container.bmt-fullscreen-mode.bmt-toolbar-hidden .bmt-table-wrapper {
    max-height: calc(100vh - 60px) !important;
}


/* Responsive adjustments */
@media (max-width: 768px) {
    .bmt-fullscreen-btn {
        width: 45px;
        height: 45px;
        top: 15px;
        right: 15px;
    }

    .bmt-fullscreen-btn svg {
        width: 20px;
        height: 20px;
    }
}

/* Keyboard shortcut hint (optional tooltip) */
.bmt-fullscreen-btn::after {
    content: attr(title);
    position: absolute;
    bottom: -35px;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.bmt-fullscreen-btn:hover::after {
    opacity: 1;
}