/* ============================================================
   Smart Board — Layout & Sidebar Module
   Covers: workspace-layout-container, sidebar, mobile header
   ============================================================ */

/* ── Panel Hosts ──────────────────────────────────────────── */
#panel-workspace,
#panel-connectors {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    padding: 0;
}

#panel-connectors.tab-panel-inner {
    padding: 0;
}

/* ── Workspace Layout ─────────────────────────────────────── */
.workspace-layout-container {
    display: flex;
    flex: 1;
    height: 100%;
    width: 100%;
    min-width: 0;
    /* Prevents flex children from stretching past viewport */
    overflow: hidden;
    position: relative;
    background: var(--bg-primary);
}

/* ── Sidebar ──────────────────────────────────────────────── */
.workspace-sidebar {
    width: 250px;
    background: var(--surface-1);
    border-left: 1px solid var(--border-light, var(--surface-border));
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    flex-shrink: 0;
}

/* Desktop collapsed state */
@media (min-width: 769px) {
    .workspace-sidebar.desktop-closed {
        width: 0;
        border-left: none;
        overflow: hidden;
    }

    html[dir="ltr"] .workspace-sidebar.desktop-closed {
        border-right: none;
    }
}

html[dir="ltr"] .workspace-sidebar {
    border-left: none;
    border-right: 1px solid var(--border-light, var(--surface-border));
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.sidebar-title {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-item {
    display: flex !important;
    align-items: center !important;
    flex-direction: row !important;
    gap: 12px !important;
    padding: 10px 12px !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    transition: background 0.2s, color 0.2s !important;
    color: var(--text-2) !important;
    font-size: 0.95rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    width: 100% !important;
    box-sizing: border-box !important;
    line-height: normal !important;
}

.sidebar-item:hover {
    background: var(--bg-glass-hover) !important;
    color: var(--text-1) !important;
}

.sidebar-item.active {
    background: rgba(99, 102, 241, 0.1) !important;
    color: var(--primary-color) !important;
    font-weight: 500 !important;
}

.sidebar-item-icon {
    font-size: 1.1rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 20px !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.sidebar-item span {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    flex: 1 !important;
    min-width: 0 !important;
    white-space: nowrap !important;
    text-align: right !important;
}

html[dir="ltr"] .sidebar-item span {
    text-align: left !important;
}

.sidebar-divider {
    height: 1px;
    background: var(--surface-border, rgba(255,255,255,0.08));
    margin: 6px 12px;
}

/* ── Main Canvas Area ─────────────────────────────────────── */
.workspace-main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
    min-width: 0;
    min-height: 0;
}

.sidebar-toggle-btn {
    display: none;
    background: var(--surface-1);
    border: 1px solid var(--border-light, var(--surface-border));
    color: var(--text-1);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.sidebar-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-close-btn {
    background: none;
    border: none;
    color: var(--text-2);
    font-size: 1.2rem;
    cursor: pointer;
    display: none;
    padding: 4px;
}

/* ── Mobile Sticky Header ─────────────────────────────────── */
.workspace-mobile-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--surface-1);
    border-bottom: 1px solid var(--border-light, var(--surface-border));
    flex-shrink: 0;
    z-index: 5;
}

.workspace-mobile-title-row,
.workspace-mobile-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.workspace-mobile-title {
    font-size: 1.1rem;
    margin: 0;
    font-weight: 700;
}

.mobile-header-icon-btn {
    background: var(--surface-1);
    padding: 6px;
    border-radius: 6px;
    border: 1px solid var(--border-light, var(--surface-border));
    color: var(--text-1);
    display: flex;
}

/* ── Mobile / Tablet Responsive ───────────────────────────── */
@media (max-width: 899px) {
    .workspace-sidebar {
        position: absolute;
        top: 0;
        bottom: 0;
        right: 0;
        transform: translateX(100%);
        box-shadow: -5px 0 25px rgba(0, 0, 0, 0.5);
    }

    .workspace-sidebar.open {
        transform: translateX(0);
    }

    html[dir="ltr"] .workspace-sidebar {
        right: auto;
        left: 0;
        transform: translateX(-100%);
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.5);
    }

    html[dir="ltr"] .workspace-sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle-btn {
        display: flex;
    }

    .sidebar-close-btn {
        display: block;
    }

    .workspace-mobile-header {
        display: flex;
    }
}

/* ── Override Old Header ──────────────────────────────────── */
.panel-header.workspace-header {
    display: none !important;
}
