/**
 * LaraForm — default theme.
 *
 * Every visual decision reads a --lf-* token, so restyling is overriding tokens (in :root,
 * a wrapper class, or a Tailwind layer) — never fighting selectors. Tailwind apps can feed
 * theme() values into the tokens, or switch to laraform-headless.css and bring utilities
 * via config('laraform.classes').
 */

:root {
    --lf-font: inherit;
    --lf-text: #1f2937;
    --lf-muted: #6b7280;
    --lf-accent: #2563eb;
    --lf-invalid: #dc2626;

    --lf-bg: #ffffff;
    --lf-bg-disabled: #f3f4f6;
    --lf-border: #d1d5db;
    --lf-border-hover: #9ca3af;
    --lf-radius: 0.375rem;

    --lf-control-height: 2.25rem;
    --lf-control-size: 0.875rem;
    --lf-control-pad-x: 0.625rem;
    --lf-label-size: 0.8125rem;
    --lf-gap: 1rem;

    --lf-focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.25);
    --lf-invalid-ring: 0 0 0 3px rgba(220, 38, 38, 0.2);

    --lf-popup-bg: #ffffff;
    --lf-popup-border: #d1d5db;
    --lf-popup-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    --lf-option-active-bg: #eff6ff;
    --lf-option-selected: #2563eb;

    --lf-chip-bg: #e5e7eb;
    --lf-chip-text: #1f2937;
}

/* ---------------------------------------------------------------- structure (shared) */

.lf-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.lf-hidden-native {
    display: none !important;
}

.lf-field {
    margin-bottom: var(--lf-gap);
    font-family: var(--lf-font);
    color: var(--lf-text);
}

.lf-combo,
.lf-multi,
.lf-date,
.lf-number {
    position: relative;
}

.lf-popup {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    z-index: 50;
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    max-height: min(18rem, 40vh);
    overflow-y: auto;
}

.lf-popup[hidden] {
    display: none;
}

/* ------------------------------------------------------------------------ labels */

.lf-label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: var(--lf-label-size);
    font-weight: 600;
    color: var(--lf-text);
}

.lf-label--inline {
    display: inline;
    margin: 0;
    font-weight: 400;
    font-size: var(--lf-control-size);
}

.lf-required {
    color: var(--lf-invalid);
    margin-left: 0.125rem;
}

/* ---------------------------------------------------------------------- controls */

.lf-control {
    display: block;
    width: 100%;
    height: var(--lf-control-height);
    padding: 0 var(--lf-control-pad-x);
    font-family: var(--lf-font);
    font-size: var(--lf-control-size);
    color: var(--lf-text);
    background: var(--lf-bg);
    border: 1px solid var(--lf-border);
    border-radius: var(--lf-radius);
    outline: none;
    transition: border-color 120ms ease, box-shadow 120ms ease;
    box-sizing: border-box;
}

.lf-control:hover:not(:disabled):not(:focus) {
    border-color: var(--lf-border-hover);
}

.lf-control:focus {
    border-color: var(--lf-accent);
    box-shadow: var(--lf-focus-ring);
}

.lf-control:disabled {
    background: var(--lf-bg-disabled);
    color: var(--lf-muted);
    cursor: not-allowed;
}

.lf-control::placeholder {
    color: var(--lf-muted);
}

.lf-textarea {
    height: auto;
    padding: 0.5rem var(--lf-control-pad-x);
    resize: vertical;
    min-height: var(--lf-control-height);
}

select.lf-control {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 0 1 1.06.02L10 11.06l3.71-3.83a.75.75 0 1 1 1.08 1.04l-4.25 4.39a.75.75 0 0 1-1.08 0L5.21 8.27a.75.75 0 0 1 .02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1rem;
    padding-right: 2rem;
}

/* Numbers are right-aligned (the laragrid editor convention). */
.lf-number-input {
    text-align: right;
}

/* Y/N: a narrow centered one-character box. */
.lf-yesno-input {
    max-width: 5rem;
    text-align: center;
    text-transform: uppercase;
}

.lf-number--prefixed .lf-number-input {
    padding-left: 1.75rem;
}

.lf-number-prefix {
    position: absolute;
    left: 0.625rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: var(--lf-control-size);
    color: var(--lf-muted);
    pointer-events: none;
}

/* -------------------------------------------------------------------- help / error */

.lf-help {
    margin: 0.25rem 0 0;
    font-size: 0.75rem;
    color: var(--lf-muted);
}

.lf-error {
    margin: 0.25rem 0 0;
    font-size: 0.75rem;
    color: var(--lf-invalid);
}

.lf-field--invalid .lf-control {
    border-color: var(--lf-invalid);
}

.lf-field--invalid .lf-control:focus {
    box-shadow: var(--lf-invalid-ring);
}

/* ------------------------------------------------------------------------ popups */

.lf-popup {
    background: var(--lf-popup-bg);
    border: 1px solid var(--lf-popup-border);
    border-radius: var(--lf-radius);
    box-shadow: var(--lf-popup-shadow);
}

.lf-option {
    padding: 0.375rem 0.625rem;
    font-size: var(--lf-control-size);
    border-radius: calc(var(--lf-radius) - 2px);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.lf-option--active {
    background: var(--lf-option-active-bg);
}

.lf-option[aria-selected="true"] {
    color: var(--lf-option-selected);
    font-weight: 600;
}

.lf-option--check[aria-selected="true"]::before {
    content: "✓";
    font-weight: 700;
}

.lf-option--check[aria-selected="false"]::before {
    content: "";
    width: 0.875em;
    display: inline-block;
}

.lf-option--empty {
    color: var(--lf-muted);
    cursor: default;
}

/* ---------------------------------------------------------------- checkbox / radio */

.lf-field--check {
    display: block;
}

.lf-check-row {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: var(--lf-control-size);
}

.lf-checkbox,
.lf-radio {
    width: 1rem;
    height: 1rem;
    accent-color: var(--lf-accent);
    cursor: pointer;
}

.lf-checkbox:focus-visible,
.lf-radio:focus-visible,
.lf-toggle:focus-visible {
    outline: 2px solid var(--lf-accent);
    outline-offset: 2px;
}

.lf-fieldset {
    border: 0;
    padding: 0;
    margin: 0 0 var(--lf-gap);
    min-width: 0;
}

.lf-fieldset .lf-label {
    padding: 0;
}

.lf-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.lf-group--inline {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1rem;
}

/* ------------------------------------------------------------------------ toggle */

.lf-toggle {
    appearance: none;
    -webkit-appearance: none;
    width: 2.25rem;
    height: 1.25rem;
    border-radius: 999px;
    background: var(--lf-border);
    position: relative;
    cursor: pointer;
    transition: background 150ms ease;
    flex-shrink: 0;
}

.lf-toggle::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: calc(1.25rem - 4px);
    height: calc(1.25rem - 4px);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    transition: transform 150ms ease;
}

.lf-toggle:checked {
    background: var(--lf-accent);
}

.lf-toggle:checked::before {
    transform: translateX(1rem);
}

/* ------------------------------------------------------------------------- chips */

.lf-multi-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    min-height: var(--lf-control-height);
    padding: 0.25rem var(--lf-control-pad-x);
    background: var(--lf-bg);
    border: 1px solid var(--lf-border);
    border-radius: var(--lf-radius);
    cursor: text;
    box-sizing: border-box;
}

.lf-multi--open .lf-multi-box,
.lf-multi-box:focus-within {
    border-color: var(--lf-accent);
    box-shadow: var(--lf-focus-ring);
}

.lf-chips {
    display: contents;
}

.lf-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.25rem 0.125rem 0.5rem;
    font-size: 0.75rem;
    background: var(--lf-chip-bg);
    color: var(--lf-chip-text);
    border-radius: calc(var(--lf-radius) - 2px);
}

.lf-chip-x {
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size: 0.875rem;
    line-height: 1;
    padding: 0 0.125rem;
    color: inherit;
    border-radius: 2px;
}

.lf-chip-x:hover {
    color: var(--lf-invalid);
}

.lf-multi-input {
    flex: 1 1 6rem;
    width: auto;
    min-width: 6rem;
    height: 1.5rem;
    border: 0;
    padding: 0;
    box-shadow: none;
}

.lf-multi-input:focus {
    border: 0;
    box-shadow: none;
}

/* ------------------------------------------------------------------------ actions */

.lf-actions {
    margin-top: calc(var(--lf-gap) * 1.25);
}

.lf-submit {
    height: var(--lf-control-height);
    padding: 0 1.25rem;
    font-size: var(--lf-control-size);
    font-weight: 600;
    color: #fff;
    background: var(--lf-accent);
    border: 1px solid var(--lf-accent);
    border-radius: var(--lf-radius);
    cursor: pointer;
    transition: filter 120ms ease;
}

.lf-submit:hover {
    filter: brightness(1.08);
}

.lf-submit:focus-visible {
    outline: 2px solid var(--lf-accent);
    outline-offset: 2px;
}

/* ------------------------------------------------------------------------- panels */

.lf-panel {
    width: min(var(--lf-panel-width, 28rem), 95vw);
    max-height: 90vh;
    border: 0;
    border-radius: calc(var(--lf-radius) * 2);
    padding: 0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    color: var(--lf-text);
    font-family: var(--lf-font);
}

.lf-panel::backdrop {
    background: rgba(15, 23, 42, 0.45);
}

.lf-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem 0;
}

.lf-panel-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.lf-panel-x {
    border: 0;
    background: transparent;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0.25rem;
    border-radius: var(--lf-radius);
    color: var(--lf-muted);
    cursor: pointer;
}

.lf-panel-x:hover {
    color: var(--lf-text);
}

.lf-panel-body {
    padding: 1rem 1.25rem 0.25rem;
    max-height: 70vh;
    overflow: auto;
}

.lf-panel-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.25rem 1.25rem;
}

.lf-panel-hint {
    font-size: 0.75rem;
    color: var(--lf-muted);
}

/* --------------------------------------------------------------------- responsive */

@media (pointer: coarse) {
    :root {
        --lf-control-height: 2.75rem; /* 44px touch targets */
    