/* =============================================================
   COMPONENT / INPUT
   
   Все текстовые поля через :is(), различия — точечно.
   ============================================================= */

/* ---------------------------------------------------------
   ОБЩЕЕ — для всех текстовых полей
   --------------------------------------------------------- */
:is(input[type="text"],
    input[type="search"],
    input[type="tel"],
    input[type="password"],
    input[type="email"],
    input[type="number"],
    input[type="date"],
    input[type="datetime-local"],
    textarea,
    select) {
    font: inherit;
    color: var(--text-primary);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: 0;
    padding: 8px 12px;
    transition: background-color .15s ease, border-color .15s ease;
}

/* ---------------------------------------------------------
   ФОКУС — один раз для всех
   --------------------------------------------------------- */
:is(input[type="text"],
    input[type="search"],
    input[type="tel"],
    input[type="password"],
    input[type="email"],
    input[type="number"],
    input[type="date"],
    input[type="datetime-local"],
    textarea,
    select):focus {
    background-color: var(--blue-100);
    border-color: var(--blue-500);
    outline: none;
}

/* ---------------------------------------------------------
   РАЗЛИЧИЯ
   --------------------------------------------------------- */

/* Текстовые поля — ширина по контенту */
:is(input[type="text"],
    input[type="search"],
    input[type="tel"],
    input[type="password"],
    input[type="email"]) {
    width: auto;
    text-overflow: ellipsis;
}

/* Числовое — на всю ширину, по центру, без стрелок */
input[type="number"] {
    width: 100%;
    text-align: center;
    appearance: textfield;
    -webkit-appearance: textfield;
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    display: none;
}

/* Дата / время — на всю ширину, свой padding */
:is(input[type="date"], input[type="datetime-local"]) {
    width: 100%;
    border-color: transparent;
    padding-block: 8px;
    padding-inline: 8px 12px;
}

/* Select — padding асимметричный под стрелку */
select {
    width: 100%;
    padding-block: 9px;
    padding-inline: 9px 16px;
}

/* Textarea — на всю ширину, вертикальный ресайз */
textarea {
    display: block;
    width: 100%;
    border-radius: 0;
    resize: vertical;
    min-height: 80px;
}

/* ---------------------------------------------------------
   СОСТОЯНИЯ
   --------------------------------------------------------- */

/* Readonly — данные можно скопировать, но не менять */
[readonly] {
    background-color: var(--bg-surface-alt);
    color: var(--text-secondary);
    border-color: var(--border-default);
    box-shadow: none;
    cursor: default;
}

/* Disabled — полностью недоступно */
[disabled] {
    background-color: var(--bg-surface-alt);
    color: var(--text-tertiary);
    border-color: var(--border-light);
    box-shadow: none;
    cursor: not-allowed;
    opacity: .7;
}

/* Невалидное значение */
:is(input, select, textarea):invalid {
    background-color: var(--red-100);
    border-color: var(--red-500);
}

/* ---------------------------------------------------------
   В ТАБЛИЦАХ — поля без границ
   --------------------------------------------------------- */
table :is(input, select, textarea) {
    background-color: transparent;
    border-color: transparent;
}

/* Фокус в таблице — подсветка фона */
table :is(input, select, textarea):focus {
    background-color: var(--blue-100);
}

/* ---------------------------------------------------------
   ЧЕКБОКСЫ И РАДИО
   --------------------------------------------------------- */
input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--blue-500);
    --focus-color: var(--blue-500);
}

/* ---------------------------------------------------------
   ВЫДЕЛЕНИЕ ТЕКСТА
   --------------------------------------------------------- */
::selection {
    background-color: var(--blue-300);
    color: var(--blue-900);
}