/* ===================================
   LAYOUT STRUCTURE — BloxUI Studio
   FILE: css/layout.css
   ROLE: Header, activity bar, sidebar, inspector, resizers, view shells, View menu, Settings
   RELATED JS: js/layout.js toggles .closed / .collapsed / .active
   =================================== */

/* ========== HEADER ========== */
header {
    height: 50px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
    z-index: 100;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-area img {
    height: 40px;
    width: 40px;
    padding: 3px;
    object-fit: contain;
    margin-left: -13px;
}

.logo-area h1 {
    font-size: 16px;
    font-weight: 700;
    margin-right: 15px;
    letter-spacing: 0.3px;
}

.menu {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--text-muted);
    font-size: 13px;
}

.menu span,
.menu .menu-label {
    cursor: pointer;
    transition: 0.2s;
}

.menu span:hover,
.menu .menu-label:hover,
.menu-item.open .menu-label {
    color: var(--text-main);
}

.menu-item {
    position: relative;
}

.menu-label {
    outline: none;
}

.menu-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 180px;
    padding: 6px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
    z-index: 200;
}

.menu-item.open .menu-dropdown,
.menu-item:hover .menu-dropdown {
    display: block;
}

.menu-action {
    display: block;
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text-main);
    font: inherit;
    text-align: left;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
}

.menu-action:hover {
    background: rgba(255, 255, 255, 0.06);
}

#view-menu {
    min-width: 320px;
}

.menu-check {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.menu-check .check-slot {
    width: 14px;
    flex-shrink: 0;
    color: var(--blue-roblox);
    font-weight: 700;
    text-align: center;
}

.menu-check:not(.is-checked) {
    color: var(--text-muted);
}

.header-pill {
    background: #282c37;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid #383e4d;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.avatar {
    width: 28px;
    height: 28px;
    background: #fff;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
}

/* ========== APP BODY ========== */
.app-body {
    display: flex;
    flex: 1;
    height: calc(100vh - 50px);
    overflow: hidden;
}

/* ========== ACTIVITY BAR (LEFTMOST) ========== */
.activity-bar {
    width: 56px;
    background: var(--bg-activity);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 0;
    gap: 14px;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
}

.activity-icon {
    color: var(--text-muted);
    cursor: pointer;
    padding: 9px;
    border-radius: 8px;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.activity-icon:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.06);
}

.activity-icon.active {
    color: var(--blue-roblox);
    background: rgba(41, 121, 255, 0.12);
}

.activity-icon svg {
    width: 22px !important;
    height: 22px !important;
    stroke-width: 1.7;
}

.activity-spacer {
    margin-top: auto;
}

/* ========== VIEW CONTAINERS ========== */
.view {
    display: none;
    flex: 1;
    height: 100%;
    overflow: hidden;
}

.view.active {
    display: flex;
}

/* ========== SETTINGS VIEW (PREFERENCES) ========== */
#settings-view {
    flex-direction: row;
    background: var(--bg-main);
}

.settings-nav {
    width: 250px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

.settings-nav-header {
    font-size: 16px;
    font-weight: 700;
    padding: 0 12px 14px;
    color: var(--text-main);
}

.settings-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    text-align: left;
    transition: 0.15s;
}

.settings-nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
}

.settings-nav-item.active {
    color: var(--blue-roblox);
    background: rgba(41, 121, 255, 0.12);
    font-weight: 600;
}

.settings-nav-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke-width: 2;
}

.settings-content-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 32px 48px;
}

.settings-content {
    max-width: 680px;
}

.settings-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
}

.settings-page-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text-main);
}

.btn-back {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
}

.btn-back:hover {
    background: rgba(255, 255, 255, 0.06);
}

.btn-back svg {
    width: 14px;
    height: 14px;
}

/* ========== SIDEBAR & INSPECTOR PANELS ========== */
.sidebar,
.inspector {
    width: 280px;
    min-width: 0;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    transition: width 0.18s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.18s ease;
}

.sidebar {
    order: 1;
}

.resize-grip.grip-left {
    order: 2;
}

.canvas-area {
    order: 3;
}

.resize-grip.grip-right {
    order: 4;
}

.inspector {
    order: 5;
    border-right: none;
    border-left: 1px solid var(--border);
}

/* When a whole side panel is hidden (Figma-like auto-hide) */
.sidebar.closed,
.inspector.closed {
    width: 0 !important;
    flex-basis: 0 !important;
    min-width: 0 !important;
    opacity: 0;
    border: none;
    pointer-events: none;
    overflow: hidden;
}

/* Disable transitions while actively dragging the resize handle */
body.is-resizing,
body.is-resizing * {
    user-select: none !important;
    -webkit-user-select: none !important;
}

body.is-resizing .sidebar,
body.is-resizing .inspector {
    transition: none !important;
}

/* ========== RESIZE GRIPS (FIGMA-STYLE RESIZING) ========== */
.resize-grip {
    width: 6px;
    margin: 0 -3px;
    z-index: 45;
    cursor: col-resize;
    background: transparent;
    transition: background 0.15s ease;
    flex-shrink: 0;
    position: relative;
}

.resize-grip::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 2px;
    width: 2px;
    background: transparent;
    transition: background 0.15s ease;
}

.resize-grip:hover::after,
.resize-grip.resizing::after {
    background: var(--blue-roblox, #2979ff);
}

.sidebar.closed + #grip-sidebar,
.sidebar.closed ~ #grip-sidebar,
#grip-sidebar.closed,
#grip-inspector.closed,
#editor-view.no-sidebar #grip-sidebar,
#editor-view.no-inspector #grip-inspector {
    display: none !important;
}

/* ========== COLLAPSIBLE PANEL SECTIONS ========== */
.panel-section {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    min-height: 0;
}

/* 'grow' sections expand to fill remaining vertical space */
.panel-section.grow {
    flex: 1 1 auto;
    min-height: 0;
}

.panel-section.grow.collapsed {
    flex: 0 0 auto !important;
}

/* When Components is collapsed, Layers expands to take all leftover height */
.panel-section.grow.expanded {
    flex: 1 1 auto !important;
}

.section-body {
    min-height: 0;
    overflow: hidden;
}

.section-body .components-grid {
    flex-shrink: 1;
}

.section-body.fill {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Collapsed section: content hidden, only header remains */
.panel-section.collapsed .section-body {
    display: none !important;
}

.panel-section.collapsed > .panel-header .panel-collapse-icon {
    transform: rotate(-90deg);
}

/* Header row: title on the left, action icons on the right */
.panel-header {
    padding: 12px 15px;
    font-size: 11px;
    font-weight: bold;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    user-select: none;
}

.panel-header > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1;
}

.panel-header.collapsible {
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.panel-header.collapsible:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
}

.panel-collapse-icon {
    width: 14px;
    height: 14px;
    stroke-width: 2;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}
