/* ================================================================
   FriendsByChance — tags.css
   Styles for the Tags page (3-pane layout) and the shared
   TagLikePage sections used by the Tags / Locations / Times tabs.
   ================================================================ */

/* ── Left Pane Top Bar (.fbc-lptb) ───────────────────────────── */

.fbc-lptb {
    display:     flex;
    align-items: flex-start;
    padding:     10px 10px 10px 14px;
    border-bottom: 1px solid var(--color-divider);
    background:  var(--color-bg);
    flex-shrink: 0;
    min-height:  66px;   /* matches 2 × 30px icon buttons + 6px gap */
    box-sizing:  border-box;
    /* The tab buttons change shape with the PANE's width, not the
       window's: the left pane is fixed-width beside a wide window and
       most of the screen on a phone. */
    container-type: inline-size;
}

.fbc-lptb-tabs {
    flex:           1;
    display:        flex;
    flex-direction: column;
    gap:            4px;
    min-width:      0;
}

.fbc-lptb-tab {
    display:     block;
    width:       100%;
    text-align:  left;
    padding:     5px 10px;
    border-radius: 6px;
    border:      1px solid transparent;
    font-size:   0.88rem;
    font-weight: 500;
    cursor:      pointer;
    color:       var(--color-text-secondary);
    background:  transparent;
    transition:  background 0.1s, color 0.1s;
    line-height: 1.4;
}
.fbc-lptb-tab:hover             { background: var(--color-hover, rgba(0,0,0,0.04)); color: var(--color-text); }
.fbc-lptb-tab--active           { background: var(--color-primary, #4a7c59); color: #fff; border-color: var(--color-primary, #4a7c59); }
.fbc-lptb-tab--active:hover     { opacity: 0.88; background: var(--color-primary, #4a7c59); color: #fff; }

/* ── Tabs with icons: big buttons side by side ─────────────────
   The glyph is what is seen; the label underneath, small, is what makes
   sure the purpose is never a guess. */
.fbc-lptb-tabs--icons {
    flex-direction: row;
    gap:            6px;
}
.fbc-lptb-tabs--icons .fbc-lptb-tab {
    flex:            1 1 0;
    min-width:       0;
    /* A page with ONE mode so far (The Map) keeps the size a button has
       among others, rather than one bar across the pane. */
    max-width:       112px;
    display:         flex;
    flex-direction:  column;
    align-items:     center;
    justify-content: center;
    gap:             4px;
    min-height:      62px;
    padding:         8px 4px 6px;
    border-color:    var(--color-divider);
    border-radius:   10px;
    background:      var(--color-surface);
    text-align:      center;
}
.fbc-lptb-tabs--icons .fbc-lptb-tab--active {
    background:   var(--color-primary);
    border-color: var(--color-primary);
    color:        var(--color-text-on-primary);
}

.fbc-lptb-tab-icon     { display: flex; line-height: 0; }
.fbc-lptb-tab-icon svg { width: 24px; height: 24px; }

.fbc-lptb-tabs--icons .fbc-lptb-tab-label {
    max-width:     100%;
    font-size:     0.72rem;
    font-weight:   600;
    line-height:   1.2;
    letter-spacing: 0.01em;
    overflow:      hidden;
    text-overflow: ellipsis;
    white-space:   nowrap;
}

/* Too narrow for three buttons side by side: one row each, glyph first. */
@container (max-width: 230px) {
    .fbc-lptb-tabs--icons { flex-direction: column; gap: 4px; }
    .fbc-lptb-tabs--icons .fbc-lptb-tab {
        flex:            0 0 auto;
        max-width:       none;
        flex-direction:  row;
        justify-content: flex-start;
        gap:             8px;
        min-height:      0;
        padding:         5px 10px;
        border-radius:   6px;
    }
    .fbc-lptb-tabs--icons .fbc-lptb-tab:not(.fbc-lptb-tab--active) {
        border-color: transparent;
        background:   transparent;
    }
    .fbc-lptb-tab-icon svg { width: 16px; height: 16px; }
    .fbc-lptb-tabs--icons .fbc-lptb-tab-label { font-size: 0.88rem; font-weight: 500; }
}

.fbc-lptb-spacer {
    width:      8px;
    flex-shrink: 0;
}

/* ── Type toolbar (clear filter + edit mode, just above type list) */

.tags-type-toolbar {
    display:         flex;
    justify-content: flex-end;
    align-items:     center;
    gap:             4px;
    padding:         4px 8px;
    border-bottom:   1px solid var(--color-divider);
    flex-shrink:     0;
}

/* ── Tags type list (left pane) ──────────────────────────────── */

.tags-type-list {
    flex:       1;
    overflow-y: auto;
    padding:    4px 0 12px;
}

.tags-type-row-wrap {
    display:     flex;
    align-items: center;
    padding:     3px 8px;
    margin:      0 6px;
    border-radius: 6px;
    cursor:      pointer;
    transition:  background 0.08s;
    /* A row answers to one, two or three clicks (toggle / only this / none),
       and a triple click would otherwise select the row's text as a
       paragraph — the selection flashing blue on every third tap. */
    user-select: none;
}
.tags-type-row-wrap:hover              { background: var(--color-hover, rgba(0,0,0,0.04)); }
.tags-type-row-wrap.tags-type-selected {
    background: rgba(74,124,89,0.14);
    box-shadow: inset 3px 0 0 var(--color-primary, #4a7c59);
}
.tags-type-row-wrap.dragging           { opacity: 0.4; }
.tags-type-row-wrap.drag-before        { border-top:    2px solid var(--color-primary, #4a7c59); }
.tags-type-row-wrap.drag-after         { border-bottom: 2px solid var(--color-primary, #4a7c59); }

/* A drawer's grip (.fbc-drag-handle) — there in edit mode only (shared.css) */
.tags-type-drag-handle {
    align-self:   stretch;
    margin-right: 4px;
}

/* "+ New Type" button — hidden in view mode */
.tags-add-type-btn {
    display:     none;
    width:       calc(100% - 20px);
    margin:      8px 10px 0;
    padding:     6px 12px;
    font-size:   0.84rem;
    border:      1px dashed var(--color-divider);
    border-radius: 6px;
    background:  transparent;
    cursor:      pointer;
    color:       var(--color-primary, #4a7c59);
    text-align:  center;
}
.tags-add-type-btn:hover { background: var(--color-hover, rgba(0,0,0,0.04)); }

/* ── Edit mode — toggle class on .tags-type-list ─────────────── */

.tags-type-list.fbc-edit-mode .tags-add-type-btn { display: block; }

/* In view mode, buttons in the type list are hidden; spacers (.tl-btn-spacer)
   stay visible so every row keeps its 2-button height. */
.tags-type-list:not(.fbc-edit-mode) .fbc-side-col button { display: none; }

/* ── Main pane: tag row buttons always visible, horizontal ───── */

.tags-main-content .tl-row .fbc-side-col {
    flex-direction: row;
    gap:            4px;
    padding-top:    0;
    align-items:    center;
}

/* ── Main content (right pane of the left|main split) ────────── */

.tags-main-content {
    display:        flex;
    flex-direction: column;
    min-height:     100%;
}

/* Sticky topbar inside main pane.
   flex-wrap + a min-width on the search box is what implements the
   "buttons beside the search bar if there is room, otherwise on their
   own right-aligned row below" rule.  Deliberately NOT a media query:
   the main pane's width depends on the left rail and the navigation
   pane, so the break has to follow the container, not the window. */
.tags-main-topbar {
    display:     flex;
    flex-wrap:   wrap;
    align-items: center;
    gap:         8px;
    padding:     8px 14px;
    border-bottom: 1px solid var(--color-divider);
    background:  var(--color-bg);
    flex-shrink: 0;
    position:    sticky;
    top:         0;
    z-index:     2;
}

.tags-search-wrap {
    flex:     1;
    display:  flex;
    align-items: center;
    position: relative;
    /* The wrap threshold.  The tools are 66px (2 × 30px + 6px gap) and the
       row adds an 8px gap, so the tools drop to their own line once the
       pane's content box is under ~354px — i.e. on a phone-width screen,
       which is the case the spec calls "otherwise".
       Do not lower this: at 220px the break needed a <322px viewport and
       the stacked layout was effectively unreachable. */
    min-width: 280px;
}

/* Expand/collapse-all + compact/expanded toggles */
.tags-view-tools {
    display:     flex;
    align-items: center;
    gap:         6px;
    flex-shrink: 0;
    /* Pins the group right in both layouts: beside the search box it
       takes the leftover space, and on its own row it pushes right. */
    margin-left: auto;
}

/* The field: THE SEARCH FIELD (shared.css); room at its end for its ×. */
.tags-search-input { padding-right: 30px; }

/* Body — scrolling is handled by .fbc-pane-main */
.tags-main-body {
    flex:    1;
    padding: 4px 0 32px;
}

/* ── Type section (collapsible block in main pane) ────────────
   Calm header: caret + name (+count) + one-line desc + subtle "+".
   Sections with a color (--sec-color) get a slim accent bar.     */

.tags-type-section-hdr {
    display:      flex;
    align-items:  center;
    gap:          10px;
    padding:      9px 12px;
    cursor:       pointer;
    user-select:  none;
    border-top:   1px solid var(--color-divider);
    position:     relative;
    transition:   background 0.08s;
}
.tags-type-section-hdr:hover { background: var(--color-hover, rgba(0,0,0,0.03)); }

/* Slim color accent on the left of the header */
.tags-type-section.has-color .tags-type-section-hdr::before {
    content:       '';
    position:      absolute;
    left:          0;
    top:           6px;
    bottom:        6px;
    width:         4px;
    border-radius: 0 3px 3px 0;
    background:    var(--sec-color);
}

/* Collapse caret (chevron) */
.tags-section-caret {
    width:        7px;
    height:       7px;
    flex-shrink:  0;
    margin-left:  4px;
    border-right:  2px solid var(--color-text-secondary);
    border-bottom: 2px solid var(--color-text-secondary);
    transform:    rotate(-45deg);   /* pointing right (collapsed) */
    transition:   transform 0.12s;
}
.tags-type-section.expanded .tags-section-caret {
    transform: rotate(45deg);       /* pointing down (expanded) */
}

.tags-section-name-wrap {
    flex:    1;
    display: flex;
    align-items: baseline;
    gap:     10px;
    min-width: 0;
}

.tags-section-name {
    font-size:   0.92rem;
    font-weight: 600;
    color:       var(--color-text);
    white-space: nowrap;
    flex-shrink: 0;
}

.tags-section-desc {
    font-size:   0.78rem;
    color:       var(--color-text-secondary);
    white-space: nowrap;
    overflow:    hidden;
    text-overflow: ellipsis;
    min-width:   0;
}

/* Subtle "+" button in the section header */
.tags-section-add {
    width:        26px;
    height:       26px;
    border-color: transparent;
    background:   transparent;
    color:        var(--color-text-secondary);
}
.tags-type-section-hdr:hover .tags-section-add {
    border-color: var(--color-divider);
    background:   var(--color-bg);
    color:        var(--color-text);
}

.tags-type-section .tags-type-section-body {
    display: none;
    border-bottom: 1px solid var(--color-divider);
    padding-bottom: 4px;
}
.tags-type-section.expanded .tags-type-section-body { display: block; }
.tags-type-section.has-color .tags-type-section-body {
    box-shadow: inset 3px 0 0 var(--sec-color);
}

/* ── Empty states ────────────────────────────────────────────── */

.tags-empty {
    padding:    20px 14px;
    font-size:  0.88rem;
    color:      var(--color-text-secondary);
    font-style: italic;
}

/* ── Banner (errors / rate-limit) ────────────────────────────── */

.tags-banner {
    border-radius: 6px;
    padding:       10px 14px;
    margin-bottom: 16px;
    font-size:     0.88rem;
    background:    rgba(220, 53, 69, 0.08);
    color:         #b91c1c;
    border:        1px solid rgba(220, 53, 69, 0.2);
    display:       none;
}
.tags-banner.visible { display: block; }

/* ── Character limit hint ────────────────────────────────────── */

.tags-char-limit-hint {
    display:   none;
    font-size: 0.78rem;
    color:     #dc3545;
    margin-top: 2px;
}
.tags-char-limit-hint.visible { display: block; }

/* ── What a tag is on (FBC.tags: _taggedList, elementChip) ─────────
   Under a tag, in its row and its popover: what it stands for, each a
   chip whose card opens it; what a combo reaches through one of its tags is
   dimmed (its title says which).  Then the chats it feeds. */
.tag-extras {
    display:        flex;
    flex-direction: column;
    gap:            8px;
    min-width:      0;
}
/* .tagged-list: a titled line of chips (FBC.ui.chipBlock, taglike.css);
   each chip pressed opens its card (FBC.ui.cardChip). */
.tagged-chip--via { opacity: 0.55; }
.tagged-list-more {
    background: none;
    border:     none;
    padding:    2px 6px;
    font:       inherit;
    font-size:  0.8rem;
    color:      var(--color-primary);
    cursor:     pointer;
}
.tagged-list-more:hover { text-decoration: underline; }

/* The editor's "Tagged", and what a combo reaches besides. */
.tle-tagged-through {
    margin:     -2px 0 0;
    font-size:  0.8rem;
    color:      var(--color-text-secondary);
}

/* ── A thing's own tags (FBC.tags: tagsField, chipsOf) ─────────────
   An album's, a text's — in its editor, and as chips under it. */
.tags-field { margin-top: 8px; }
.tags-field:empty { display: none; }
.tags-chips {
    display:   flex;
    flex-wrap: wrap;
    gap:       4px;
    margin-top: 6px;
}
.description-item-tags:empty { display: none; }

/* Select mode (taglike-page.js): a group's box, first in its header, and
   the Select button that sits with the view tools. */
.tags-section-select { flex: 0 0 auto; margin: 0 8px 0 0; }
.tags-view-tools .tlp-select-btn { margin-right: 6px; }
