/* Zinkly components (redesign 2026, step 1, beta)
 *
 * Reusable building blocks that use only the tokens in zk-tokens.css.
 * Every class starts with .zt- so it changes nothing until a template opts in;
 * existing pages look exactly as before. Later steps move screens onto these classes
 * one at a time and retire the older override layers behind them.
 * Loaded after AdminCP > Site design, so these win over older layers where a template uses them.
 */

/* ---------- Buttons: primary, secondary, ghost, danger x sm / md / lg ---------- */
.zt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--zt-s-2);
    min-height: var(--zt-control-h);
    padding: 0 var(--zt-s-4);
    border: 1px solid transparent;
    border-radius: var(--zt-r-pill);
    font: inherit;
    font-size: .875rem;
    font-weight: var(--zt-fw-semibold);
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: background-color var(--zt-dur) var(--zt-ease), border-color var(--zt-dur) var(--zt-ease),
                color var(--zt-dur) var(--zt-ease), transform var(--zt-dur-fast) var(--zt-ease);
}
.zt-btn:focus-visible { outline: none; box-shadow: var(--zt-focus); }
.zt-btn:active:not(:disabled) { transform: scale(.97); }
.zt-btn:disabled, .zt-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.zt-btn > svg { width: 1.125rem; height: 1.125rem; flex-shrink: 0; }

.zt-btn--primary { background: var(--zt-brand); color: var(--zt-on-brand); }
.zt-btn--primary:hover:not(:disabled) { background: var(--zt-brand-strong); }

.zt-btn--secondary { background: var(--zt-surface-2); color: var(--zt-text); border-color: var(--zt-border); }
.zt-btn--secondary:hover:not(:disabled) { background: var(--zt-surface-3); border-color: var(--zt-border-strong); }

.zt-btn--ghost { background: transparent; color: var(--zt-text-2); }
.zt-btn--ghost:hover:not(:disabled) { background: var(--zt-surface-2); color: var(--zt-text); }

.zt-btn--danger { background: var(--zt-danger); color: #fff; }
.zt-btn--danger:hover:not(:disabled) { background: var(--zt-danger-strong); }

.zt-btn--sm { min-height: 32px; padding: 0 var(--zt-s-3); font-size: var(--zt-fs-sm); }
.zt-btn--lg { min-height: 48px; padding: 0 var(--zt-s-5); font-size: var(--zt-fs-body); }
.zt-btn--block { width: 100%; }
.zt-btn--icon { width: var(--zt-control-h); padding: 0; }
.zt-btn--icon.zt-btn--sm { width: 32px; }

@media (max-width: 767px) {
    .zt-btn { min-height: var(--zt-tap); }
    .zt-btn--icon { width: var(--zt-tap); }
}

/* ---------- Inputs ---------- */
.zt-input, .zt-select, .zt-textarea {
    display: block;
    width: 100%;
    min-height: var(--zt-tap);
    padding: 0 var(--zt-s-3);
    border: 1px solid var(--zt-border);
    border-radius: var(--zt-r-sm);
    background: var(--zt-surface-2);
    color: var(--zt-text);
    font: inherit;
    font-size: var(--zt-fs-body);
    transition: border-color var(--zt-dur) var(--zt-ease), box-shadow var(--zt-dur) var(--zt-ease);
}
.zt-textarea { padding: var(--zt-s-3); min-height: 96px; line-height: var(--zt-lh-body); resize: vertical; }
.zt-input::placeholder, .zt-textarea::placeholder { color: var(--zt-text-3); opacity: 1; }
.zt-input:hover, .zt-select:hover, .zt-textarea:hover { border-color: var(--zt-border-strong); }
.zt-input:focus, .zt-select:focus, .zt-textarea:focus {
    outline: none;
    border-color: var(--zt-brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--zt-brand) 28%, transparent);
}
.zt-input[aria-invalid="true"], .zt-textarea[aria-invalid="true"] { border-color: var(--zt-danger); }
.zt-label { display: block; margin-bottom: var(--zt-s-1); font-size: var(--zt-fs-sm); font-weight: var(--zt-fw-medium); color: var(--zt-text-2); }
.zt-help { margin-top: var(--zt-s-1); font-size: var(--zt-fs-sm); color: var(--zt-text-3); }
.zt-error { margin-top: var(--zt-s-1); font-size: var(--zt-fs-sm); color: var(--zt-danger); }

/* ---------- Cards ---------- */
.zt-card {
    background: var(--zt-surface);
    border: 1px solid var(--zt-border);
    border-radius: var(--zt-r-md);
    box-shadow: var(--zt-shadow-1);
}
.zt-card--pad { padding: var(--zt-s-4); }
.zt-card--interactive { transition: border-color var(--zt-dur) var(--zt-ease), transform var(--zt-dur) var(--zt-ease); }
.zt-card--interactive:hover { border-color: var(--zt-border-strong); }
@media (hover: hover) { .zt-card--interactive:hover { transform: translateY(-1px); } }
.zt-card__title { font-size: var(--zt-fs-lg); font-weight: var(--zt-fw-semibold); line-height: var(--zt-lh-tight); color: var(--zt-text); }
.zt-card__meta { font-size: var(--zt-fs-sm); color: var(--zt-text-3); }

/* ---------- Menus and popups ---------- */
.zt-menu {
    min-width: 200px;
    padding: var(--zt-s-1);
    background: var(--zt-surface-2);
    border: 1px solid var(--zt-border);
    border-radius: var(--zt-r-md);
    box-shadow: var(--zt-shadow-2);
}
.zt-menu__item {
    display: flex;
    align-items: center;
    gap: var(--zt-s-3);
    width: 100%;
    min-height: 40px;
    padding: 0 var(--zt-s-3);
    border-radius: calc(var(--zt-r-md) - 6px);
    background: none;
    border: 0;
    color: var(--zt-text);
    font: inherit;
    font-size: .875rem;
    text-align: start;
    cursor: pointer;
}
.zt-menu__item > svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--zt-text-2); }
.zt-menu__item:hover, .zt-menu__item:focus-visible { background: var(--zt-surface-3); outline: none; }
.zt-menu__item--danger { color: var(--zt-danger); }
.zt-menu__sep { height: 1px; margin: var(--zt-s-1) 0; background: var(--zt-border); }

.zt-modal-backdrop { position: fixed; inset: 0; background: var(--zt-overlay); }
.zt-modal {
    background: var(--zt-surface);
    border: 1px solid var(--zt-border);
    border-radius: calc(var(--zt-r-md) + 4px);
    box-shadow: var(--zt-shadow-2);
}

/* ---------- Chips, badges, tabs ---------- */
.zt-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--zt-s-1);
    min-height: 32px;
    padding: 0 var(--zt-s-3);
    border: 1px solid var(--zt-border);
    border-radius: var(--zt-r-pill);
    background: var(--zt-surface);
    color: var(--zt-text-2);
    font-size: var(--zt-fs-sm);
    font-weight: var(--zt-fw-medium);
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--zt-dur) var(--zt-ease), color var(--zt-dur) var(--zt-ease);
}
.zt-chip:hover { background: var(--zt-surface-2); color: var(--zt-text); }
.zt-chip[aria-pressed="true"], .zt-chip.is-active { background: var(--zt-brand); border-color: var(--zt-brand); color: var(--zt-on-brand); }

.zt-badge {
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    padding: 0 var(--zt-s-2);
    border-radius: var(--zt-r-pill);
    background: var(--zt-surface-3);
    color: var(--zt-text-2);
    font-size: var(--zt-fs-cap);
    font-weight: var(--zt-fw-semibold);
    line-height: 1;
}
.zt-badge--brand { background: var(--zt-brand-soft); color: var(--zt-brand-ink); }
.zt-badge--danger { background: color-mix(in srgb, var(--zt-danger) 16%, transparent); color: var(--zt-danger); }
.zt-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--zt-brand); flex-shrink: 0; }

.zt-tabs { display: flex; gap: var(--zt-s-1); border-bottom: 1px solid var(--zt-border); }
.zt-tab {
    position: relative;
    padding: var(--zt-s-3) var(--zt-s-3);
    color: var(--zt-text-3);
    font-size: .875rem;
    font-weight: var(--zt-fw-medium);
    white-space: nowrap;
}
.zt-tab:hover { color: var(--zt-text); }
.zt-tab[aria-selected="true"], .zt-tab.is-active { color: var(--zt-text); }
.zt-tab[aria-selected="true"]::after, .zt-tab.is-active::after {
    content: ""; position: absolute; left: var(--zt-s-3); right: var(--zt-s-3); bottom: -1px;
    height: 2px; border-radius: 2px; background: var(--zt-brand);
}

/* ---------- Navigation item (sidebar, rails) ---------- */
.zt-nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--zt-s-3);
    min-height: 40px;
    padding: 0 var(--zt-s-3);
    border-radius: var(--zt-r-sm);
    color: var(--zt-text-2);
    font-size: .875rem;
    font-weight: var(--zt-fw-medium);
    transition: background-color var(--zt-dur) var(--zt-ease), color var(--zt-dur) var(--zt-ease);
}
.zt-nav-item > svg { width: 20px; height: 20px; flex-shrink: 0; }
.zt-nav-item:hover { background: var(--zt-surface-2); color: var(--zt-text); }
.zt-nav-item[aria-current="page"], .zt-nav-item.is-active { background: var(--zt-brand-soft); color: var(--zt-text); font-weight: var(--zt-fw-semibold); }
.zt-nav-item[aria-current="page"] > svg, .zt-nav-item.is-active > svg { color: var(--zt-brand-ink); }

/* ---------- Empty states and skeletons ---------- */
.zt-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--zt-s-2);
    padding: var(--zt-s-7) var(--zt-s-5);
    text-align: center;
    color: var(--zt-text-2);
}
.zt-empty__icon {
    display: grid; place-items: center;
    width: 56px; height: 56px; margin-bottom: var(--zt-s-2);
    border-radius: 50%;
    background: var(--zt-brand-soft);
    color: var(--zt-brand-ink);
}
.zt-empty__icon > svg { width: 26px; height: 26px; }
.zt-empty__title { font-size: var(--zt-fs-lg); font-weight: var(--zt-fw-semibold); color: var(--zt-text); }
.zt-empty__text { max-width: 32ch; font-size: var(--zt-fs-sm); line-height: var(--zt-lh-body); }

.zt-skeleton {
    display: block;
    border-radius: var(--zt-r-sm);
    background: linear-gradient(90deg, var(--zt-surface-2) 25%, var(--zt-surface-3) 37%, var(--zt-surface-2) 63%);
    background-size: 400% 100%;
    animation: zt-shimmer 1.4s ease infinite;
}
@keyframes zt-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- Glass (floating bars only) ---------- */
.zt-glass { background: var(--zt-surface); }
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .zt-glass { background: var(--zt-glass-bg); -webkit-backdrop-filter: var(--zt-glass-blur); backdrop-filter: var(--zt-glass-blur); }
}
@media (prefers-reduced-transparency: reduce) {
    .zt-glass { background: var(--zt-surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* ---------- Icons: one stroke, three sizes ---------- */
.zt-icon { width: 20px; height: 20px; flex-shrink: 0; stroke-width: 1.75; }
.zt-icon--sm { width: 16px; height: 16px; }
.zt-icon--lg { width: 24px; height: 24px; }

/* ---------- Utilities ---------- */
.zt-no-scrollbar { scrollbar-width: none; }
.zt-no-scrollbar::-webkit-scrollbar { display: none; }
.zt-truncate { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zt-text-2 { color: var(--zt-text-2); }
.zt-text-3 { color: var(--zt-text-3); }
.zt-enter { animation: zt-enter var(--zt-dur-slow) var(--zt-ease) both; }
@keyframes zt-enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Reduced motion: no movement, instant state changes ---------- */
@media (prefers-reduced-motion: reduce) {
    .zt-btn, .zt-card--interactive, .zt-chip, .zt-nav-item, .zt-input, .zt-select, .zt-textarea { transition: none; }
    .zt-btn:active:not(:disabled), .zt-card--interactive:hover { transform: none; }
    .zt-skeleton, .zt-enter { animation: none; }
}
