/* =============================================================
   Ajustes visuais para componentes Telerik UI for Blazor
   Objetivo: harmonizar bordas, cores e espaçamentos com os
   componentes Radzen (RadzenTextBox, RadzenNumeric, etc.)
   ============================================================= */

/* --- Inputs / NumericTextBox / TextBox --- */

/* Borda exterior do wrapper (igual ao Radzen .rz-textbox) */
.k-input:not(.k-switch):not(.k-checkbox),
.k-picker {
    border: 1px solid #dee2e6 !important;
    border-radius: 4px !important;
    background-color: #fff !important;
    overflow: visible !important;
}

/* Remover estilo Material "underline" dos inputs solid/flat */
.k-input-solid:not(.k-switch):not(.k-checkbox),
.k-input-flat:not(.k-switch):not(.k-checkbox),
.k-picker-solid,
.k-picker-flat {
    border: 1px solid #dee2e6 !important;
    border-radius: 4px !important;
    background-color: #fff !important;
}

/* Remover o pseudo-elemento ::after (underline animado do Material) */
.k-input-solid::after,
.k-input-flat::after,
.k-picker-solid::after,
.k-picker-flat::after {
    display: none !important;
}

/* Inner: sem borda própria, a borda fica no wrapper */
.k-input-inner {
    border: none !important;
    box-shadow: none !important;
    background-color: transparent !important;
}

/* Estados focus / hover */
.k-input:not(.k-switch):not(.k-checkbox):focus-within,
.k-picker:focus-within {
    border-color: #B57F59 !important;
    box-shadow: 0 0 0 2px rgba(181, 127, 89, 0.2) !important;
}

.k-input:not(.k-switch):not(.k-checkbox):hover:not(:focus-within),
.k-picker:hover:not(:focus-within) {
    border-color: #bfc5ca !important;
}

/* Estado disabled */
.k-input.k-disabled:not(.k-switch):not(.k-checkbox),
.k-picker.k-disabled,
.k-disabled > .k-input:not(.k-switch):not(.k-checkbox),
.k-disabled > .k-picker {
    border-color: #dee2e6 !important;
    background-color: #fff !important;
    opacity: 1;
}

/* --- Checkbox (estilos base da v13, ausentes no tema antigo) --- */
.k-checkbox {
    margin: 0;
    padding: 0;
    line-height: initial;
    border-width: 2px;
    border-style: solid;
    border-color: #1D1B20;
    border-radius: 0.25rem;
    outline: 0;
    background-color: unset;
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    display: inline-block;
    flex: none;
    vertical-align: middle;
    position: relative;
    cursor: pointer;
    -webkit-appearance: none;
    width: 1rem;
    height: 1rem;
}

.k-checkbox::before {
    content: "";
    display: block;
    width: 100%;
    height: 100%;
    mask-repeat: no-repeat;
}

.k-checkbox:checked::before,
.k-checkbox.k-checked::before {
    background-color: currentColor;
    mask-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3e%3cpath fill='none' stroke='%23ffffff' stroke-width='3' d='M4.1,12.7 9,17.6 20.3,6.3'/%3e%3c/svg%3e");
}

.k-checkbox:indeterminate::before,
.k-checkbox.k-indeterminate::before {
    background-color: currentColor;
    mask-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23ffffff' stroke-width='3' d='M4 10h12'/%3e%3c/svg%3e");
}

.k-checkbox:checked,
.k-checkbox:indeterminate {
    background-color: #B57F59 !important;
    border-color: #B57F59 !important;
    color: #fff;
}

.k-checkbox:checked:focus,
.k-checkbox:indeterminate:focus {
    box-shadow: 0 0 0 2px rgba(181, 127, 89, 0.3) !important;
}

.k-checkbox:disabled,
.k-checkbox.k-disabled {
    opacity: 0.6;
    cursor: default;
}

.k-checkbox-wrap {
    flex: none;
    display: inline-flex;
    flex-flow: row nowrap;
    align-items: center;
    vertical-align: middle;
    position: relative;
}

.k-checkbox-wrap::before {
    content: "\200B";
    width: 0px;
    overflow: hidden;
    flex: none;
    display: inline-block;
    vertical-align: top;
}

/* --- Switch (estilos base da v13 material, ausentes no tema antigo) --- */
.k-switch {
    box-sizing: border-box;
    outline: 0;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    line-height: 1;
    position: relative;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    width: 52px;
    height: 32px;
}

/* Switch Small */
.k-switch.k-switch-sm {
    width: 40px;
    height: 22px;
}

.k-switch.k-switch-sm .k-switch-track {
    width: 40px;
    height: 22px;
}

.k-switch.k-switch-sm .k-switch-thumb {
    width: 16px;
    height: 16px;
}

.k-switch.k-switch-sm.k-switch-on .k-switch-thumb-wrap {
    inset-inline-start: calc(100% - 11px);
}

.k-switch.k-switch-sm.k-switch-off .k-switch-thumb-wrap {
    inset-inline-start: 11px;
}

.k-switch.k-switch-sm .k-switch-thumb::before {
    width: 32px;
    height: 32px;
}

/* Switch Large */
.k-switch.k-switch-lg {
    width: 60px;
    height: 36px;
}

.k-switch.k-switch-lg .k-switch-track {
    width: 60px;
    height: 36px;
}

.k-switch.k-switch-lg .k-switch-thumb {
    width: 28px;
    height: 28px;
}

.k-switch.k-switch-lg.k-switch-on .k-switch-thumb-wrap {
    inset-inline-start: calc(100% - 18px);
}

.k-switch.k-switch-lg.k-switch-off .k-switch-thumb-wrap {
    inset-inline-start: 18px;
}

.k-switch.k-switch-lg .k-switch-thumb::before {
    width: 44px;
    height: 44px;
}

.k-switch *,
.k-switch *::before,
.k-switch *::after {
    box-sizing: border-box;
}

.k-switch [type=checkbox] {
    display: none;
}

.k-switch-track {
    border-width: 2px;
    border-style: solid;
    border-radius: 9999px;
    outline: 0;
    display: flex;
    flex-flow: row nowrap;
    flex: 1 0 auto;
    position: relative;
    width: 52px;
    height: 32px;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.k-switch-thumb-wrap {
    width: 0;
    height: 0;
    overflow: visible;
    position: absolute;
    inset-block-start: 50%;
}

.k-switch-thumb {
    border-width: 0;
    border-style: solid;
    border-radius: 9999px;
    display: block;
    position: absolute;
    transform: translate(-50%, -50%);
    transition: all 0.2s;
    width: 24px;
    height: 24px;
}

.k-switch-label-on,
.k-switch-label-off {
    display: none;
}

/* Switch ON */
.k-switch-on .k-switch-thumb-wrap {
    inset-inline-start: calc(100% - 16px);
}

.k-switch-on .k-switch-track {
    border-color: #B57F59;
    background-color: #B57F59;
}

.k-switch-on .k-switch-thumb {
    background-color: #fff;
}

/* Switch OFF */
.k-switch-off .k-switch-thumb-wrap {
    inset-inline-start: 16px;
}

.k-switch-off .k-switch-track {
    border-color: #6E687C;
    background-color: #EAE5EC;
}

.k-switch-off .k-switch-thumb {
    background-color: #6E687C;
}

/* Switch hover */
.k-switch .k-switch-thumb::before {
    content: "";
    border-radius: 100%;
    display: none;
    opacity: 0;
    transform: translate(-50%, -50%);
    position: absolute;
    z-index: -1;
    top: 50%;
    left: 50%;
    pointer-events: none;
    width: 40px;
    height: 40px;
    background-color: #B57F59;
}

.k-switch:hover .k-switch-thumb::before {
    display: block;
    opacity: 0.08;
}

.k-switch:focus .k-switch-thumb::before {
    display: block;
    opacity: 0.2;
}

/* Switch disabled */
.k-switch:disabled,
.k-switch.k-disabled {
    opacity: 0.6;
    pointer-events: none;
}

/* RTL */
.k-switch[dir=rtl] .k-switch-thumb,
[dir=rtl] .k-switch .k-switch-thumb {
    transform: translate(50%, -50%);
}

/* --- DropDownList / ComboBox / AutoComplete --- */
.k-dropdownlist,
.k-combobox,
.k-autocomplete,
.k-multiselect {
    border-color: #dee2e6;
}

.k-dropdownlist:focus-within,
.k-combobox:focus-within,
.k-autocomplete:focus-within,
.k-multiselect:focus-within {
    border-color: #B57F59;
    box-shadow: 0 0 0 2px rgba(181, 127, 89, 0.2);
}

/* Item selecionado nos popups */
.k-list-item.k-selected,
.k-selected.k-list-optionlabel {
    background-color: #B57F59 !important;
    color: #fff !important;
}

.k-list-item:hover,
.k-list-optionlabel:hover {
    background-color: rgba(181, 127, 89, 0.1);
}

/* --- DatePicker / TimePicker --- */
.k-datepicker,
.k-timepicker,
.k-datetimepicker {
    border-color: #dee2e6;
}

.k-datepicker:focus-within,
.k-timepicker:focus-within,
.k-datetimepicker:focus-within {
    border-color: #B57F59;
    box-shadow: 0 0 0 2px rgba(181, 127, 89, 0.2);
}

/* Botão do calendário */
.k-datepicker .k-input-button,
.k-timepicker .k-input-button,
.k-datetimepicker .k-input-button {
    color: #B57F59;
}

/* --- Spin buttons do NumericTextBox --- */
.k-numerictextbox .k-input-spinner,
.k-numerictextbox .k-spin-button {
    border-color: #dee2e6;
}

.k-numerictextbox .k-input-spinner .k-button,
.k-numerictextbox .k-spin-button .k-button {
    border-color: #dee2e6;
}

.k-numerictextbox .k-spin-button .k-button:hover {
    background-color: rgba(181, 127, 89, 0.15);
    color: #B57F59;
}

/* --- NumericTextBox - placeholder não cortado --- */
.k-numerictextbox .k-input-inner {
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    padding: 4px 6px !important;
}

/* --- Grid Header - reduzir padding lateral do .k-link --- */
.k-cell-inner > .k-link,
.k-grid-md .k-table-th > .k-cell-inner > .k-link {
    padding: 8px 0px !important;
}

/* --- Editor - botões da toolbar espremidos --- */

/* O tema (falperra-material.css) só dá padding aos botões através das classes de
   tamanho: .k-button-md{padding:8px 16px} e .k-button-md.k-icon-button{padding:8px}.
   Não existe nenhuma regra para o .k-button sozinho. Acontece que os botões da toolbar
   do Editor são emitidos apenas como .k-button.k-icon-button, sem classe de tamanho,
   pelo que nenhuma regra do tema lhes pega e acabam a apanhar o reset do Tailwind
   (button{padding:0}, carregado depois do tema) — colapsam para 18px e ficam
   sobrepostos. Repõe-se aqui o padding equivalente ao .k-button-md.
   O .k-input-button (seta dos dropdowns Format/Font Size/Font Name) fica de fora
   porque esse já é dimensionado pelo wrapper e está correto. */
.k-toolbar .k-button.k-icon-button:not(.k-input-button) {
    padding: 8px;
}

/* --- Linha selecionada nas grids --- */

/* O tema marca a linha selecionada só com rgba(0,0,0,0.04) — um cinzento a 4% que
   é praticamente invisível. Aqui usa-se a cor da app: fundo suave + barra à esquerda.
   As regras aplicam-se às <td> (não à <tr>) de propósito: o hover do tema pinta a
   <tr> com rgba(0,0,0,0.07) e o fundo das células fica por cima, portanto a linha
   selecionada mantém o destaque com o rato em cima. */
.k-grid .k-table-row.k-selected > td,
.k-grid .k-table-row.k-selected > .k-table-td,
.k-grid .k-grid-content-locked .k-table-row.k-selected > .k-table-td,
.k-grid .k-grid-content-locked .k-selected:hover .k-table-td,
.k-grid .k-grid-content-locked .k-selected.k-hover .k-table-td {
    background-color: rgba(181, 127, 89, 0.13) !important;
    box-shadow: inset 0 1px 0 rgba(181, 127, 89, 0.35),
                inset 0 -1px 0 rgba(181, 127, 89, 0.35);
}

/* Barra vertical na primeira célula — o marcador da linha */
.k-grid .k-table-row.k-selected > td:first-child,
.k-grid .k-table-row.k-selected > .k-table-td:first-child,
.k-grid .k-grid-content-locked .k-table-row.k-selected > .k-table-td:first-child {
    box-shadow: inset 3px 0 0 0 #B57F59,
                inset 0 1px 0 rgba(181, 127, 89, 0.35),
                inset 0 -1px 0 rgba(181, 127, 89, 0.35);
}

/* =============================================================
   Gráficos Telerik — variáveis de tema em falta
   -------------------------------------------------------------
   O falperra-material.css é um build antigo do tema Kendo: tem
   39 variáveis --kendo-*, nenhuma delas --kendo-chart-* (o tema
   oficial do 14.1.0 tem 329, incluindo 24 de gráficos).

   O JS do Kendo lê --kendo-chart-bg para construir as opções de
   tema do gráfico. Sem ela não gera as opções dos eixos e a
   largura da linha do eixo fica indefinida; o lineBox() faz
   `x2 = box.x2 - line.width` e devolve NaN, o que degenera o
   clip-path das séries (kdef2) e esconde tudo o que lá está
   dentro. Só afeta séries recortadas — Line e Area ficam
   invisíveis, Column/Bar/Pie não usam esse clip e desenham bem.

   Basta definir esta variável; as restantes continuam a usar os
   fallbacks internos do Kendo, que já produzem o aspeto atual.
   ============================================================= */
:root {
    --kendo-chart-bg: #fff;
}
