/* The list of spaces, rooms and direct messages on the left, with the
   form that makes new ones. */

.sidebar {
    width: var(--sidebar-width);
    flex: none;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.sidebar-head {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    height: var(--bar-height);
    flex: none;
    padding: 0 var(--space-6);
    border-bottom: 1px solid var(--color-border);
}

.sidebar-head .search-link {
    flex: 1;
    justify-content: flex-start;
    gap: var(--space-5);
    color: var(--color-text-muted);
}

.sidebar-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: var(--space-4) var(--space-6) var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

/* A heading with the button that adds to what is under it. */
.group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: var(--space-6);
    min-height: var(--control-size);
}

/* Who you are, at the foot of the column. */
.user-area {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex: none;
    padding: var(--space-5) var(--space-6);
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
}

.user-area .user-identity {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    margin-left: var(--space-3);
    color: var(--color-text);
    line-height: 1.25;
}

.user-area .user-identity .name {
    font-weight: 600;
    font-size: var(--text-s);
}

.user-area .user-identity .id {
    color: var(--color-text-muted);
    font-size: var(--text-xs);
}

.user-area .user-identity .name, .user-area .user-identity .id {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.group-label {
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin: 0 var(--space-4);
}

/* A room or a person. Read, it is quiet; with something unread it is
   bright and bold, so the eye finds what is new without reading numbers. */
.room-link {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    min-height: var(--control-size);
    padding: 0 var(--space-5);
    border-radius: var(--radius-m);
    color: var(--color-text-muted);
}

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

.room-link.unread-room, .room-link.on {
    color: var(--color-text);
}

.room-link.unread-room .label {
    font-weight: 600;
}

/* What stands before the name: a sign for a room, a picture for a person. */
.room-link .sign {
    position: relative;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--avatar-size-small);
    height: var(--avatar-size-small);
}

.room-link .sign .icon {
    width: 1em;
    height: 1em;
}

.room-link .sign .avatar {
    margin: 0;
}

/* A person's picture is a little larger than a room's sign: it is a face. */
.room-link .sign.person, .room-link .sign.person .avatar {
    width: var(--avatar-size-inline);
    height: var(--avatar-size-inline);
    font-size: var(--text-xs);
}

.room-link .sign.person .presence-dot {
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 9px;
    height: 9px;
    border: 2px solid var(--color-surface);
    box-sizing: content-box;
}

.room-link .sign.person .presence-dot.offline {
    display: none;
}

/* ── a space: a heading that folds, its rooms under it ─────────────────── */

.space-head {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    min-height: var(--control-size);
    margin-top: var(--space-2);
    border-radius: var(--radius-m);
}

.space-head:hover, .space-head.on {
    background: var(--color-fill);
}

.space-head .fold {
    min-width: 1.5rem;
    padding: 0;
}

.space-head .fold .icon {
    width: 1rem;
    height: 1rem;
}

.space-link {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: var(--space-4);
    color: var(--color-text);
    font-weight: 600;
}

.space-link .avatar {
    margin: 0;
    width: var(--avatar-size-inline);
    height: var(--avatar-size-inline);
    border-radius: var(--radius-m);
    font-size: var(--text-xs);
}

.space-link .label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The options are there when the space is pointed at, and always where
   nothing can point. */
.space-head .space-menu {
    visibility: hidden;
}

.space-head:hover .space-menu, .space-menu:focus-visible {
    visibility: visible;
}

@media (hover: none) {
    .space-head .space-menu {
        visibility: visible;
    }
}

/* A line down the side ties the rooms to their space. */
.space-rooms-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    margin-left: calc(.75rem - 1px);
    padding-left: var(--space-5);
    border-left: 1px solid var(--color-border);
}

.room-link.on, .room-link:hover {
    background: var(--color-fill);
}

.unread {
    background: var(--color-accent);
    color: var(--color-on-accent);
    border-radius: var(--radius-pill);
    padding: 0 var(--space-4);
    font-size: var(--text-xs);
}

.invite-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-5);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-m);
    padding: var(--space-5);
}

.create-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-6);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
}




.new-dm {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.on-call {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    color: var(--color-success);
    font-size: var(--text-xs);
    margin-right: var(--space-3);
}

/* On a phone the column is a drawer that slides over the page. */
@media (max-width: 720px) {
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 5;
        width: min(var(--sidebar-width), 85vw);
        transform: translateX(-100%);
        transition: transform .15s ease-out;
    }

    .sidebar.open {
        transform: none;
    }
}
