/**
 * App Shell — navy menu down the left, navy top bar, warm screen.
 * Mirrors the website's "App Frame" design (prmsolutions/proton-website,
 * src/components/sections/app-chrome.tsx) so the product looks like the
 * product mock-ups on the site. Built on css/tokens.css.
 */

/* ======================================================================
   Sidebar
   ====================================================================== */

.sidebar {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: var(--sidebar-width);
    height: 100%;
    color: rgb(var(--on-ink-soft));
    background: rgb(var(--ink));
    transition: width var(--duration-base) var(--ease-out);
    z-index: 40;
}

/* The logo cell sits level with the top bar, divided from it like the site's frame */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    height: var(--topbar-height);
    padding: 0 12px 0 14px;
    flex-shrink: 0;
    border-right: 1px solid rgb(255 255 255 / 0.08);
    border-bottom: 1px solid rgb(255 255 255 / 0.08);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    text-decoration: none;
    color: var(--text-inverse);
}

.sidebar-logo {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.sidebar-brand-name {
    font-size: var(--text-lg);
    font-weight: var(--weight-bold);
    letter-spacing: var(--tracking-tighter);
    white-space: nowrap;
}

.sidebar-brand-iq {
    color: var(--signal);
}

.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: rgb(255 255 255 / 0.7);
    background: none;
    border: 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.sidebar-collapse-btn:hover {
    color: var(--text-inverse);
    background: rgb(255 255 255 / 0.1);
}

.sidebar-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 10px 10px 12px;
    scrollbar-color: rgb(255 255 255 / 0.15) transparent;
}

.nav-section + .nav-section {
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px solid rgb(255 255 255 / 0.1);
}

/* "AI & AUTOMATION" style section labels */
.nav-section-title {
    padding: 0 9px 6px;
    font-size: 10px;
    font-weight: var(--weight-bold);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgb(var(--on-ink-faint));
    white-space: nowrap;
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 34px;
    padding: 0 7px;
    margin: 2px 0;
    font-size: var(--text-md);
    font-weight: var(--weight-medium);
    color: rgb(var(--on-ink-soft));
    text-decoration: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    transition: background-color var(--duration-fast), color var(--duration-fast);
}

/* The icon tile: white/10 at rest, lime with an ink glyph when active */
.nav-item-icon {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    color: var(--text-inverse);
    background: rgb(255 255 255 / 0.1);
    border-radius: var(--radius-xs);
    transition: background-color var(--duration-fast), color var(--duration-fast);
}

.nav-item-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-item:hover {
    color: var(--text-inverse);
    background: rgb(255 255 255 / 0.06);
}

.nav-item.active {
    font-weight: var(--weight-bold);
    color: var(--text-inverse);
    background: rgb(255 255 255 / 0.12);
}

.nav-item.active .nav-item-icon {
    color: rgb(var(--ink));
    background: var(--signal);
}

.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: var(--text-2xs);
    font-weight: var(--weight-bold);
    color: rgb(var(--ink));
    background: var(--signal);
    border-radius: var(--radius-full);
}

.sidebar-footer {
    flex-shrink: 0;
    padding: 8px 10px 12px;
    border-top: 1px solid rgb(255 255 255 / 0.1);
}

/* Collapsed (icon rail) */
.sidebar-collapsed .sidebar {
    width: var(--sidebar-width-collapsed);
}

.sidebar-collapsed .sidebar-header {
    justify-content: center;
    padding: 0;
}

.sidebar-collapsed .sidebar-brand,
.sidebar-collapsed .nav-item-text,
.sidebar-collapsed .nav-section-title {
    display: none;
}

.sidebar-collapsed .sidebar-collapse-btn svg {
    transform: scaleX(-1);
}

.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 0;
}

.sidebar-collapsed .nav-badge {
    position: absolute;
    top: 0;
    right: 2px;
    min-width: 14px;
    height: 14px;
    padding: 0 3px;
    font-size: 9px;
}

/* Label beside a hovered/focused icon in the collapsed rail (AppShell) */
.nav-hover-label {
    position: fixed;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 28px;
    padding: 0 12px;
    font-size: var(--text-sm);
    font-weight: var(--weight-bold);
    color: rgb(var(--ink));
    white-space: nowrap;
    background: var(--bg-surface);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
    transform: translate(-4px, -50%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--duration-fast), transform var(--duration-fast), visibility var(--duration-fast);
}

.nav-hover-label.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translate(0, -50%);
}

.nav-hover-label .nav-badge {
    position: static;
}

/* ======================================================================
   Main frame + top bar
   ====================================================================== */

.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-canvas);
}

.top-bar {
    position: relative;
    z-index: 60; /* Above fullscreen chat (50) and calendar panel (30) */
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
    height: var(--topbar-height);
    padding: 0 16px 0 20px;
    color: rgb(var(--on-ink));
    background: rgb(var(--ink));
    border-bottom: 1px solid rgb(255 255 255 / 0.08);
}

/* Search pill (white/14 on navy) */
.top-bar-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    max-width: 440px;
}

.top-bar-search-icon {
    position: absolute;
    left: 13px;
    display: flex;
    color: rgb(var(--on-ink));
    pointer-events: none;
}

.top-bar-search {
    width: 100%;
    height: 34px;
    padding: 0 56px 0 34px;
    font-family: inherit;
    font-size: var(--text-md);
    color: var(--text-inverse);
    background: rgb(255 255 255 / 0.14);
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    transition: background-color var(--duration-fast), border-color var(--duration-fast), box-shadow var(--duration-fast);
}

.top-bar-search::placeholder {
    color: rgb(var(--on-ink));
}

.top-bar-search:hover {
    background: rgb(255 255 255 / 0.18);
}

.top-bar-search:focus {
    outline: none;
    background: rgb(255 255 255 / 0.2);
    border-color: rgb(255 255 255 / 0.35);
    box-shadow: 0 0 0 3px rgb(var(--lime-500) / 0.35);
}

.top-bar-search-kbd {
    position: absolute;
    right: 12px;
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: rgb(var(--on-ink-faint));
    pointer-events: none;
}

.top-bar-search:focus ~ .top-bar-search-kbd {
    opacity: 0;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    gap: 10px;
}

.top-bar-icon-btn {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    color: rgb(var(--on-ink-soft));
    background: none;
    border: 0;
    border-radius: var(--radius-full);
    cursor: pointer;
}

.top-bar-icon-btn:hover {
    color: var(--text-inverse);
    background: rgb(255 255 255 / 0.1);
}

/* White "+ Create" pill */
.top-bar-create {
    display: inline-flex;
    align-items: center;
    height: 30px;
    padding: 0 14px;
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: var(--weight-bold);
    color: rgb(var(--ink));
    background: var(--bg-surface);
    border: 0;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background-color var(--duration-fast);
}

.top-bar-create:hover {
    background: var(--signal);
}

.top-bar-avatar {
    display: flex;
    padding: 0;
    background: none;
    border: 0;
    border-radius: var(--radius-full);
    cursor: pointer;
}

.top-bar-avatar .avatar {
    width: 30px;
    height: 30px;
    font-size: var(--text-xs);
    color: rgb(var(--ink));
    background: rgb(var(--blue-100));
    box-shadow: 0 0 0 2px rgb(255 255 255 / 0.15);
}

.top-bar-avatar:hover .avatar,
.top-bar-avatar[aria-expanded="true"] .avatar {
    box-shadow: 0 0 0 2px var(--signal);
}

.account-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 240px;
    z-index: 100;
}

.account-menu-header {
    padding: 8px 10px 6px;
}

.account-menu-name {
    font-size: var(--text-md);
    font-weight: var(--weight-bold);
    color: var(--text-primary);
}

.account-menu-email {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ======================================================================
   Search dropdown (anchored under the top-bar search)
   ====================================================================== */

.search-results-dropdown {
    border: 0 !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-xl) !important;
}
