@use '@angular/material' as mat;
@use '../../../../../styles/portal-sidebar';
@use '../../../../../styles/panel-header' as panel;
@use '../../../../../../../apps/web/src/nav-list.scss';

:host {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.groups-view-layout {
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    background: var(--app-content-bg, var(--mat-sys-surface));
}

.groups-nav-panel {
    width: 208px;
    min-width: 164px;
    max-width: 320px;
    flex-shrink: 0;
    min-height: 0;
    display: flex;
    overflow: hidden;
    background: var(--app-rail-bg, var(--mat-sys-surface-container-low));
    padding: 12px 10px 10px 12px;
    box-sizing: border-box;
    container-type: inline-size;
}

.groups-nav-shell {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
}

.groups-nav-header {
    padding: 4px 6px 12px;
    flex-shrink: 0;
    display: flex;
    gap: 10px;
    flex-direction: column;
}

.groups-nav-header__content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.groups-nav-title {
    margin: 0;
    font-size: 0.94rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--mat-sys-on-surface);
}

.groups-nav-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.groups-nav-action,
.groups-nav-search {
    @include mat.form-field-density(-5);
}

.groups-nav-action {
    width: 28px;
    height: 28px;
    min-width: 28px;
    padding: 0;
    line-height: 28px;

    mat-icon {
        width: 18px;
        height: 18px;
        font-size: 18px;
    }
}

.groups-nav-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    min-height: 36px;
    border-radius: 10px;
    border: 1px solid var(--app-search-border, var(--mat-sys-outline-variant));
    background: var(--app-search-bg, var(--mat-sys-surface-container));
    cursor: text;
    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;

    &:focus-within {
        border-color: var(--mat-sys-primary);
        box-shadow: 0 0 0 3px
            color-mix(in srgb, var(--mat-sys-primary) 12%, transparent);
    }
}

.groups-nav-search__icon {
    width: 18px;
    height: 18px;
    font-size: 18px;
    color: var(--mat-sys-on-surface-variant);
    flex-shrink: 0;
}

.groups-nav-search input {
    flex: 1;
    min-width: 0;
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    color: var(--mat-sys-on-surface);
    font: inherit;
    font-size: 0.84rem;

    &::placeholder {
        color: var(--mat-sys-on-surface-variant);
        opacity: 0.6;
    }

    &::-webkit-search-cancel-button {
        display: none;
    }
}

.groups-nav-search__close {
    width: 24px;
    height: 24px;
    min-width: 24px;
    line-height: 24px;
    flex-shrink: 0;
    padding: 0;

    mat-icon {
        width: 16px;
        height: 16px;
        font-size: 16px;
    }
}

.groups-content-header {
    @include panel.standard-panel-header();
    border-top-left-radius: inherit;
}

.groups-content-header button {
    @include mat.form-field-density(-5);
}

.category-meta {
    @include panel.standard-panel-meta();

    &--stacked {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

.category-title {
    @include panel.standard-panel-title(0.94rem);
}

.category-subtitle {
    @include panel.standard-panel-subtitle();
}

.groups-nav-list {
    height: 100%;
    min-height: 0;
    padding-top: 0;
    padding-inline: 0 2px;
}

.groups-nav-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 24px 12px;
    color: var(--app-muted-color, var(--mat-sys-on-surface-variant));

    &__icon {
        width: 28px;
        height: 28px;
        font-size: 28px;
        opacity: 0.5;
        margin-bottom: 10px;
    }

    &__title {
        font-size: 0.85rem;
        font-weight: 520;
        letter-spacing: -0.01em;
        margin-bottom: 4px;
        text-wrap: balance;
    }

    &__hint {
        font-size: 0.78rem;
        line-height: 1.4;
        opacity: 0.65;
        text-wrap: pretty;
    }
}

.group-nav-item {
    background: transparent;
}

.channel-context-menu-anchor {
    position: fixed;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

.groups-content-panel {
    width: auto;
    min-width: 0;
    max-width: none;
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: none;
    background: var(--app-content-bg, var(--mat-sys-surface));
    border-top-left-radius: 16px;
}

.groups-content-panel > .groups-content-header {
    border-top-left-radius: inherit;
}

.groups-channels-viewport {
    flex: 1;
    min-height: 0;
    width: 100%;
    padding: 4px 8px 12px;
    box-sizing: border-box;

    ::ng-deep .cdk-virtual-scroll-content-wrapper {
        width: 100% !important;
        max-width: 100% !important;
    }
}

.groups-content-empty-state {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    text-align: center;
}

.groups-view-empty-state {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    text-align: center;
}

.empty-state-icon {
    width: 48px;
    height: 48px;
    font-size: 48px;
    opacity: 0.5;
    margin-bottom: 16px;
}

.empty-state-title {
    font-size: 1.05rem;
    font-weight: 520;
    letter-spacing: -0.01em;
    margin-bottom: 8px;
}

.empty-state-hint {
    opacity: 0.65;
    font-size: 0.85rem;
    max-width: 240px;
    line-height: 1.4;
}

@container (max-width: 220px) {
    .groups-nav-list {
        padding-inline-end: 0;
    }
}
