/* ==========================================================================
   SHARED UI COMPONENTS (md/DESIGN.md)
   ==========================================================================
   One look for elements that do the same job on every page: pills (toggleable
   filters, tabs, checkbox choices), badges (status and info tags), the round
   close button and the extra button variants. Built by the PHP components in
   project/components/ui/ and by rbUi in assets/js/app-components.js; use those
   instead of writing the markup by hand.

   The file name sorts right after acc.css (tokens, .btn) and before every page
   stylesheet, so a page can still adjust spacing with a class of the same
   specificity (`.zvuk-druhy { margin-top: 12px; }`). Colours, radius, padding
   and states belong here, not in page stylesheets.
   ========================================================================== */

/* ========== BUTTON VARIANTS (base .btn lives in acc.css) ========== */

/* Less important action, link to another page, Cancel: a muted primary that still reads as a button. The tint and
   the border are translucent, so they stay visible on white, grey and tinted surfaces alike. */
.btn-ghost {
    background: var(--primary-light);
    color: var(--primary);
    padding: 10px 16px;
}

.btn-ghost:hover:not(:disabled) {
    background: var(--primary-ghost-hover);
    box-shadow: inset 0 0 0 1px var(--primary-border);
    color: var(--text);
}

.btn-ghost:active:not(:disabled) {
    background: rgba(240, 56, 90, 0.26);
}

.btn-ghost:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Destructive confirmation (delete, cancel publishing). */
.btn-danger {
    background: var(--error);
    color: #fff;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

/* Secondary destructive action next to a primary one: ghost with red text. */
.btn-danger-ghost {
    background: transparent;
    color: var(--error);
    padding: 10px 16px;
}

.btn-danger-ghost:hover:not(:disabled) {
    background: var(--error-bg);
    color: var(--error);
}

/* ========== CLOSE BUTTON (dialogs, panels) ========== */

.close-button {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: var(--radius-full);
    background: var(--bg-hover);
    color: var(--text-secondary);
    font: inherit;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.close-button:hover {
    background: var(--border);
}

/* ========== PILLS ========== */
/* A row of pill-shaped toggles. Three kinds share one look:
   - link pills (<a>): server-side filters (Feed, Usage, Articles),
   - button pills (<button>): client-side tabs and filters (Audio, Inbox),
   - checkbox pills (<label> with <input>): multi-select choices (platforms).
   Active = `.is-active` (links, buttons) or a checked input inside. The accent
   colour defaults to --primary; platform pills set --pill-accent to the
   platform colour. */

.pill-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

/* Page-level filter bar above a list or table. */
.pill-group--bar {
    margin-bottom: 16px;
}

.pill {
    --pill-accent: var(--primary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--bg-card);
    color: var(--text-secondary);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}

.pill:hover {
    border-color: var(--pill-accent);
    color: var(--text);
}

.pill.is-active,
.pill:has(input:checked) {
    border-color: var(--pill-accent);
    background: color-mix(in srgb, var(--pill-accent) 10%, transparent);
    color: var(--pill-accent);
}

.pill:disabled,
.pill:has(input:disabled) {
    opacity: 0.55;
    cursor: not-allowed;
}

.pill input[type="checkbox"],
.pill input[type="radio"] {
    margin: 0;
    accent-color: var(--pill-accent);
}

.pill-icon {
    display: inline-flex;
    color: var(--pill-accent);
}

.pill-count {
    font-weight: 400;
    opacity: 0.7;
}

.pill-count:empty {
    display: none;
}

/* Segmented control: one track, equal-width options, one active (theme and language in the account menu).
   The active option is lifted onto the card colour with the accent, like a pill, so it reads as the same family. */
.pill-group--segmented {
    display: grid;
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-flow: column;
    gap: 3px;
    padding: 3px;
    border-radius: var(--radius-md);
    background: var(--bg-hover);
}

.pill-group--segmented .pill {
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    padding: 6px 4px;
    border-color: transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    font-size: 12px;
    line-height: 1.25;
    text-align: center;
    white-space: normal;
}

.pill-group--segmented .pill:hover {
    border-color: transparent;
    background: color-mix(in srgb, var(--bg-card) 60%, transparent);
}

.pill-group--segmented .pill.is-active {
    border-color: var(--primary-border);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

.pill-group--segmented .pill-icon {
    font-size: 15px;
    color: inherit;
}

.pill-group--segmented .pill.is-active .pill-icon {
    color: var(--pill-accent);
}

/* ========== BADGES ========== */
/* Small read-only tag: status, kind, source. Never clickable (use a pill). */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: var(--bg-hover);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.badge--primary { background: var(--primary-light); color: var(--primary); }
.badge--success { background: var(--success-bg); color: var(--success-text); }
.badge--warning { background: var(--warning-bg); color: var(--warning-text); }
.badge--danger  { background: var(--error-bg); color: var(--error-text); }
.badge--info    { background: var(--info-bg); color: var(--info-text); }
.badge--muted   { background: var(--bg-hover); color: var(--text-muted); }

/* ========== COLUMN HANDLES (draggable column borders, rbColumnResize in assets/js/column-resize.js) ========== */

/* Wide hit area on the border, a thin line on hover, keyboard focus and while dragging. The grid it sits on needs
   position: relative; the script places it and hides it when there is no column border (narrow layouts). */
.column-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 5;
    width: 10px;
    margin-left: -5px;
    cursor: col-resize;
    touch-action: none;
}

.column-handle::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 4px;
    width: 2px;
    background: transparent;
    transition: background var(--transition-fast);
}

.column-handle:hover::after,
.column-handle:focus-visible::after,
.column-handle.is-dragging::after {
    background: var(--primary);
}

.column-handle:focus-visible {
    outline: none;
}

/* While dragging: the resize cursor everywhere (the pointer leaves the handle), no text selection. */
.is-column-resizing,
.is-column-resizing * {
    cursor: col-resize !important;
    user-select: none;
}
