/**
 * DataEdge Layout Manager Styles
 *
 * Styles for split views, split handle, and widget overlays.
 * Integrates with DataEdge design system (glassmorphism).
 */

/* ============================================================
   LAYOUT PANES
   ============================================================ */

.layout-pane {
    position: relative;
    overflow: hidden;
    background: transparent;
    height: 100%;
    width: 100%;
}

.layout-pane-primary {
    /* Pane 1 (always visible) */
}

.layout-pane-secondary {
    /* Pane 2 (visible in split mode) */
}

/* Ensure iframes fill panes */
.layout-pane .app-iframe {
    width: 100%;
    height: 100%;
}

/* Welcome screen should also fill pane */
.layout-pane .welcome-screen {
    width: 100%;
    height: 100%;
}

/* ============================================================
   SINGLE VIEW (Default)
   ============================================================ */

.layout-single {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.layout-single .layout-pane-primary {
    width: 100%;
    height: 100%;
    flex: 1;
}

/* ============================================================
   SPLIT VIEW (Horizontal)
   ============================================================ */

.layout-split-horizontal {
    display: flex !important;
    flex-direction: row !important;
    gap: 0;
    height: 100%;
}

.layout-split-horizontal .layout-pane {
    height: 100%;
    flex-shrink: 0;
}

.layout-split-horizontal .split-handle {
    width: 8px;
    height: 100%;
    flex-shrink: 0;
    cursor: col-resize;
}

/* ============================================================
   SPLIT VIEW (Vertical)
   ============================================================ */

.layout-split-vertical {
    display: flex !important;
    flex-direction: column !important;
    gap: 0;
    height: 100%;
}

.layout-split-vertical .layout-pane {
    width: 100%;
    flex-shrink: 0;
}

.layout-split-vertical .split-handle {
    width: 100%;
    height: 8px;
    flex-shrink: 0;
    cursor: row-resize;
}

/* ============================================================
   SPLIT HANDLE
   ============================================================ */

.split-handle {
    position: relative;
    background: rgba(59, 130, 246, 0.15);
    transition: all 0.2s ease;
    z-index: 10;
    user-select: none;
}

.split-handle:hover {
    background: rgba(59, 130, 246, 0.3);
}

.split-handle:active {
    background: rgba(52, 211, 153, 0.3);
}

/* The draggable glider button */
.split-handle-grip {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.9) 0%, rgba(52, 211, 153, 0.9) 100%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    user-select: none;
    transition: all 0.2s ease;
}

/* Horizontal split - vertical glider button */
.layout-split-horizontal .split-handle-grip {
    width: 24px;
    height: 60px;
    flex-direction: column;
}

/* Vertical split - horizontal glider button */
.layout-split-vertical .split-handle-grip {
    width: 60px;
    height: 24px;
    flex-direction: row;
}

/* Grip dots */
.split-handle-grip::before,
.split-handle-grip::after {
    content: '';
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
}

/* Hover state for glider */
.split-handle:hover .split-handle-grip {
    background: linear-gradient(135deg, rgba(59, 130, 246, 1) 0%, rgba(52, 211, 153, 1) 100%);
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%) scale(1.05);
}

/* Active/dragging state */
.split-handle:active .split-handle-grip,
.layout-dragging .split-handle-grip {
    background: linear-gradient(135deg, rgba(52, 211, 153, 1) 0%, rgba(59, 130, 246, 1) 100%);
    box-shadow: 0 4px 20px rgba(52, 211, 153, 0.6);
    transform: translate(-50%, -50%) scale(1.1);
}

/* ============================================================
   DRAGGING STATE
   ============================================================ */

.layout-dragging {
    user-select: none;
}

.layout-dragging * {
    pointer-events: none;
}

.layout-dragging .split-handle {
    pointer-events: auto;
    background: var(--de-accent);
}

/* ============================================================
   WIDGET CONTAINER (Overlay)
   ============================================================ */

.widget-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none; /* Allow click-through */
    z-index: 9999;
}

/* Individual widgets will have pointer-events: auto */
.widget-container > * {
    pointer-events: auto;
}

/* ============================================================
   WIDGET STYLES (Base)
   ============================================================ */

.de-widget {
    position: absolute;
    background: var(--de-glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--de-glass-border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    resize: both;
    min-width: 200px;
    min-height: 150px;
}

.de-widget-titlebar {
    background: rgba(59, 130, 246, 0.1);
    border-bottom: 1px solid var(--de-glass-border);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: move;
    user-select: none;
}

.de-widget-title {
    color: var(--de-primary);
    font-weight: 600;
    font-size: 14px;
}

.de-widget-controls {
    display: flex;
    gap: 4px;
}

.de-widget-btn {
    background: none;
    border: none;
    color: var(--de-text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s;
}

.de-widget-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    color: var(--de-primary);
}

.de-widget-content {
    flex: 1;
    padding: 12px;
    overflow: auto;
    color: var(--de-text);
}

/* Minimized widget */
.de-widget-minimized {
    width: auto !important;
    height: auto !important;
    resize: none;
}

.de-widget-minimized .de-widget-content {
    display: none;
}

/* Widget animations */
@keyframes widgetSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.de-widget {
    animation: widgetSlideIn 0.3s ease-out;
}

/* ============================================================
   RESPONSIVE DESIGN
   ============================================================ */

@media (max-width: 768px) {
    /* Larger split handle for mobile */
    .layout-split-horizontal .split-handle {
        width: 8px;
    }

    .layout-split-vertical .split-handle {
        height: 8px;
    }

    /* Widgets take more space on mobile */
    .de-widget {
        max-width: 95vw !important;
        max-height: 90vh !important;
    }
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */

.layout-transition {
    transition: all 0.3s ease;
}

.layout-no-transition {
    transition: none !important;
}
