/*
 * EatSmart admin: controls — buttons, fields, toggles (docs/ADMIN-UI.md §2.3).
 */

/* Primary button: Filament picks its own shades by contrast and chose the light sage with dark
   text. The pair is set here from the tokens instead: ink sage + white in light mode, light sage
   + dark text in dark mode (both 5:1 and up). Filament reads these variables, so hover and
   disabled states keep working. */
.fi-btn.fi-color-primary:not(.fi-outlined) {
    --bg: var(--es-accent-fill);
    --text: var(--es-on-accent);
    --hover-bg: color-mix(in srgb, var(--es-accent-fill) 88%, var(--es-text));
    --hover-text: var(--es-on-accent);
    --dark-bg: var(--es-accent-fill);
    --dark-text: var(--es-on-accent);
    --dark-hover-bg: color-mix(in srgb, var(--es-accent-fill) 85%, var(--es-raised));
    --dark-hover-text: var(--es-on-accent);
}

/* Secondary buttons (gray in Filament: «Отменить», «Закрыть», «Выход»): raised paper with a
   hairline, text colour — they must not compete with the one primary action. */
.fi-btn.fi-color-gray:not(.fi-outlined),
.fi-btn:not(.fi-color):not(.fi-outlined) {
    --bg: var(--es-raised);
    --text: var(--es-text);
    --hover-bg: var(--es-surface);
    --hover-text: var(--es-text);
    --dark-bg: var(--es-raised);
    --dark-text: var(--es-text);
    --dark-hover-bg: color-mix(in srgb, var(--es-raised) 80%, var(--es-text));
    --dark-hover-text: var(--es-text);
    background: var(--es-raised);
    color: var(--es-text);
    box-shadow: inset 0 0 0 1px var(--es-hairline);
}
.fi-btn.fi-color-gray:not(.fi-outlined):hover,
.fi-btn:not(.fi-color):not(.fi-outlined):hover {
    background: var(--es-surface);
}

/* Dangerous actions (delete, block, switch off): the ink terracotta, white text in light mode. */
.fi-btn.fi-color-danger:not(.fi-outlined) {
    --bg: var(--es-over-ink);
    --text: var(--es-raised);
    --hover-bg: color-mix(in srgb, var(--es-over-ink) 88%, var(--es-text));
    --hover-text: var(--es-raised);
    --dark-bg: var(--es-over-ink);
    --dark-text: var(--es-page);
    --dark-hover-bg: color-mix(in srgb, var(--es-over-ink) 85%, var(--es-raised));
    --dark-hover-text: var(--es-page);
}

/* One height for buttons and fields in a row: 36. Text never wraps inside a button. */
.fi-btn {
    border-radius: var(--es-radius-control);
    min-height: 36px;
    padding-inline: 14px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}
.fi-btn.fi-size-sm,
.fi-btn.fi-size-xs {
    min-height: 32px;
    padding-inline: 12px;
    font-size: 13px;
}

/* Text links (row actions, «Использовать код восстановления»): ink colour, no bright green. */
.fi-link {
    color: var(--es-accent-ink);
}
.fi-link.fi-color-danger {
    color: var(--es-over-ink);
}
.fi-link.fi-color-gray {
    color: var(--es-muted);
}

/* ---------- Fields ---------- */

.fi-fo-field-label-content {
    font-size: 13px;
    font-weight: 500;
    color: var(--es-text);
}
/* The required mark is a quiet dot of terracotta, not a red alarm on every label. */
.fi-fo-field-label-required-mark {
    color: var(--es-over);
}

/* Fields are raised paper with a hairline; focus thickens the line to sage instead of a glow. */
.fi-input-wrp {
    background: var(--es-raised);
    border-radius: var(--es-radius-control);
    --tw-ring-color: var(--es-hairline);
    box-shadow: inset 0 0 0 1px var(--es-hairline);
}
.fi-input-wrp:not(.fi-disabled):not(:has(.fi-input-wrp-actions :focus)):focus-within {
    box-shadow: inset 0 0 0 1px var(--es-accent), 0 0 0 3px color-mix(in srgb, var(--es-accent) 22%, transparent);
}
.fi-input-wrp.fi-invalid {
    box-shadow: inset 0 0 0 1px var(--es-over);
}
.fi-input-wrp.fi-disabled {
    background: var(--es-surface);
}
/* Inside a field the outline from the global focus rule would double the sage line. */
.fi-input-wrp :focus-visible {
    outline: none;
}
.fi-input,
.fi-select-input,
.fi-fo-textarea {
    color: var(--es-text);
    font-size: 14px;
    min-height: 34px;
}
.fi-input::placeholder,
.fi-fo-textarea::placeholder {
    color: color-mix(in srgb, var(--es-muted) 80%, transparent);
}
/* Prefix and suffix («$», «в сутки»): muted, part of the field, not separate boxes. */
.fi-input-wrp-prefix,
.fi-input-wrp-suffix,
.fi-input-wrp-label {
    color: var(--es-muted);
    border-color: var(--es-hairline);
    font-size: 13px;
}

/* Helper text under a field and validation messages. */
.fi-fo-field-wrp-hint,
.fi-sc-text,
.fi-fo-field .fi-fo-field-content-col > .fi-sc-text {
    color: var(--es-muted);
}
.fi-fo-field-wrp-error-message {
    color: var(--es-over-ink);
    font-size: 12.5px;
}

/* Toggles and checkboxes: sage when on, the track colour when off. */
.fi-toggle {
    background: var(--es-track);
    box-shadow: inset 0 0 0 1px var(--es-hairline);
}
.fi-toggle.fi-toggle-on {
    background: var(--es-accent-fill);
    box-shadow: none;
}
.fi-checkbox-input {
    background-color: var(--es-raised);
    box-shadow: inset 0 0 0 1px var(--es-hairline);
    border-radius: 5px;
}
.fi-checkbox-input:checked {
    background-color: var(--es-accent-fill);
    box-shadow: none;
}

/* Dropdown lists: the same pill hover as the menu. */
.fi-dropdown-list-item {
    border-radius: 8px;
    color: var(--es-text);
}
.fi-dropdown-list-item:hover,
.fi-dropdown-list-item:focus-visible {
    background: var(--es-surface);
}
.fi-dropdown-list-item.fi-color-danger,
.fi-dropdown-list-item.fi-color-danger .fi-dropdown-list-item-label {
    color: var(--es-over-ink);
}
.fi-dropdown-list + .fi-dropdown-list {
    border-color: var(--es-hairline);
}
.fi-select-input-option:hover,
.fi-select-input-option[aria-selected="true"] {
    background: var(--es-surface);
}

/* ---------- Notifications ---------- */

/* A slip of raised paper in the corner with a coloured edge; no icons in bright colours. */
.fi-no-notification {
    background: var(--es-raised);
    border-radius: var(--es-radius-block);
    box-shadow: var(--es-shadow-float), inset 0 0 0 1px var(--es-hairline);
}
.fi-no-notification-title {
    font-weight: 500;
    color: var(--es-text);
}
.fi-no-notification-body {
    color: var(--es-muted);
}

/* ---------- Callouts (warnings inside a form or card) ---------- */

.fi-callout {
    border-radius: var(--es-radius-control);
    box-shadow: none;
}

/* The emergency switch sits apart from the form: it acts at once, not on «Сохранить». */
.es-switch-section {
    margin-top: 8px;
}

/* The save bar stays at the bottom of the screen while the form scrolls. */
.fi-sc-actions.fi-sticky,
.fi-form-actions.fi-sticky {
    background: color-mix(in srgb, var(--es-page) 92%, transparent);
    border-top: 1px solid var(--es-hairline);
    backdrop-filter: blur(6px);
}

/* Price table inside the settings: compact cells, numbers on the right. */
.fi-fo-table-repeater input[type="number"],
.fi-fo-table-repeater input[inputmode="decimal"] {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Blocks side by side end on one line, even when one has a line of helper text more. */
.fi-grid-col:has(> .fi-sc-component > .es-equal-height),
.fi-sc-component:has(> .es-equal-height),
.es-equal-height,
.es-equal-height > .fi-section {
    height: 100%;
}

/* Price table: like a data table — small muted heads without fill, hairlines, rows of 44. */
.fi-fo-table-repeater table {
    border-color: var(--es-hairline);
}
.fi-fo-table-repeater th {
    background: transparent;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--es-muted);
    padding: 8px 12px;
    border-color: var(--es-hairline);
}
.fi-fo-table-repeater td {
    padding: 4px 8px;
    border-color: var(--es-hairline);
}
.fi-fo-table-repeater td .fi-input-wrp {
    box-shadow: none;
    background: transparent;
}
.fi-fo-table-repeater td .fi-input-wrp:focus-within {
    box-shadow: inset 0 0 0 1px var(--es-accent);
    background: var(--es-raised);
}
/* A bin in every row would shout; it turns terracotta only under the pointer or focus. */
.fi-fo-table-repeater-actions .fi-icon-btn {
    color: var(--es-muted);
}
.fi-fo-table-repeater-actions .fi-icon-btn:hover,
.fi-fo-table-repeater-actions .fi-icon-btn:focus-visible {
    color: var(--es-over-ink);
}
