/* App Templates editor — GLOBAL (not scoped). These form, section and row classes are shared across
   three separate Blazor components — MarketGroupEditor, MarketGroupRowEditor and BetslipTemplateEditor
   — and Blazor scoped CSS cannot cross a component boundary (see .claude/rules/04). Keeping one copy
   here also removes the duplicated .mge-*/.fdt-cat__icon blocks the scoped files used to carry. */

/* ---- Loading state --------------------------------------------------------------------------- */
.sm-tpl-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sm-space-2);
    padding: var(--sm-space-6);
    color: var(--sm-color-text-muted);
}

.sm-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--sm-color-border);
    border-top-color: var(--sm-color-primary);
    border-radius: 50%; /* a full circle — no token for this */
    animation: sm-spin 0.7s linear infinite;
}

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

/* ---- Field grid + individual fields ---------------------------------------------------------- */
.mge-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sm-space-3);
}

.mge-field {
    display: flex;
    flex-direction: column;
    gap: var(--sm-space-1);
    min-width: 0;
}

.mge-field--full {
    grid-column: 1 / -1;
}

.mge-field--check {
    justify-content: flex-end;
}

.mge-label {
    font-size: var(--sm-font-size-sm);
    font-weight: var(--sm-font-weight-500);
    color: var(--sm-color-text-muted);
}

/* ---- Fieldset: the grouping primitive -------------------------------------------------------- */
/* A labelled group of related fields. Lightweight (no card) so it nests cleanly inside a row card;
   consecutive fieldsets get a hairline divider so the groups read as a hierarchy. */
.mge-fieldset {
    display: flex;
    flex-direction: column;
    gap: var(--sm-space-3);
}

.mge-fieldset + .mge-fieldset {
    padding-top: var(--sm-space-3);
    border-top: 1px solid var(--sm-color-border);
}

.mge-fieldset__title {
    font-size: var(--sm-font-size-sm);
    font-weight: var(--sm-font-weight-700);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--sm-color-text-muted);
    margin: 0;
}

.mge-fieldset__hint {
    font-size: var(--sm-font-size-sm);
    color: var(--sm-color-text-muted);
    margin: calc(var(--sm-space-1) * -1) 0 0;
}

/* ---- Headings + misc ------------------------------------------------------------------------- */
.mge-rows-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sm-space-2);
}

.mge-subtitle {
    font-size: var(--sm-font-size-lg);
    font-weight: var(--sm-font-weight-600);
    color: var(--sm-color-text);
    margin: 0;
}

.mge-subtitle--small {
    font-size: var(--sm-font-size-base);
}

.mge-muted {
    color: var(--sm-color-text-muted);
}

.mge-banner {
    padding: var(--sm-space-3) var(--sm-space-4);
    border-radius: var(--sm-radius-md);
    background: var(--sm-color-warning-bg);
    color: var(--sm-color-warning);
}

/* ---- Market-group editor shell --------------------------------------------------------------- */
.mge-panel {
    display: flex;
    flex-direction: column;
    gap: var(--sm-space-3);
    min-width: 0;
}

.mge-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--sm-space-2);
}

.mge-panel__actions {
    display: flex;
    align-items: center;
    gap: var(--sm-space-2);
}

/* A file <input> can't be an SmButton, so the upload control is a label styled to match the
   secondary button next to it; the real InputFile is visually hidden but still label-activated. */
.mge-filebtn {
    display: inline-flex;
    align-items: center;
    height: 40px;
    padding: 0 var(--sm-space-4);
    border: 1px solid var(--sm-color-border);
    border-radius: var(--sm-radius-lg);
    background: var(--sm-color-surface);
    color: var(--sm-color-text);
    font-size: var(--sm-font-size-sm);
    font-weight: var(--sm-font-weight-500);
    cursor: pointer;
}

.mge-filebtn:hover {
    background: var(--sm-color-surface-alt);
}

.mge-filebtn__input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

.mge-panel__titlewrap {
    display: flex;
    align-items: center;
    gap: var(--sm-space-2);
    min-width: 0;
}

.mge-panel__title {
    font-size: var(--sm-font-size-lg);
    font-weight: var(--sm-font-weight-700);
    color: var(--sm-color-text);
    margin: 0;
}

.mge-panel__body {
    display: flex;
    flex-direction: column;
    gap: var(--sm-space-3);
    max-height: calc(100vh - 220px);
    overflow-y: auto;
    padding-right: var(--sm-space-2);
}

/* ---- Rows ------------------------------------------------------------------------------------ */
.mge-rows {
    display: flex;
    flex-direction: column;
    gap: var(--sm-space-3);
}

.mge-row {
    border: 1px solid var(--sm-color-border);
    border-radius: var(--sm-radius-md);
    padding: var(--sm-space-3);
    display: flex;
    flex-direction: column;
    gap: var(--sm-space-3);
    background: var(--sm-color-surface);
}

.mge-row__head {
    display: flex;
    align-items: center;
    gap: var(--sm-space-2);
}

.mge-row__type {
    flex: 1 1 auto;
    font-weight: var(--sm-font-weight-600);
    color: var(--sm-color-text);
    text-transform: capitalize;
}

.mge-row__include {
    flex: 1 1 auto;
    color: var(--sm-color-text-muted);
    font-size: var(--sm-font-size-sm);
}

/* ---- Selections + column headers ------------------------------------------------------------- */
.mge-headers-toggle {
    margin-bottom: var(--sm-space-1);
}

.mge-sel {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: var(--sm-space-2);
    align-items: end;
}

/* Header input is prepended as a fourth column when the row has column headers. */
.mge-sel--headed {
    grid-template-columns: 1fr 1fr 1fr 1fr auto;
}

/* ---- Shared icon button (remove / edit affordances in row and selection heads) --------------- */
.fdt-cat__icon {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--sm-color-text-muted);
    display: inline-flex;
    padding: var(--sm-space-1);
    border-radius: var(--sm-radius-sm);
}

.fdt-cat__icon:hover {
    background: var(--sm-color-surface-alt);
    color: var(--sm-color-text);
}
