/* Compact View - Embed sidepanel as iframe inside Overleaf editor area */

/* Wrapper that contains both editor and compact panel */
#overleaf-helper-compact-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

/* The original editor content - takes remaining space */
#overleaf-helper-compact-wrapper > .overleaf-editor-original {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Container for the compact view panel with iframe */
#overleaf-helper-compact-panel {
    flex-shrink: 0;
    height: 33.33%; /* Default 1/3 of parent height */
    min-height: 120px;
    max-height: 70%;

    background: #ffffff;
    border-top: 2px solid #16a34a;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);

    display: flex;
    flex-direction: column;
    position: relative;

    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#overleaf-helper-compact-panel.hidden {
    display: none;
}

/* Resize handle / drag bar */
#compact-panel-resizer {
    position: absolute;
    top: -4px;
    left: 0;
    right: 0;
    height: 8px;
    cursor: ns-resize;
    background: transparent;
    z-index: 10;
    transition: background 0.2s;
}

#compact-panel-resizer:hover,
#compact-panel-resizer.dragging {
    background: linear-gradient(180deg, rgba(22, 163, 74, 0.4) 0%, transparent 100%);
}

#compact-panel-resizer::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 4px;
    background: #16a34a;
    border-radius: 2px;
    transition: all 0.2s;
    opacity: 0.6;
}

#compact-panel-resizer:hover::before,
#compact-panel-resizer.dragging::before {
    opacity: 1;
    width: 80px;
    background: #15803d;
}

/* Close button in top-right corner */
#compact-panel-close {
    position: absolute;
    top: 8px;
    right: 12px;
    width: 28px;
    height: 28px;
    z-index: 20;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;

    color: #64748b;
    transition: all 0.2s;
}

#compact-panel-close:hover {
    background: #fee2e2;
    border-color: #fecaca;
    color: #dc2626;
}

#compact-panel-close svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

/* Iframe container */
#compact-panel-iframe-container {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* The iframe itself */
#compact-panel-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #ffffff;
}

/* Overlay during resize to prevent iframe from capturing mouse events */
#compact-panel-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: 5;
    display: none;
}

#compact-panel-overlay.active {
    display: block;
}
