/* Multi-select tag dropdown (see index-tag-multiselect.js)
 * Uses --izi-* design tokens so light + dark themes work without changes.
 */

.tag-ms {
    position: relative;
    display: inline-block;
    min-width: 220px;
    font-size: 13px;
    color: var(--izi-text);
}

.tag-ms-trigger {
    width: 100%;
    min-height: 32px;
    background: var(--izi-bg);
    border: 1px solid var(--izi-border-strong);
    border-radius: 6px;
    padding: 4px 28px 4px 6px;
    cursor: pointer;
    text-align: left;
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    color: var(--izi-text);
}

.tag-ms-trigger:hover {
    border-color: var(--izi-primary);
}

.tag-ms-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.tag-ms-placeholder {
    color: var(--izi-text-muted);
}

.tag-ms-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 4px 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1;
    /* default text colour for chips that have no per-tag colour set;
       chips with a colour override this inline via JS contrast helper */
    color: var(--izi-text);
}

.tag-ms-chip-empty {
    background: var(--izi-bg-tertiary);
}

.tag-ms-chip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-size: 13px;
}

.tag-ms-chip-remove {
    border: none;
    background: rgba(0, 0, 0, 0.18);
    color: inherit;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 14px;
    padding: 0;
}

.tag-ms-chip-remove:hover {
    background: rgba(0, 0, 0, 0.28);
}

.tag-ms-caret {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--izi-text-muted);
    pointer-events: none;
}

/* Popover: closed by default, opened by toggling the .open class.
   Uses position:fixed so it escapes any clipping parent (modal body,
   overflow:hidden containers, etc). JS computes top/left on open. */
.tag-ms-popover {
    display: none;
    position: fixed;
    z-index: 1000;
    background: var(--izi-bg);
    border: 1px solid var(--izi-border-strong);
    border-radius: 6px;
    box-shadow: var(--izi-shadow-lg, 0 8px 24px rgba(0, 0, 0, 0.18));
    max-height: 320px;
    min-width: 240px;
    box-sizing: border-box;
    flex-direction: column;
    color: var(--izi-text);
    overflow: hidden; /* keep ✕ corner inside the rounded border */
}

.tag-ms-popover.open {
    display: flex;
}

.tag-ms-search-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--izi-border);
    box-sizing: border-box;
}

.tag-ms-search {
    flex: 1;
    height: 28px;
    padding: 0 8px;
    font-size: 13px;
    border: 1px solid var(--izi-border-strong);
    border-radius: 4px;
    background: var(--izi-bg);
    color: var(--izi-text);
}

.tag-ms-search:focus {
    outline: none;
    border-color: var(--izi-primary);
}

.tag-ms-close {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    color: var(--izi-text-muted);
    padding: 4px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}

.tag-ms-close:hover {
    background: var(--izi-bg-hover);
    color: var(--izi-text);
}

.tag-ms-items {
    overflow-y: auto;
    max-height: 260px;
    padding: 4px 0;
}

.tag-ms-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--izi-text);
}

.tag-ms-item:hover,
.tag-ms-item.highlight {
    background: var(--izi-bg-hover);
}

.tag-ms-item.selected .tag-ms-name {
    font-weight: 600;
}

.tag-ms-checkbox {
    width: 14px;
    height: 14px;
    border: 1px solid var(--izi-border-strong);
    border-radius: 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--izi-primary);
    background: var(--izi-bg);
    flex-shrink: 0;
}

.tag-ms-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tag-ms-dot-empty {
    border: 1px dashed var(--izi-border-strong);
    background: transparent;
}

.tag-ms-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    font-size: 14px;
    line-height: 1;
}

.tag-ms-icon-empty {
    /* keeps the row vertically aligned even without an icon */
}

.tag-ms-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--izi-text);
}

.tag-ms-star {
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--izi-text-muted);
    padding: 2px 4px;
    font-size: 14px;
    line-height: 1;
}

.tag-ms-star.active {
    color: #f59e0b;
}

.tag-ms-star:hover {
    color: #f59e0b;
}

.tag-ms-create {
    color: var(--izi-primary);
    font-weight: 500;
}

.tag-ms-plus {
    display: inline-block;
    width: 14px;
    text-align: center;
    font-weight: 700;
}

.tag-ms-empty {
    padding: 8px 10px;
    color: var(--izi-text-muted);
    font-size: 12px;
    text-align: center;
}

/* When mounted inside the toolbar's filter bar, keep the trigger compact. */
.filter-bar .tag-ms,
.toolbar-left .tag-ms {
    min-width: 200px;
    max-width: 320px;
}

/* AND / OR mode toggle next to the tag filter dropdown */
.tag-filter-mode-btn {
    min-width: 38px;
    padding: 0 8px;
    height: 32px;
    border: 1px solid var(--izi-border-strong);
    border-radius: 6px;
    background: var(--izi-bg);
    color: var(--izi-text);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    flex-shrink: 0;
}

.tag-filter-mode-btn:hover {
    border-color: var(--izi-primary);
    background: var(--izi-bg-hover);
}

.tag-filter-mode-btn.and {
    color: var(--izi-primary);
    border-color: var(--izi-primary);
    background: var(--izi-primary-bg, var(--izi-bg-hover));
}

/* Admin view rows (see index-tags-admin.js) */
.tag-admin-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--izi-border);
    font-size: 13px;
    color: var(--izi-text);
}

.tag-admin-info {
    flex: 1;
    min-width: 0;
}

.tag-admin-name {
    font-weight: 500;
    color: var(--izi-text);
}

.tag-admin-syn,
.tag-ms-syn {
    color: var(--izi-text-muted);
    font-weight: 400;
    font-size: 0.9em;
    font-style: italic;
}

.tag-admin-owner {
    color: var(--izi-text-muted);
    font-size: 11px;
}

.tag-admin-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.tag-admin-actions .btn.btn-small,
.tag-admin-hover-actions .btn.btn-small {
    padding: 4px 8px;
    font-size: 12px;
}

/* Fixed-width right cluster (acro / count / star). Same width on
   every row → the hover-actions slot before it always lands at the
   same X, regardless of acronym length. */
.tag-admin-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
    width: 140px;
}

/* Hover-reveal: edit / share / merge / delete are rendered in their
   own .tag-admin-hover-actions container placed BEFORE the right
   cluster. The slot is ALWAYS reserved (fixed min-width) AND the
   right cluster is fixed-width too, so the hover-actions area starts
   and ends at the same X on every row. The buttons inside are
   hidden by default and become visible on row hover. */
.tag-admin-hover-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    flex-shrink: 0;
    min-width: 160px;
}

.tag-admin-hover-actions > .btn.btn-small {
    visibility: hidden;
}

.tag-admin-row:hover .tag-admin-hover-actions > .btn.btn-small,
.tag-admin-row:focus-within .tag-admin-hover-actions > .btn.btn-small {
    visibility: visible;
}

.tag-admin-rename-input {
    width: 100%;
    padding: 2px 4px;
    font-size: 13px;
    border: 1px solid var(--izi-primary);
    border-radius: 3px;
    background: var(--izi-bg);
    color: var(--izi-text);
}

.tag-admin-share-popover {
    position: absolute;
    right: 6px;
    top: 100%;
    z-index: 10;
    background: var(--izi-bg);
    border: 1px solid var(--izi-border-strong);
    border-radius: 6px;
    padding: 6px;
    display: flex;
    gap: 4px;
    align-items: center;
    box-shadow: var(--izi-shadow-lg, 0 8px 24px rgba(0, 0, 0, 0.18));
}

.tag-admin-share-select {
    padding: 4px 6px;
    font-size: 12px;
    border: 1px solid var(--izi-border-strong);
    border-radius: 3px;
    background: var(--izi-bg);
    color: var(--izi-text);
}

/* Compact row decorations */
.tag-admin-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    font-size: 14px;
    line-height: 1;
}

.tag-admin-icon-empty {
    /* keeps row alignment when no icon */
}

.tag-admin-acro {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    background: var(--izi-bg-tertiary);
    color: var(--izi-text-secondary);
    text-transform: uppercase;
    flex-shrink: 0;
}

.tag-admin-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 18px;
    padding: 0 6px;
    border-radius: 9px;
    font-size: 11px;
    background: var(--izi-bg-tertiary);
    color: var(--izi-text-muted);
    flex-shrink: 0;
}

.tag-admin-group-title {
    margin: 12px 0 4px 0;
    font-size: 13px;
    color: var(--izi-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Full-screen editor mode (no accordion). The list is hidden while
   the editor is shown and vice versa, so the page has a single scroll
   container — no nested scrollbars. */
.tag-admin-edit-screen {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.tag-admin-edit-screen-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--izi-border);
}

.tag-admin-edit-screen-title {
    margin: 0;
    font-size: 14px;
    color: var(--izi-text-secondary);
}

.tag-admin-edit-screen-title strong {
    color: var(--izi-text);
}

.tag-admin-edit-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tag-admin-edit-meta {
    color: var(--izi-text-muted);
    font-size: 12px;
}

.tag-admin-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tag-admin-field label {
    font-size: 12px;
    color: var(--izi-text-secondary);
}

.tag-admin-field-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.tag-admin-color-preview {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    border: 1px dashed var(--izi-border);
    color: var(--izi-text-muted);
}

.tag-admin-icon-grid {
    border: 1px solid var(--izi-border);
    border-radius: 6px;
    padding: 6px;
    background: var(--izi-bg);
    /* No max-height — let the page scroll the whole editor instead of
       nesting a second scrollbar inside the form. */
}

.tag-admin-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}
