/*
 * Local overrides for central-ui.css — Figma-aligned spacing and layout.
 * Loaded AFTER central-ui.css so these take precedence.
 * central-ui.css is imported from an external source and should not be edited.
 */

/* ── Layout ────────────────────────────────────────────────── */

/* Allow horizontal scrolling when viewport is narrower than min-width */
.app-layout {
    overflow-x: auto;
    overflow-y: hidden;
}

/* ── Body layout ────────────────────────────────────────────── */

.app-body {
    display: flex;
    flex-direction: row;
    flex: 1;
    min-height: 0;
    height: auto;
    gap: 10px;
    padding: 10px;
}

/* ── Content area ───────────────────────────────────────────── */

.app-content {
    border-radius: 10px;
    margin: 0;
    position: relative;
    min-width: 0;
    overflow: auto;
}

.app-content iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.app-content .native-page {
    padding: 1.5rem 2rem;
    height: 100%;
    overflow-y: auto;
    box-sizing: border-box;
    color: var(--app-color-text, #333);
}

.app-content .welcome {
    padding: 2rem;
    color: var(--app-color-text, #333);
}

/* ── Sidebar ────────────────────────────────────────────────── */

.app-sidebar {
    width: 220px;
    padding: 0;
    flex-shrink: 0;
    scrollbar-gutter: stable;
    font-family: var(--app-font-primary, "Geist", sans-serif);
}

/* Bottom-section grouping: appears immediately below the main section
   with a small grey spacer for visual separation, rather than pinned to
   the sidebar bottom. */
.app-sidebar > .app-sidebar-section--bottom {
    margin-top: 12px;
}

.app-sidebar > .app-sidebar-section--bottom ~ .app-sidebar-section--bottom {
    margin-top: 0;
}

/* ── Profile selector (sidebar top) ─────────────────────────── */

.app-project-selector {
    padding: 12px;
}

.app-project-selector-label {
    display: block;
    margin-bottom: 4px;
    font-family: var(--app-font-primary, "Geist", sans-serif);
    font-size: 14px;
    font-weight: 400;
    line-height: 22px;
    color: var(--app-text-primary, rgba(17,24,39,.87));
}

.app-project-selector-select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid hsla(0, 0%, 40%, 0.15);
    border-radius: 8px;
    background-color: var(--app-bg-primary, #fff);
    color: var(--app-text-primary, rgba(17,24,39,.87));
    font-family: var(--app-font-primary, inherit);
    font-size: 14px;
    font-weight: 500;
    line-height: 22px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 8L10 12L14 8' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    box-sizing: border-box;
    transition: border-color 0.2s ease;
}

.app-project-selector-select:hover {
    border-color: hsla(0, 0%, 40%, 0.3);
}

.app-project-selector-select:focus-visible {
    outline: 2px solid var(--app-focus-ring, rgba(20,27,155,.6));
    outline-offset: -2px;
}

/* ── Menu items ─────────────────────────────────────────────── */

/* Single-item menu groups (div, not details) should not show the
   gray expanded-group background that central-ui.css applies. */
div.app-menu-group {
    background-color: transparent;
}

/* Make single-item menu links match group header layout */
.app-menu-group > a.app-menu-item {
    display: flex;
    width: 100%;
    box-sizing: border-box;
    border-radius: 8px;
}

/* details/summary overrides for server-rendered menu groups */
details.app-menu-group {
    border-radius: 8px;
    overflow: hidden;
}

details.app-menu-group > summary.app-menu-group-parent {
    list-style: none;
    display: flex;
    box-sizing: border-box;
}

details.app-menu-group > summary.app-menu-group-parent::-webkit-details-marker {
    display: none;
}

details.app-menu-group > .app-menu-group-items {
    max-height: none;
}

details.app-menu-group > summary .app-menu-dropdown-icon {
    transition: transform 0.2s ease;
}

details[open].app-menu-group > summary .app-menu-dropdown-icon {
    transform: rotate(180deg);
}

/* ── Sidebar toggle button ─────────────────────────────────── */

/* Hidden by default. Only shown in the small-screen overlay mode
   (see @media (max-width: 768px) below) where it acts as the
   show/hide hamburger for the off-canvas sidebar. */
.app-sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    margin: 4px 4px 0;
    border: none;
    border-radius: var(--app-radius-md, 8px);
    background: transparent;
    color: var(--app-icon-primary, rgba(17,24,39,.57));
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.15s ease;
}

.app-sidebar-toggle:hover {
    background-color: var(--app-bg-hover, #f5f5f5);
}

.app-sidebar-toggle svg {
    width: 20px;
    height: 20px;
}

/* ── Header hamburger (injected by header-collapse.js) ─────── */

.app-header-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    margin-left: auto;
    border: none;
    border-radius: var(--app-radius-md, 8px);
    background: transparent;
    color: var(--app-icon-primary, rgba(17,24,39,.57));
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.15s ease;
}

.app-header-menu-btn:hover {
    background-color: var(--app-bg-hover, #f5f5f5);
}

.app-header-menu-btn svg {
    width: 20px;
    height: 20px;
}

.app-header-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 200px;
    background: var(--app-bg-primary, #fff);
    border: 1px solid hsla(0, 0%, 40%, 0.15);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 4px;
    z-index: 1000;
    flex-direction: column;
    gap: 2px;
}

.app-header-dropdown.open {
    display: flex;
}

.app-header-dropdown a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--app-text-primary, rgba(17,24,39,.87));
    text-decoration: none;
    font-family: var(--app-font-primary, "Geist", sans-serif);
    font-size: 14px;
    font-weight: 500;
    line-height: 22px;
    transition: background-color 0.15s ease;
    white-space: nowrap;
}

.app-header-dropdown a:hover {
    background-color: var(--app-bg-hover, #f5f5f5);
}

.app-header-dropdown a .app-nav-menu__icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.app-header-dropdown-sep {
    height: 1px;
    margin: 4px 12px;
    background: hsla(0, 0%, 40%, 0.15);
}

/* ── Sidebar overlay backdrop ──────────────────────────────── */

.app-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 999;
}

.app-sidebar-backdrop.visible {
    display: block;
}

/* ── Auto-collapse on small screens ────────────────────────── */

@media (max-width: 768px) {
    /* Header: hide original nav, show hamburger */
    .app-header__nav,
    .app-header__right {
        display: none !important;
    }

    .app-header__left {
        gap: 0 !important;
    }

    .app-header-menu-btn {
        display: flex;
    }

    .app-header,
    #app-header {
        position: relative;
    }

    /* Tighten body padding */
    .app-body {
        gap: 4px;
        padding: 4px;
    }

    /* Sidebar: completely hidden, zero space */
    .app-sidebar {
        display: none;
    }

    /* Floating hamburger pinned to top-left of the body area */
    .app-sidebar-toggle {
        display: flex;
        position: fixed;
        top: 10px;
        left: 10px;
        z-index: 1001;
        background: var(--app-bg-primary, #fff);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    }

    /* Expanded: full sidebar as overlay below top bar */
    .app-sidebar.expanded {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 260px;
        z-index: 1000;
        background: var(--app-bg-secondary, #f9f9f9);
        padding: 48px 12px 12px;
        overflow-y: auto;
        box-shadow: 4px 0 16px rgba(0, 0, 0, 0.15);
    }

    .app-sidebar.expanded .app-sidebar-section {
        display: flex;
    }
}
