/*
 * AI Assurance Application Shell
 */

.app-shell {
    display: grid;
    grid-template-columns: var(--app-sidebar-width) minmax(0, 1fr);
    width: 100%;
    min-height: 100vh;
    background: var(--app-bg);
    transition: grid-template-columns var(--app-transition);
}

.app-shell[data-sidebar-state="collapsed"] {
    grid-template-columns: var(--app-sidebar-collapsed-width) minmax(0, 1fr);
}

.app-sidebar {
    position: sticky;
    top: 0;
    z-index: 1200;
    display: flex;
    width: 100%;
    height: 100vh;
    min-width: 0;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid var(--app-sidebar-border);
    background:
        radial-gradient(circle at 20% 0%, rgba(37, 99, 235, .16), transparent 36%),
        linear-gradient(180deg, var(--app-sidebar-bg-alt), var(--app-sidebar-bg));
    color: var(--app-sidebar-text);
}

.sidebar-header {
    display: flex;
    min-height: 82px;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: 1rem 1rem 1rem 1.1rem;
    border-bottom: 1px solid var(--app-sidebar-border);
}

.sidebar-brand {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: .75rem;
    color: #ffffff;
}

.sidebar-brand:hover {
    color: #ffffff;
}

.brand-mark {
    display: inline-flex;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 13px;
    background:
        linear-gradient(135deg, #2f7df7, #19b8d7);
    box-shadow: 0 10px 24px rgba(20, 110, 230, .26);
    font-size: .95rem;
    font-weight: 850;
    letter-spacing: -.03em;
}

.brand-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.brand-copy strong {
    overflow: hidden;
    color: #ffffff;
    font-size: .98rem;
    letter-spacing: -.02em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-copy small {
    color: var(--app-sidebar-muted);
    font-size: .7rem;
    font-weight: 650;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.sidebar-collapse-button {
    display: inline-flex;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 10px;
    background: rgba(255, 255, 255, .05);
    color: #dce7f7;
    cursor: pointer;
}

.sidebar-collapse-button:hover {
    background: rgba(255, 255, 255, .1);
}

.sidebar-context-card {
    display: flex;
    align-items: center;
    gap: .7rem;
    margin: .9rem 1rem .35rem;
    padding: .85rem .9rem;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 14px;
    background: rgba(255, 255, 255, .035);
}

.context-status {
    display: inline-flex;
    width: 26px;
    height: 26px;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 9px;
    background: rgba(17, 207, 139, .12);
}

.context-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #17d894;
    box-shadow: 0 0 0 4px rgba(23, 216, 148, .12);
}

.context-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.context-copy span {
    color: var(--app-sidebar-muted);
    font-size: .62rem;
    font-weight: 800;
    letter-spacing: .11em;
    text-transform: uppercase;
}

.context-copy strong {
    overflow: hidden;
    color: #ffffff;
    font-size: .8rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-nav {
    min-height: 0;
    flex: 1 1 auto;
    overflow-x: hidden;
    overflow-y: auto;
    padding: .5rem .75rem 1rem;
    scrollbar-color: rgba(255, 255, 255, .28) transparent;
    scrollbar-width: thin;
}

.sidebar-nav::-webkit-scrollbar {
    width: 7px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    border-radius: 20px;
    background: rgba(255, 255, 255, .2);
}

.sidebar-nav-group {
    margin-top: 1.25rem;
}

.sidebar-section-title {
    margin: 0 0 .55rem;
    padding-inline: .8rem;
    color: var(--app-sidebar-muted);
    font-size: .65rem;
    font-weight: 800;
    letter-spacing: .11em;
    text-transform: uppercase;
}

.sidebar-link {
    position: relative;
    display: flex;
    min-height: 43px;
    align-items: center;
    gap: .75rem;
    margin: .15rem 0;
    padding: .64rem .75rem;
    border: 1px solid transparent;
    border-radius: 11px;
    color: var(--app-sidebar-text);
    font-size: .82rem;
    font-weight: 650;
    transition:
        background-color var(--app-transition),
        border-color var(--app-transition),
        color var(--app-transition),
        transform var(--app-transition);
}

.sidebar-link:hover {
    border-color: rgba(255, 255, 255, .07);
    background: rgba(255, 255, 255, .055);
    color: #ffffff;
    transform: translateX(2px);
}

.sidebar-link.is-active {
    border-color: rgba(80, 156, 255, .22);
    background:
        linear-gradient(90deg, rgba(37, 99, 235, .38), rgba(37, 99, 235, .18));
    color: #ffffff;
    box-shadow: inset 3px 0 0 #38c7ee;
}

.nav-icon {
    position: relative;
    display: inline-flex;
    width: 22px;
    height: 22px;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 7px;
    background: rgba(255, 255, 255, .06);
}

.nav-icon::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 2px;
    background: #bac8db;
}

.sidebar-link.is-active .nav-icon::before {
    background: #ffffff;
}

.sidebar-link-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-footer {
    padding: .8rem 1rem 1rem;
    border-top: 1px solid var(--app-sidebar-border);
}

.sidebar-security-chip {
    display: flex;
    align-items: center;
    gap: .55rem;
    color: #c8d5e8;
    font-size: .72rem;
    font-weight: 650;
}

.security-chip-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #31d7a0;
}

.app-main {
    display: flex;
    min-width: 0;
    min-height: 100vh;
    flex-direction: column;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    min-height: var(--app-topbar-height);
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: .95rem 1.75rem;
    border-bottom: 1px solid rgba(197, 208, 223, .75);
    background: rgba(255, 255, 255, .92);
    box-shadow: 0 4px 18px rgba(20, 35, 60, .035);
    backdrop-filter: blur(14px);
}

.topbar-primary {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 1rem;
}

.sidebar-toggle {
    display: none;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    border: 1px solid var(--app-border);
    border-radius: 11px;
    background: #ffffff;
    color: var(--app-text);
    cursor: pointer;
    box-shadow: var(--app-shadow-sm);
}

.sidebar-toggle span {
    width: 18px;
    height: 2px;
    border-radius: 20px;
    background: currentColor;
}

.page-heading {
    min-width: 0;
}

.page-eyebrow {
    display: block;
    margin-bottom: .1rem;
    color: var(--app-primary);
    font-size: .65rem;
    font-weight: 800;
    letter-spacing: .11em;
    text-transform: uppercase;
}

.page-title {
    overflow: hidden;
    margin: 0;
    font-size: clamp(1.15rem, 1.5vw, 1.55rem);
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-subtitle {
    overflow: hidden;
    max-width: 640px;
    margin: .15rem 0 0;
    color: var(--app-text-soft);
    font-size: .78rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-actions {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: flex-end;
    gap: .65rem;
}

.topbar-search {
    position: relative;
    display: flex;
    width: min(380px, 32vw);
    min-width: 240px;
    height: 44px;
    align-items: center;
    gap: .55rem;
    padding: 0 .7rem 0 .85rem;
    border: 1px solid var(--app-border);
    border-radius: 12px;
    background: #ffffff;
    box-shadow: var(--app-shadow-sm);
    transition:
        border-color var(--app-transition),
        box-shadow var(--app-transition);
}

.topbar-search:focus-within {
    border-color: #8fb5f6;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .1);
}

.topbar-search-icon {
    width: 15px;
    height: 15px;
    flex: 0 0 auto;
    border: 2px solid #7b8ba2;
    border-radius: 50%;
}

.topbar-search-icon::after {
    content: "";
    position: absolute;
    width: 6px;
    height: 2px;
    margin: 11px 0 0 -1px;
    transform: rotate(45deg);
    border-radius: 10px;
    background: #7b8ba2;
}

.topbar-search input {
    min-width: 0;
    flex: 1;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--app-text);
    font-size: .82rem;
}

.topbar-search input::placeholder {
    color: #8997aa;
}

.search-shortcut {
    display: inline-flex;
    min-width: 24px;
    height: 24px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--app-border);
    border-radius: 7px;
    background: var(--app-surface-muted);
    color: var(--app-text-muted);
    font-size: .72rem;
    box-shadow: none;
}

.topbar-icon-button {
    position: relative;
    display: inline-flex;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border: 1px solid var(--app-border);
    border-radius: 12px;
    background: #ffffff;
    color: var(--app-text-soft);
    box-shadow: var(--app-shadow-sm);
}

.topbar-icon-button:hover {
    background: var(--app-surface-muted);
    color: var(--app-primary);
}

.topbar-bell {
    position: relative;
    width: 16px;
    height: 17px;
    border: 2px solid currentColor;
    border-top-left-radius: 9px;
    border-top-right-radius: 9px;
    border-bottom: 0;
}

.topbar-bell::after {
    content: "";
    position: absolute;
    left: 4px;
    bottom: -5px;
    width: 6px;
    height: 3px;
    border-radius: 0 0 6px 6px;
    background: currentColor;
}

.notification-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 7px;
    height: 7px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background: #ef476f;
}

.user-menu-button {
    display: flex;
    min-width: 210px;
    max-width: 270px;
    height: 48px;
    align-items: center;
    gap: .65rem;
    padding: .3rem .65rem .3rem .35rem;
    border: 1px solid var(--app-border);
    border-radius: 13px;
    background: #ffffff;
    color: var(--app-text);
    box-shadow: var(--app-shadow-sm);
    cursor: pointer;
}

.user-avatar {
    display: inline-flex;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 11px;
    background: linear-gradient(135deg, #265fd6, #18a7c7);
    color: #ffffff;
    font-size: .75rem;
    font-weight: 800;
}

.user-meta {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    text-align: left;
}

.user-meta strong,
.user-meta small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-meta strong {
    font-size: .78rem;
}

.user-meta small {
    color: var(--app-text-muted);
    font-size: .67rem;
}

.user-chevron {
    width: 8px;
    height: 8px;
    transform: rotate(45deg);
    border-right: 2px solid #738196;
    border-bottom: 2px solid #738196;
}

.app-dropdown {
    min-width: 240px;
    margin-top: .5rem !important;
    padding: .5rem;
    border: 1px solid var(--app-border);
    border-radius: 14px;
    box-shadow: var(--app-shadow-lg);
}

.dropdown-user-summary {
    display: flex;
    flex-direction: column;
    padding: .55rem .7rem;
}

.dropdown-user-summary strong {
    font-size: .8rem;
}

.dropdown-user-summary span {
    color: var(--app-text-muted);
    font-size: .7rem;
}

.app-dropdown .dropdown-item {
    border-radius: 9px;
    padding: .55rem .7rem;
    font-size: .8rem;
}

.app-content {
    width: 100%;
    min-width: 0;
    flex: 1 1 auto;
    padding: 1.5rem 1.75rem 2rem;
    overflow-x: hidden;
}

.app-content-inner {
    width: min(100%, var(--app-content-max));
    min-width: 0;
    margin-inline: auto;
}

.app-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1150;
    display: none;
    border: 0;
    background: rgba(5, 15, 28, .58);
    backdrop-filter: blur(2px);
}

.app-shell[data-sidebar-state="collapsed"] .brand-copy,
.app-shell[data-sidebar-state="collapsed"] .context-copy,
.app-shell[data-sidebar-state="collapsed"] .sidebar-link-label,
.app-shell[data-sidebar-state="collapsed"] .sidebar-section-title,
.app-shell[data-sidebar-state="collapsed"] .sidebar-security-chip span {
    display: none;
}

.app-shell[data-sidebar-state="collapsed"] .sidebar-header,
.app-shell[data-sidebar-state="collapsed"] .sidebar-context-card,
.app-shell[data-sidebar-state="collapsed"] .sidebar-link,
.app-shell[data-sidebar-state="collapsed"] .sidebar-security-chip {
    justify-content: center;
}

.app-shell[data-sidebar-state="collapsed"] .sidebar-collapse-button {
    transform: rotate(180deg);
}

@media (max-width: 1199.98px) {
    .topbar-search {
        width: min(320px, 30vw);
        min-width: 210px;
    }

    .user-menu-button {
        min-width: 48px;
        width: 48px;
        padding: .3rem;
    }

    .user-meta,
    .user-chevron {
        display: none;
    }
}

@media (max-width: 991.98px) {
    .app-shell,
    .app-shell[data-sidebar-state="collapsed"] {
        display: block;
    }

    .app-sidebar {
        position: fixed;
        left: 0;
        transform: translateX(-100%);
        width: min(300px, 86vw);
        box-shadow: var(--app-shadow-lg);
        transition: transform var(--app-transition);
    }

    .app-shell[data-mobile-sidebar="open"] .app-sidebar {
        transform: translateX(0);
    }

    .app-shell[data-mobile-sidebar="open"] .app-backdrop {
        display: block;
    }

    .sidebar-collapse-button {
        display: none;
    }

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

    .app-topbar {
        padding-inline: 1rem;
    }

    .app-content {
        padding: 1.25rem 1rem 1.75rem;
    }
}

@media (max-width: 767.98px) {
    .app-topbar {
        min-height: auto;
        align-items: flex-start;
        flex-wrap: wrap;
        gap: .8rem;
        padding-block: .8rem;
    }

    .topbar-primary {
        width: 100%;
    }

    .page-heading {
        flex: 1;
    }

    .page-subtitle {
        display: none;
    }

    .topbar-actions {
        width: 100%;
    }

    .topbar-search {
        width: auto;
        min-width: 0;
        flex: 1;
    }

    .search-shortcut {
        display: none;
    }
}

@media (max-width: 479.98px) {
    .topbar-search {
        height: 42px;
    }

    .topbar-search input::placeholder {
        color: transparent;
    }

    .page-title {
        font-size: 1rem;
    }

    .app-content {
        padding-inline: .75rem;
    }
}
