/* ============================================================
   brand-kit.css — LeagueHub shared component styles
   Scope: admin/scoring/superadmin. Classes prefixed `.lh-` to
   avoid Bootstrap collision. All values from tokens in style.css.
   Source: docs/BRAND-KIT.md §6 Component Catalog.
   ============================================================ */

/* ── Typography helpers (bindings for --text-* tokens) ─────── */
.lh-text-page-title {
    font-family: var(--font-heading);
    font-size: var(--text-page-title-size);
    font-weight: var(--text-page-title-weight);
    line-height: var(--text-page-title-lh);
    color: var(--text);
    margin: 0;
}

.lh-text-page-subtitle {
    font-family: var(--font-sans);
    font-size: var(--text-page-subtitle-size);
    font-weight: var(--text-page-subtitle-weight);
    line-height: var(--text-page-subtitle-lh);
    color: var(--text-secondary);
    margin: 0;
}

.lh-text-card-title {
    font-family: var(--font-heading);
    font-size: var(--text-card-title-size);
    font-weight: var(--text-card-title-weight);
    line-height: var(--text-card-title-lh);
    color: var(--text);
    margin: 0;
}

.lh-text-mono-label {
    font-family: var(--font-mono);
    font-size: var(--text-mono-label-size);
    font-weight: var(--text-mono-label-weight);
    line-height: var(--text-mono-label-lh);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* ── PageHeader ────────────────────────────────────────────── */
.lh-page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.lh-page-header__text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.lh-page-header__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

@media (max-width: 575.98px) {
    .lh-page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .lh-page-header__actions {
        width: 100%;
    }
}

/* ── Global focus-visible catch-all (WCAG 2.4.7) ─────────── */
:where(.admin-content, .admin-sidebar, .admin-topbar) :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ── Card ──────────────────────────────────────────────────── */
.lh-card {
    /* position: relative is required so .stretched-link children (e.g. the
       admin dashboard stat cards) scope their ::after overlay to this card
       instead of the nearest positioned ancestor — without it, every
       stretched-link expands to the page and the last one painted
       (Suspensions on the admin dashboard) steals every click. */
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--lh-shadow-sm);
    overflow: hidden;
    transition: box-shadow var(--lh-motion-fast) ease-out,
                border-color var(--lh-motion-fast) ease-out;
}

.lh-card--interactive:hover {
    box-shadow: var(--lh-shadow-lg);
    border-color: var(--border);
    cursor: pointer;
}

.lh-card__header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* Card-header headings inherit the display font without requiring a helper class.
   Applies to the <h1>-<h6> directly inside .lh-card__header across admin + scoring. */
.lh-card__header h1,
.lh-card__header h2,
.lh-card__header h3,
.lh-card__header h4,
.lh-card__header h5,
.lh-card__header h6 {
    font-family: var(--font-heading);
    font-size: var(--text-card-title-size);
    font-weight: var(--text-card-title-weight);
    line-height: var(--text-card-title-lh);
    color: var(--text);
    margin: 0;
}

.lh-card__body {
    padding: 20px;
}

.lh-card__body--flush {
    padding: 0;   /* use when body holds a table or list that owns its own padding */
}

.lh-card__footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-light);
    background: var(--bg);
}

/* ── DataTable ─────────────────────────────────────────────── */
.lh-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    font-family: var(--font-sans);
    font-size: var(--text-body-size);
    color: var(--text);
}

.lh-table thead {
    background: var(--slate);
}

.lh-table thead th {
    padding: 12px 16px;
    text-align: left;
    font-family: var(--font-mono);
    font-size: var(--text-mono-label-size);
    font-weight: 600;
    line-height: var(--text-mono-label-lh);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.85);
    border: none;
    white-space: nowrap;
}

.lh-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.lh-table tbody tr:last-child td {
    border-bottom: none;
}

.lh-table tbody tr {
    transition: background-color var(--lh-motion-fast) ease-out;
}
.lh-table tbody tr:hover {
    background: var(--accent-light);
}

.lh-table tbody tr.lh-table__row--selected {
    background: var(--accent-light);
}

.lh-table__cell--numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.lh-table__cell--center { text-align: center; }

/* ── FormField ─────────────────────────────────────────────── */
.lh-form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lh-form-field__label {
    font-family: var(--font-sans);
    font-size: var(--text-body-strong-size);
    font-weight: var(--text-body-strong-weight);
    line-height: var(--text-body-strong-lh);
    color: var(--text);
}

.lh-form-field__required {
    color: var(--danger);
    margin-left: 2px;
}

.lh-form-field__input,
.lh-form-field__select,
.lh-form-field__textarea {
    width: 100%;
    min-height: 48px;  /* WCAG touch target */
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: var(--text-body-size);
    color: var(--text);
    transition: border-color var(--lh-motion-fast) ease-out,
                box-shadow var(--lh-motion-fast) ease-out;
}

.lh-form-field__input:focus-visible,
.lh-form-field__select:focus-visible,
.lh-form-field__textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-color: var(--accent);
}

.lh-form-field__input::placeholder,
.lh-form-field__textarea::placeholder {
    color: var(--text-muted);
}

.lh-form-field--invalid .lh-form-field__input,
.lh-form-field--invalid .lh-form-field__select,
.lh-form-field--invalid .lh-form-field__textarea {
    border-color: var(--danger);
}

.lh-form-field--invalid .lh-form-field__input:focus-visible,
.lh-form-field--invalid .lh-form-field__select:focus-visible,
.lh-form-field--invalid .lh-form-field__textarea:focus-visible {
    outline-color: var(--danger);
}

.lh-form-field__error {
    font-family: var(--font-sans);
    font-size: var(--text-micro-size);
    color: var(--danger);
    display: flex;
    align-items: center;
    gap: 4px;
}

.lh-form-field__hint {
    font-family: var(--font-sans);
    font-size: var(--text-micro-size);
    color: var(--text-muted);
}

.lh-form-field__input:disabled,
.lh-form-field__select:disabled,
.lh-form-field__textarea:disabled {
    background: var(--bg);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* ── StatCard ──────────────────────────────────────────────── */
.lh-stat-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--lh-shadow-sm);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 120px;
}

.lh-stat-card__label {
    font-family: var(--font-mono);
    font-size: var(--text-mono-label-size);
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.lh-stat-card__value {
    font-family: var(--font-heading);
    font-size: var(--text-stat-size);
    font-weight: var(--text-stat-weight);
    line-height: var(--text-stat-lh);
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.lh-stat-card__trend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-sans);
    font-size: var(--text-micro-size);
    font-weight: 500;
}

.lh-stat-card__trend--up    { color: var(--success); }
.lh-stat-card__trend--down  { color: var(--danger); }
.lh-stat-card__trend--flat  { color: var(--text-muted); }

/* ── SearchBar ─────────────────────────────────────────────── */
.lh-search {
    position: relative;
    display: flex;
    align-items: center;
}

.lh-search__icon {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    pointer-events: none;
    font-size: 16px;
    line-height: 1;
}

.lh-search__input {
    width: 100%;
    min-height: 48px;
    padding: 10px 12px 10px 40px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: var(--text-body-size);
    color: var(--text);
    transition: border-color var(--lh-motion-fast) ease-out;
}

.lh-search__input::placeholder { color: var(--text-muted); }

.lh-search__input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-color: var(--accent);
}

/* ── Button ────────────────────────────────────────────────── */
.btn-lh-primary,
.btn-lh-secondary,
.btn-lh-danger,
.btn-lh-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-family: var(--font-sans);
    font-size: var(--text-body-strong-size);
    font-weight: var(--text-body-strong-weight);
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
    transition: background-color var(--lh-motion-fast) ease-out,
                border-color var(--lh-motion-fast) ease-out,
                color var(--lh-motion-fast) ease-out;
}

.btn-lh-primary {
    background: var(--accent);
    color: var(--white);
    border-color: var(--accent);
}
.btn-lh-primary:hover,
.btn-lh-primary:focus-visible {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
    color: var(--white);
}

.btn-lh-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}
.btn-lh-secondary:hover,
.btn-lh-secondary:focus-visible {
    background: var(--bg);
    border-color: var(--text-muted);
    color: var(--text);
}

.btn-lh-danger {
    background: var(--danger);
    color: var(--white);
    border-color: var(--danger);
}
.btn-lh-danger:hover,
.btn-lh-danger:focus-visible {
    background: var(--danger-hover);
    border-color: var(--danger-hover);
    color: var(--white);
}

.btn-lh-ghost {
    background: transparent;
    color: var(--text);
    border-color: transparent;
}
.btn-lh-ghost:hover,
.btn-lh-ghost:focus-visible {
    background: var(--bg);
    color: var(--text);
}

.btn-lh-primary:focus-visible,
.btn-lh-secondary:focus-visible,
.btn-lh-danger:focus-visible,
.btn-lh-ghost:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn-lh-primary:disabled,
.btn-lh-secondary:disabled,
.btn-lh-danger:disabled,
.btn-lh-ghost:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-lh-sm {
    min-height: 36px;
    padding: 0 12px;
    font-size: var(--text-micro-size);
}

.btn-lh--loading {
    position: relative;
    color: transparent !important;
}

.btn-lh--loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-right-color: transparent;
    color: var(--white);
    animation: lh-btn-spin 0.6s linear infinite;
}

.btn-lh-secondary.btn-lh--loading::after,
.btn-lh-ghost.btn-lh--loading::after {
    color: var(--text);
}

@keyframes lh-btn-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .btn-lh--loading::after { animation: none; }
    .btn-lh-primary, .btn-lh-secondary, .btn-lh-danger, .btn-lh-ghost,
    .lh-card, .lh-table tbody tr, .lh-form-field__input, .lh-form-field__select,
    .lh-form-field__textarea, .lh-search__input {
        transition: none;
    }
}

/* ── Badge ─────────────────────────────────────────────────── */
.badge-lh-success,
.badge-lh-danger,
.badge-lh-warning,
.badge-lh-info,
.badge-lh-purple,
.badge-lh-neutral {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: var(--text-mono-label-size);
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge-lh-success { background: var(--success-bg); color: var(--success); }
.badge-lh-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-lh-warning { background: var(--warning-bg); color: var(--warning-dark); }
.badge-lh-info    { background: var(--info-bg);    color: var(--info); }
.badge-lh-purple  { background: var(--purple-bg);  color: var(--purple); }
.badge-lh-neutral { background: var(--border-light); color: var(--text-secondary); }

/* ── Global :focus-visible on in-scope Bootstrap buttons ──── */
/* Narrow scope: only inside .admin-content / .admin-sidebar / .scoring-container */
.admin-content :focus-visible:not(.btn-lh-primary, .btn-lh-secondary, .btn-lh-danger, .btn-lh-ghost),
.scoring-container :focus-visible:not(.btn-lh-primary, .btn-lh-secondary, .btn-lh-danger, .btn-lh-ghost) {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
