/* Channel categories, drag and drop, private channels and Channel Settings' Permissions tab
   (client/js/channelList.js, client/js/channelPermissions.js). Uses the theme tokens from styles.css. */

/* Categories: a chevron, the name in capitals and a + (Create Channel in ...). */
.category-header { padding: 0 4px 0 0; margin-top: 12px; }
.category-group:first-of-type .category-header { margin-top: 4px; }
.category-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px; padding: 4px 2px; border: 0; background: none; color: inherit; font: inherit; text-transform: inherit; text-align: left; cursor: pointer; }
.category-toggle:hover { color: var(--text); }
.category-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-toggle .icon { flex: none; }
.category-add { font-size: 16px; padding: 0 6px; }

/* The lock on a private channel's icon. */
.channel-icon.private { position: relative; display: inline-flex; flex: none; }
.channel-icon.private > .icon:first-child { opacity: 0.7; }
.channel-icon.private > .icon:last-child { position: absolute; right: -4px; top: -3px; padding: 1px; border-radius: 4px; background: var(--bg-sidebar); color: var(--text-muted); opacity: 1; }

/* Drag and drop: the dragged item fades, a line shows where it will land. */
.channel-item.channel-dragging, .category-header.channel-dragging { opacity: 0.4; }
.channel-drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.channel-drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.channel-drop-into { outline: 2px dashed var(--accent); outline-offset: -2px; border-radius: 4px; }
.channel-top-drop { height: 4px; }
.channel-list.dragging-channel .channel-top-drop { height: 20px; }

/* Create Channel / Create Category. */
.create-channel-type { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-top: 6px; border-radius: 4px; background: var(--bg-chat); cursor: pointer; }
.create-channel-type:has(input:checked) { background: var(--bg-active); }
.create-channel-type .icon { color: var(--text-muted); flex: none; }
.create-channel-type-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.create-channel-type input { width: auto; accent-color: var(--accent); }
.create-channel-input { display: flex; align-items: center; gap: 6px; padding-left: 8px; border-radius: 4px; background: var(--bg-chat); }
.create-channel-input .create-channel-prefix { display: inline-flex; color: var(--text-muted); }
.create-channel-input input { flex: 1; background: none; }
.create-private-row { border-bottom: 0; }
.create-private-row .perm-label, .private-channel-row .perm-label { display: inline-flex; align-items: center; gap: 2px; }

/* Channel Settings > Permissions. */
.sync-status { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 12px; border-radius: 4px; background: var(--bg-sidebar); }
.sync-status > span { flex: 1; }
.sync-status.synced .icon { color: var(--online); }
.private-channel-row { margin-bottom: 4px; }
.channel-access { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 16px; padding: 12px; border-radius: 4px; background: var(--bg-sidebar); }
.channel-access-header { justify-content: space-between; }
.channel-access-header .perm-group-title { padding: 0; }
.channel-access-list { display: flex; flex-direction: column; gap: 2px; }
.channel-access-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 6px; border-radius: 4px; }
.channel-access-row:hover { background: var(--bg-hover); }
.overwrite-target { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.overwrite-target .avatar { width: 24px; height: 24px; font-size: 11px; flex: none; }
.overwrite-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.advanced-toggle { display: flex; align-items: center; gap: 6px; margin-top: 12px; padding: 8px 0; border: 0; background: none; color: var(--text-strong); font-weight: 700; cursor: pointer; }
.overwrite-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 20px; align-items: start; margin-top: 8px; }
.overwrite-list { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; }
.overwrite-list-header { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); padding: 0 0 4px 6px; }
.overwrite-row { display: flex; align-items: center; padding: 6px; border: 0; border-radius: 4px; background: none; color: var(--text); text-align: left; min-width: 0; }
.overwrite-row:hover { background: var(--bg-hover); }
.overwrite-row.active { background: var(--bg-active); color: var(--text-strong); }
.overwrite-editor { display: flex; flex-direction: column; min-width: 0; }
.overwrite-editor-title { display: flex; align-items: center; gap: 6px; margin: 0 0 4px; color: var(--text-strong); flex-wrap: wrap; }
.overwrite-perm { cursor: default; }
.remove-overwrite { align-self: flex-start; margin-top: 16px; }

/* Allow / inherit / deny. */
.tri-state { flex: none; display: inline-flex; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.tri-option { display: grid; place-items: center; width: 32px; height: 28px; padding: 0; border: 0; border-left: 1px solid var(--border); background: none; color: var(--text-muted); font-weight: 700; }
.tri-option:first-child { border-left: 0; }
.tri-option:not(:disabled):hover { background: var(--bg-hover); color: var(--text-strong); }
.tri-option.deny.selected { background: var(--danger); color: #fff; }
.tri-option.inherit.selected { background: var(--bg-active); color: var(--text-strong); }
.tri-option.allow.selected { background: var(--online); color: #fff; }
.tri-option:disabled { cursor: not-allowed; opacity: 0.5; }
.tri-option:disabled.selected { opacity: 0.8; }

/* "Add members or roles". */
.overwrite-picker-search { margin: 4px 0 8px; }
.overwrite-picker-list { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; }
.overwrite-picker-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border: 0; border-radius: 4px; background: none; color: var(--text); text-align: left; }
.overwrite-picker-row:hover, .overwrite-picker-row:focus-visible { background: var(--bg-hover); color: var(--text-strong); }

@media (max-width: 760px) {
  .overwrite-layout { grid-template-columns: 1fr; }
  .overwrite-list { position: static; }
}
