/* design_system/forms.css — Form controls, multi-select, checkbox, switch, file */

/* Form elements */
.section-title {
    font-size: var(--text-caption);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

.field-label {
    display: block;
    font-size: var(--text-caption);
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 0.35rem;
}
.text-input, .select-input, .textarea-input {
    width: 100%;
    min-height: var(--control-height);
    padding: var(--control-padding-y) var(--control-padding-x);
    font-size: var(--control-font-size);
    line-height: 1.25;
    font-family: inherit;
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input);
    background: #fff;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.text-input::placeholder, .textarea-input::placeholder { color: var(--color-text-muted); }
.text-input:focus, .select-input:focus, .textarea-input:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-soft);
}
.select-input {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%235F6368'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px;
    padding-right: 2rem;
}

/* Multi-select filter (search forms): trigger looks like .select-input; panel with checkboxes */
.multi-select-filter {
    position: relative;
    width: 100%;
}
button.multi-select-filter__trigger.select-input {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    text-align: left;
    font: inherit;
    color: inherit;
    background-color: #fff;
    background-image: none;
    padding-right: 1rem;
}
.multi-select-filter__summary {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
    color: var(--color-text);
}
.multi-select-filter__chevron {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    color: var(--color-text-muted);
    transition: transform 0.2s ease;
}
.multi-select-filter--open .multi-select-filter__chevron {
    transform: rotate(180deg);
}
.multi-select-filter__panel {
    position: absolute;
    z-index: 60;
    left: 0;
    right: 0;
    top: calc(100% + 0.35rem);
    max-height: 14rem;
    overflow: hidden;
    padding: 0.35rem 0;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input);
    box-shadow: 0 8px 24px rgba(32, 33, 36, 0.12);
}
.multi-select-filter__scroll {
    max-height: 13rem;
    overflow-y: auto;
    padding: 0.25rem 0.5rem 0.35rem;
}
.multi-select-filter__option {
    margin: 0;
    padding: 0.4rem 0.5rem;
    border-radius: calc(var(--radius-input) - 0.125rem);
    font-size: var(--control-font-size);
}
.multi-select-filter__option:hover {
    background: var(--color-bg-alt);
}
.multi-select-filter__option-text {
    font-weight: 500;
    color: var(--color-text);
    line-height: 1.35;
    white-space: normal;
}
.multi-select-filter__empty {
    margin: 0;
    padding: 0.75rem 1rem;
    font-size: var(--text-md);
    color: var(--color-text-muted);
}
.textarea-input { min-height: 5.5rem; resize: vertical; }
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--color-border);
    border-radius: 3px;
    cursor: pointer;
    accent-color: var(--color-accent);
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-accent);
    cursor: pointer;
    box-shadow: 0 2px 6px var(--color-accent-soft);
}

/* Checkbox, Radio */
.checkbox-row, .radio-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: var(--text-ui);
    font-weight: 500;
    color: var(--color-text);
    cursor: pointer;
}
.checkbox-custom, .radio-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-border);
    border-radius: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.radio-custom { border-radius: 50%; }
input[type="checkbox"]:checked + .checkbox-custom {
    background: var(--color-accent);
    border-color: var(--color-accent);
}
input[type="checkbox"]:checked + .checkbox-custom::after {
    content: '';
    display: block;
    width: 6px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}
input[type="radio"]:checked + .radio-custom {
    border-color: var(--color-accent);
    background: #fff;
    box-shadow: inset 0 0 0 5px var(--color-accent);
}
input[type="checkbox"], input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }

/* Switch */
.switch-field {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
}
.switch-field .switch-row-hint {
    margin-top: 0.35rem;
}
.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text);
    cursor: pointer;
}
.switch-row--control-only {
    display: inline-flex;
    justify-content: flex-start;
    gap: 0;
    width: auto;
}
.switch-row-content {
    min-width: 0;
    flex: 1;
}
.switch-row-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text);
}
.switch-row-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: var(--text-sm);
    font-weight: 400;
    color: var(--color-text-muted);
}
.switch-track {
    width: 48px;
    height: 26px;
    border-radius: 13px;
    background: var(--color-border);
    position: relative;
    flex-shrink: 0;
    transition: background 0.2s;
}
.switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}
input[type="checkbox"].switch-input { position: absolute; opacity: 0; pointer-events: none; }
input[type="checkbox"].switch-input:checked + .switch-track { background: var(--color-accent); }
input[type="checkbox"].switch-input:checked + .switch-track .switch-thumb { transform: translateX(22px); }
.switch-row:has(input[type="checkbox"].switch-input:focus-visible) .switch-track {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* File input */
.file-input-wrap { position: relative; }
.file-input-wrap input[type="file"] { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.file-input-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: var(--control-padding-y) var(--control-padding-x);
    min-height: var(--control-height);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-input);
    background: var(--color-bg-alt);
    font-size: var(--control-font-size);
    color: var(--color-text-muted);
}
.file-input-display svg { width: 16px; height: 16px; color: var(--color-text-muted); }
.file-input-wrap:hover .file-input-display { border-color: var(--color-accent); background: var(--color-accent-soft); }

/* Entity tabs (shared nav_buttons) — segmented control, sidebar-like density */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem 1.5rem; }
.form-grid-full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--color-border); }
.field-hint { font-size: var(--text-sm); color: var(--color-text-muted); margin-top: 0.35rem; }

/* Avoid overflow in grid/flex form fields (mobile Safari in particular) */
.form-grid > * { min-width: 0; }
.text-input, .select-input, .textarea-input { max-width: 100%; }
select.select-input { min-width: 0; }

/* Comp section (componenti) */
.comp-section { margin-bottom: 2rem; }
.comp-section-title {
    font-size: var(--text-caption);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
}
.comp-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }

/* Index toolbar (search + actions) */
.index-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.index-toolbar__search {
    min-width: 0;
    flex: 1;
}
.index-toolbar__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* ========== Features Board (hierarchical inline editor) ========== */
