/*
 * Founder-approved Atlas UI v1 application shell.
 *
 * Structural values and breakpoints follow UI_REFERENCE/src/styles/shell.css.
 * Legacy class names remain alongside the canonical atlas-* hooks so existing
 * server-rendered pages can migrate without parallel templates.
 */

.atlas-app {
    min-height: 100vh;
    padding: var(--atlas-frame-margin);
    background: var(--atlas-color-canvas);
}

.atlas-app__frame {
    display: grid;
    grid-template-columns: var(--atlas-sidebar-width) minmax(0, 1fr);
    width: min(100%, var(--atlas-frame-max));
    min-height: calc(100vh - (2 * var(--atlas-frame-margin)));
    margin-inline: auto;
    overflow: clip;
    border: var(--atlas-border-width) solid var(--atlas-color-border);
    border-radius: var(--atlas-radius-xl);
    background: var(--atlas-color-frame);
    box-shadow: var(--atlas-shadow-frame);
}

.atlas-app__sidebar {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    border-right: var(--atlas-border-width) solid var(--atlas-color-divider);
    background: var(--atlas-color-surface);
}

.app-frame {
    display: grid;
    grid-column: 2;
    grid-row: 1;
    grid-template-rows: var(--atlas-header-height) minmax(0, 1fr);
    min-width: 0;
    min-height: 0;
    background: var(--atlas-color-frame);
}

.atlas-app__header {
    position: relative;
    z-index: 20;
    grid-row: 1;
    min-width: 0;
    border-bottom: var(--atlas-border-width) solid var(--atlas-color-divider);
    background: var(--atlas-color-surface);
}

.atlas-app__main {
    grid-row: 2;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    background: var(--atlas-color-frame);
    scrollbar-gutter: stable;
}

.atlas-app__content {
    width: min(100%, var(--atlas-content-max));
    margin-inline: auto;
    padding: var(--atlas-space-10) var(--atlas-page-gutter) var(--atlas-space-16);
}

.atlas-app__mobile-navigation,
.mobile-navigation {
    display: none;
}

.mobile-navigation:not(:has(li)) {
    display: none !important;
}

.atlas-sidebar {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    padding: var(--atlas-space-5) var(--atlas-space-3) var(--atlas-space-4);
}

.atlas-sidebar__brand {
    display: flex;
    align-items: center;
    min-height: var(--atlas-touch-target);
    padding-inline: var(--atlas-space-3);
    color: var(--atlas-color-text-strong);
    text-decoration: none;
}

.atlas-sidebar__brand-mark {
    display: inline-grid;
    width: var(--atlas-space-8);
    height: var(--atlas-space-8);
    flex: 0 0 auto;
    place-items: center;
    fill: currentColor;
}

.atlas-sidebar__wordmark {
    margin-left: var(--atlas-space-2);
    font-size: var(--atlas-font-size-14);
    font-weight: var(--atlas-font-weight-bold);
    letter-spacing: var(--atlas-letter-spacing-wordmark);
    line-height: 1;
}

.atlas-sidebar__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    padding-top: var(--atlas-space-8);
}

.atlas-sidebar__list {
    display: grid;
    gap: var(--atlas-space-1);
    margin: 0;
    padding: 0;
    list-style: none;
}

.atlas-sidebar__link {
    display: flex;
    align-items: center;
    gap: var(--atlas-space-3);
    min-height: var(--atlas-touch-target);
    padding: var(--atlas-space-2) var(--atlas-space-3);
    border-radius: var(--atlas-radius-sm);
    color: var(--atlas-color-text-secondary);
    font-size: var(--atlas-font-size-13);
    font-weight: var(--atlas-font-weight-medium);
    line-height: var(--atlas-line-height-heading);
    text-decoration: none;
}

.atlas-sidebar__link:hover {
    background: var(--atlas-color-surface-subtle);
    color: var(--atlas-color-text-strong);
}

.atlas-sidebar__link[aria-current="page"] {
    background: var(--atlas-color-surface-selected);
    color: var(--atlas-color-text-strong);
    font-weight: var(--atlas-font-weight-semibold);
}

.primary-navigation a::before,
.sidebar-account :is(a, button)::before {
    display: none;
    content: none;
}

.atlas-icon,
.header-icon-link svg {
    display: block;
    width: var(--atlas-space-5);
    height: var(--atlas-space-5);
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.7;
}

.atlas-sidebar__brand-mark {
    fill: currentColor;
    stroke: none;
}

.primary-navigation__utilities {
    margin-top: var(--atlas-space-7) !important;
    padding-top: var(--atlas-space-5) !important;
    border-top: var(--atlas-border-width) solid var(--atlas-color-divider);
}

.desktop-sidebar:has(.sidebar-account)
    :is(
        .primary-navigation__item--search,
        .primary-navigation__item--account,
        .primary-navigation__item--billing
    ) {
    display: none;
}

.sidebar-account {
    margin-top: auto;
    padding-top: var(--atlas-space-4);
}

.sidebar-account form {
    margin: 0;
}

.sidebar-account .atlas-sidebar__link {
    width: 100%;
    border: 0;
    background: transparent;
    font-family: inherit;
    text-align: left;
}

.beta-label {
    margin: auto var(--atlas-space-3) 0;
    color: var(--atlas-color-text-muted);
    font-size: var(--atlas-font-size-12);
}

.atlas-global-header {
    display: grid;
    grid-template-columns: minmax(12rem, 24rem) auto;
    align-items: center;
    justify-content: space-between;
    gap: var(--atlas-space-6);
    height: 100%;
    padding-inline: var(--atlas-page-gutter);
}

.mobile-brand {
    display: none;
}

.atlas-global-header__search {
    position: relative;
    min-width: 0;
    margin: 0;
}

.app-header-search span {
    position: absolute;
    top: 50%;
    left: var(--atlas-space-3);
    width: var(--atlas-space-3);
    height: var(--atlas-space-3);
    border: var(--atlas-border-width) solid var(--atlas-color-text-muted);
    border-radius: var(--atlas-radius-pill);
    transform: translateY(-58%);
}

.app-header-search span::after {
    position: absolute;
    right: -0.3rem;
    bottom: -0.2rem;
    width: 0.35rem;
    height: var(--atlas-border-width);
    background: var(--atlas-color-text-muted);
    content: "";
    transform: rotate(45deg);
}

.app-header-search input {
    width: 100%;
    min-height: var(--atlas-touch-target);
    padding: var(--atlas-space-2) var(--atlas-space-3)
        var(--atlas-space-2) var(--atlas-space-8);
    border: var(--atlas-border-width) solid var(--atlas-color-border);
    border-radius: var(--atlas-radius-sm);
    background: var(--atlas-color-surface-subtle);
    color: var(--atlas-color-text);
    font-size: var(--atlas-font-size-13);
}

.atlas-global-header__actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--atlas-space-1);
}

.header-icon-link,
.atlas-global-header__account {
    display: inline-grid;
    width: var(--atlas-touch-target);
    min-width: var(--atlas-touch-target);
    min-height: var(--atlas-touch-target);
    place-items: center;
    border-radius: var(--atlas-radius-pill);
    color: var(--atlas-color-icon);
    text-decoration: none;
}

.header-icon-link:hover {
    background: var(--atlas-color-surface-subtle);
}

.atlas-global-header__account {
    margin-left: var(--atlas-space-1);
    background: var(--atlas-color-surface-selected);
    color: var(--atlas-color-text-strong);
    font-size: var(--atlas-font-size-12);
    font-weight: var(--atlas-font-weight-semibold);
}

.atlas-footer {
    display: none;
}

@media (max-width: 79.999rem) {
    .atlas-app__frame {
        --atlas-sidebar-width: 13rem;
    }

    .atlas-global-header {
        grid-template-columns: minmax(10rem, 22rem) auto;
    }
}

@media (max-width: 63.999rem) {
    .atlas-app {
        min-height: 100dvh;
        padding: 0;
    }

    .atlas-app__frame {
        display: block;
        width: 100%;
        min-height: 100dvh;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .atlas-app__sidebar {
        display: none;
    }

    .app-frame {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: var(--atlas-header-height) minmax(0, 1fr) auto;
        min-height: 100dvh;
    }

    .atlas-app__header {
        position: sticky;
        top: 0;
        grid-column: 1;
        grid-row: 1;
    }

    .atlas-app__main {
        grid-column: 1;
        grid-row: 2;
        overflow: visible;
    }

    .atlas-app__content {
        padding-top: var(--atlas-space-8);
        padding-bottom: var(--atlas-space-12);
    }

    .atlas-app__mobile-navigation,
    .mobile-navigation {
        position: sticky;
        z-index: 30;
        bottom: 0;
        display: block;
        grid-column: 1;
        grid-row: 3;
        padding-bottom: env(safe-area-inset-bottom);
        border-top: var(--atlas-border-width) solid var(--atlas-color-divider);
        background: var(--atlas-color-surface);
    }

    .atlas-mobile-navigation__list {
        display: grid;
        grid-template-columns: repeat(6, minmax(0, 1fr));
        margin: 0;
        padding: var(--atlas-space-1) var(--atlas-space-2);
        list-style: none;
    }

    .atlas-mobile-navigation__link {
        display: flex;
        min-height: 3.5rem;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: var(--atlas-space-1);
        padding: var(--atlas-space-1);
        border-radius: var(--atlas-radius-sm);
        color: var(--atlas-color-text-muted);
        font-size: var(--atlas-font-size-11);
        line-height: 1.15;
        text-align: center;
        text-decoration: none;
    }

    .atlas-mobile-navigation__link[aria-current="page"] {
        background: var(--atlas-color-surface-selected);
        color: var(--atlas-color-text-strong);
        font-weight: var(--atlas-font-weight-semibold);
    }

    .atlas-global-header {
        grid-template-columns: auto minmax(0, 1fr) auto;
        padding-inline: var(--atlas-space-4);
    }

    .atlas-global-header__search,
    .atlas-global-header__actions {
        order: initial;
        width: auto;
    }

    .mobile-brand {
        display: inline-flex;
        min-height: var(--atlas-touch-target);
        align-items: center;
        color: var(--atlas-color-text-strong);
        text-decoration: none;
    }
}

@media (max-width: 47.999rem) {
    .atlas-app__content {
        padding-inline: var(--atlas-space-4);
    }

    .atlas-global-header {
        gap: var(--atlas-space-2);
    }

    .header-icon-link {
        display: none;
    }

    .mobile-brand .brand-name {
        display: none;
    }
}

@media (max-width: 29.999rem) {
    .atlas-app__content {
        padding-top: var(--atlas-space-6);
        padding-inline: var(--atlas-space-3);
    }

    .atlas-mobile-navigation__list {
        padding-inline: 0;
    }

    .atlas-mobile-navigation__link {
        font-size: var(--atlas-font-size-11);
    }
}

@media print {
    .atlas-app,
    .atlas-app__frame,
    .atlas-app__main {
        display: block;
        min-height: auto;
        padding: 0;
        overflow: visible;
        border: 0;
        background: var(--atlas-color-surface);
        box-shadow: none;
    }

    .atlas-app__sidebar,
    .atlas-app__header,
    .atlas-app__mobile-navigation {
        display: none;
    }
}
