/* =============================================
   Page controls — toolbar / filter / row-action
   primitives shared by list & CRUD pages.
   Sits on top of zsybcom-cards.css; uses the
   --tb-* design tokens from topbar.css.
   ============================================= */


/* ----- Global [hidden] enforcement --------------------------------
   Author class rules like `.tile { display: flex }` or
   `.tile-grid { display: grid }` outrank the UA `[hidden] { display: none }`
   rule on specificity. Restore the HTML-spec behaviour so list filters
   and view-pane toggles can rely on the `hidden` attribute. */
[hidden] { display: none !important; }


/* ----- Page-level toolbar ------------------------------------------- */

.page-toolbar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.page-toolbar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.page-toolbar-row .spacer { flex: 1 1 auto; min-width: 0; }

.page-toolbar .toolbar-sep {
    width: 1px;
    align-self: stretch;
    background: var(--border);
    margin: 4px 4px;
}


/* ----- Search input (Seidos-style fused bar) ----------------------- */
/* Icon, input and optional kbd hint are flex siblings; borders join so
   the three render as one continuous control. Avoids the overlap
   problems that absolute-positioned icons run into across font sizes. */

.toolbar-search {
    display: flex;
    align-items: stretch;
    flex: 1 1 280px;
    min-width: 220px;
    max-width: 480px;
    height: 32px;
    box-sizing: border-box;
}

.toolbar-search .data-search-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-right: none;
    border-top-left-radius: var(--radius);
    border-bottom-left-radius: var(--radius);
    color: var(--text-3);
    font-size: 13px;
    line-height: 1;
    pointer-events: none;
    transition: color 120ms;
}

.toolbar-search .data-search-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    padding: 0 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0;
    color: var(--text);
    font: inherit;
    box-sizing: border-box;
    transition: border-color 120ms, box-shadow 120ms;
}

.toolbar-search .data-search-input:hover { border-color: var(--text-3); }
.toolbar-search .data-search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
    position: relative;
    z-index: 1;
}

.toolbar-search .data-search-input:focus + .data-search-kbd { /* sibling tweak when focused */
    border-color: var(--text-3);
}

.toolbar-search .data-search-input:focus ~ .data-search-icon,
.toolbar-search:focus-within .data-search-icon {
    color: var(--accent);
}

.toolbar-search .data-search-kbd {
    display: inline-flex;
    align-items: center;
    padding: 0 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-left: none;
    border-top-right-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
    color: var(--text-3);
    font-family: var(--monospace-font, 'IBM Plex Mono'), monospace;
    font-size: 10.5px;
    pointer-events: none;
}

/* When the input is the last child (no kbd hint), give it the right radius. */
.toolbar-search .data-search-input:last-child {
    border-top-right-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}


/* ----- Toolbar button (labeled action) ---------------------------- */

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
}

.toolbar-btn:hover {
    background: var(--surface-2);
    border-color: var(--text-3);
    color: var(--text);
}

.toolbar-btn[data-variant="primary"] {
    background: var(--accent);
    border-color: var(--accent);
    color: #FFFFFF;
}

.toolbar-btn[data-variant="primary"]:hover {
    filter: brightness(0.95);
    color: #FFFFFF;
}


/* ----- Pill toggle (on/off chip) ----------------------------------- */

.pill-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 120ms, border-color 120ms, color 120ms;
}

.pill-toggle[data-on="true"] {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-text);
}

.pill-toggle .dot {
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--text-3);
    border-radius: 4px;
    display: inline-grid;
    place-items: center;
    background: var(--surface);
}

.pill-toggle[data-on="true"] .dot {
    background: var(--accent);
    border-color: var(--accent);
    color: #FFFFFF;
}

/* Checkbox-driven variant — the <input type="checkbox"> is visually hidden
   using the clip-path technique (works reliably across all browsers,
   including those that enforce minimum tap-target sizes on form controls). */
.pill-toggle--check {
    position: relative;
}

.pill-toggle--check input[type="checkbox"] {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

.pill-toggle--check:has(input:checked) {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-text);
}

.pill-toggle--check:has(input:checked) .dot {
    background: var(--accent);
    border-color: var(--accent);
    color: #FFFFFF;
}


/* ----- Segmented control (view-mode switcher) ---------------------- */

.segmented {
    display: inline-flex;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2px;
    gap: 1px;
}

.segmented button {
    height: 26px;
    padding: 0 10px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-3);
    font-size: 12px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: background 120ms, color 120ms;
}

.segmented button:hover               { color: var(--text); }
.segmented button[data-active="true"] {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}


/* ----- Filter strip (letter / chip row) ---------------------------- */

.filter-strip {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 26px;
    padding: 0 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 999px;
    font-family: var(--monospace-font, 'IBM Plex Mono'), monospace;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-2);
    cursor: pointer;
    transition: border-color 120ms, color 120ms, background 120ms;
}

.filter-chip:hover {
    border-color: var(--text-3);
    color: var(--text);
}

.filter-chip[data-active="true"] {
    background: var(--accent-soft);
    color: var(--accent-text);
    border-color: var(--accent);
}

.filter-chip .count {
    font-size: 10.5px;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
}

.filter-chip[data-active="true"] .count { color: var(--accent-text); }


/* ----- Row actions (table/list inline icon button cluster) --------- */
/* Top-level .icon-btn that any row can use, not just .zsybcom-card-actions. */

.row-actions {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-right: 4px;
}

.icon-btn {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    font-size: 13px;
    line-height: 1;
    transition: background 120ms, color 120ms, border-color 120ms;
}

.icon-btn:hover {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}

/* Tone variants — semantic per action type. */
.icon-btn[data-tone="view"]     { color: var(--text-2); }
.icon-btn[data-tone="add"]      { color: var(--accent); }
.icon-btn[data-tone="edit"]     { color: var(--accent-complement); }
.icon-btn[data-tone="closed"]   { color: var(--text-3); }
.icon-btn[data-tone="danger"]   { color: var(--error, #c0392b); }
.icon-btn[data-tone="favorite"] { color: var(--text-3); }

.icon-btn[data-tone="add"]:hover {
    color: var(--accent-text);
    background: var(--accent-soft);
    border-color: var(--accent);
}
.icon-btn[data-tone="danger"]:hover {
    color: var(--error, #c0392b);
    border-color: var(--error, #c0392b);
    background: var(--error-soft, hsl(0, 80%, 96%));
}
.icon-btn[data-tone="favorite"][data-fav="1"]       { color: var(--warn-strong); }
.icon-btn[data-tone="favorite"][data-fav="1"]:hover { color: var(--warn-strong); }

.row-actions .icon-btn {
    width: 26px;
    height: 26px;
}


/* Legacy ibutton width cap — applied to Bootstrap btn used as icon-only trash button */
.ibutton-icon { max-width: 2.75rem; }


/* ----- Tile grid (lightweight card-view for list pages) ----------- */

.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
    padding: 14px;
}

.tile {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 120ms, box-shadow 120ms;
}

.tile:hover {
    border-color: var(--text-3);
    box-shadow: var(--shadow-sm);
}

.tile-title  { font-weight: 600; color: var(--text); }
.tile-title a { color: inherit; text-decoration: none; }
.tile-title a:hover { color: var(--accent-text); }

.tile-foot {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}


/* ----- Table footer + pager --------------------------------------- */

.table-footer {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    font-size: 12.5px;
    color: var(--text-2);
}

.table-footer .pager {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
}


/* ----- Status chips (reused across pages) ------------------------- */

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 18px;
    padding: 0 6px;
    border-radius: 4px;
    font-size: 10.5px;
    font-weight: 500;
    font-family: var(--monospace-font, 'IBM Plex Mono'), monospace;
    background: var(--surface-2);
    color: var(--text-3);
    border: 1px solid var(--border);
}

.status-chip[data-tone="accent"] {
    background: var(--accent-soft);
    color: var(--accent-text);
    border-color: var(--accent);
}

.status-chip[data-tone="warn"] {
    background: hsl(40, 80%, 95%);
    color: var(--warning-dark, #7a5a00);
    border-color: hsl(40, 70%, 70%);
}

.status-chip[data-tone="danger"] {
    background: hsl(0, 80%, 96%);
    color: var(--error-dark, #7a1f1f);
    border-color: hsl(0, 70%, 78%);
}

.status-chip[data-tone="success"] {
    background: hsl(120, 50%, 94%);
    color: var(--success-dark, #1e6a1e);
    border-color: hsl(120, 50%, 70%);
}
