/**
 * K-Theme UI foundation.
 *
 * Bootstrap-independent design tokens and primitives shared by parent-theme
 * pages and focused child themes. Keep selectors opt-in: this file must not
 * restyle existing content merely by being loaded.
 */

:root {
    --color-brand-primary: #5e6ad2;
    --color-brand-hover: #7170ff;
    --color-brand-subtle: #f4f5fb;
    --bg-page: #ffffff;
    --bg-subtle: #fafbfc;
    --bg-card: #ffffff;
    --text-primary: #0e0e10;
    --text-secondary: #3c3e44;
    --text-tertiary: #6b6f76;
    --text-on-brand: #ffffff;
    --border-default: #ebeef2;
    --border-strong: #d8dbe0;
    --border-focus: #5e6ad2;
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --shadow-xs: 0 1px 2px rgba(14, 14, 16, 0.04);
    --shadow-sm: 0 1px 3px rgba(14, 14, 16, 0.06), 0 1px 2px rgba(14, 14, 16, 0.04);
    --shadow-focus: 0 0 0 3px rgba(94, 106, 210, 0.12);
}

.ktheme-ui-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
    text-decoration: none;
    transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.ktheme-ui-button--primary {
    border-color: var(--color-brand-primary);
    background: var(--color-brand-primary);
    color: var(--text-on-brand);
}

.ktheme-ui-button--primary:hover,
.ktheme-ui-button--primary:focus-visible {
    border-color: var(--color-brand-hover);
    background: var(--color-brand-hover);
    color: var(--text-on-brand);
}

.ktheme-ui-button--secondary {
    border-color: var(--border-default);
    background: var(--bg-card);
    color: var(--text-primary);
}

.ktheme-ui-button--secondary:hover,
.ktheme-ui-button--secondary:focus-visible {
    border-color: var(--border-strong);
    background: var(--bg-subtle);
    color: var(--text-primary);
}

.ktheme-ui-button:active {
    transform: translateY(1px);
}

.ktheme-ui-button:focus-visible,
.ktheme-ui-search:focus-within {
    outline: 0;
    box-shadow: var(--shadow-focus);
}

.ktheme-ui-search {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 36px;
    overflow: hidden;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.ktheme-ui-search:focus-within {
    border-color: var(--border-focus);
}

.ktheme-ui-search input[type="search"] {
    min-width: 0;
    padding: 0 12px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 14px;
}

.ktheme-ui-search button {
    min-width: 48px;
    padding: 0 12px;
    border: 0;
    border-left: 1px solid var(--border-default);
    background: var(--bg-subtle);
    color: var(--text-secondary);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.16s ease, color 0.16s ease;
}

.ktheme-ui-search button:hover,
.ktheme-ui-search button:focus-visible {
    background: var(--color-brand-subtle);
    color: var(--color-brand-primary);
    outline: 0;
}

.ktheme-ui-badge {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 0 8px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xs);
    background: var(--bg-subtle);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

.ktheme-ui-badge--current-v2 {
    border-color: rgba(94, 106, 210, 0.24);
    background: var(--color-brand-subtle);
    color: var(--color-brand-primary);
}

.ktheme-ui-badge--legacy-theme {
    background: #fffaf2;
    color: #8a5a1f;
}

@media (prefers-reduced-motion: reduce) {
    .ktheme-ui-button,
    .ktheme-ui-search,
    .ktheme-ui-search button {
        transition-duration: 0.01ms !important;
    }
}
