/* Software desenvolvido por Henrique Uebel, registro no INPI - BR512025004300-7.
   Licenciado para uso exclusivo da Addaxis Sistemas Ltda, CNPJ: 63.078.814/0001-69. */

/* ============================================================================
   COMPONENTES — Portal Addaxis AI
   ============================================================================
   Cada bloco abaixo reproduz, em CSS puro, as classes que o componente shadcn/ui
   correspondente gerava via Tailwind no sistema legado. A referência de cada um
   está anotada no comentário do bloco, com as classes originais, para que
   qualquer divergência visual seja auditável sem abrir o código React.

   Convenção de nome: .pt-<componente> e modificadores .pt-<componente>--<variante>.
   O prefixo "pt-" (portal) evita colisão com as classes dos HTMLs do dashboard
   que já existem em wwwroot/ — as duas peças convivem sem se contaminar.
   ============================================================================ */

/* ────────────────────────────────────────────────────────────────────────────
   BOTÃO
   Origem: ui/button.tsx
   base: inline-flex items-center justify-center gap-2 whitespace-nowrap
         rounded-md text-sm font-medium transition-colors
         focus-visible:ring-1 focus-visible:ring-ring
         disabled:pointer-events-none disabled:opacity-50
   ──────────────────────────────────────────────────────────────────────────── */

.pt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    line-height: 1.25rem;
    font-weight: 500;
    transition: background-color 150ms, color 150ms, border-color 150ms;
    cursor: pointer;
    /* size "default": h-9 px-4 py-2 */
    height: 2.25rem;
    padding-inline: 1rem;
    padding-block: 0.5rem;
}

.pt-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 1px hsl(var(--ring));
}

.pt-btn:disabled {
    pointer-events: none;
    opacity: 0.5;
}

/* [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:pointer-events-none */
.pt-btn svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    pointer-events: none;
}

/* ── Variantes ── */

/* default: bg-primary text-primary-foreground shadow hover:bg-primary/90 */
.pt-btn--default {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    box-shadow: var(--shadow);
}
.pt-btn--default:hover:not(:disabled) { background-color: hsl(var(--primary) / 0.9); }

/* destructive: bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90 */
.pt-btn--destructive {
    background-color: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
    box-shadow: var(--shadow-sm);
}
.pt-btn--destructive:hover:not(:disabled) { background-color: hsl(var(--destructive) / 0.9); }

/* outline: border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground */
.pt-btn--outline {
    border: 1px solid hsl(var(--input));
    background-color: hsl(var(--background));
    box-shadow: var(--shadow-sm);
}
.pt-btn--outline:hover:not(:disabled) {
    background-color: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}

/* secondary: bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80 */
.pt-btn--secondary {
    background-color: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
    box-shadow: var(--shadow-sm);
}
.pt-btn--secondary:hover:not(:disabled) { background-color: hsl(var(--secondary) / 0.8); }

/* ghost: hover:bg-accent hover:text-accent-foreground */
.pt-btn--ghost { background-color: transparent; }
.pt-btn--ghost:hover:not(:disabled) {
    background-color: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}

/* link: text-primary underline-offset-4 hover:underline */
.pt-btn--link {
    background-color: transparent;
    color: hsl(var(--primary));
    text-underline-offset: 4px;
    height: auto;
    padding: 0;
}
.pt-btn--link:hover:not(:disabled) { text-decoration: underline; }

/* ── Tamanhos ── */

/* sm: h-8 rounded-md px-3 text-xs */
.pt-btn--sm {
    height: 2rem;
    padding-inline: 0.75rem;
    padding-block: 0;
    font-size: 0.75rem;
    line-height: 1rem;
}

/* lg: h-10 rounded-md px-8 */
.pt-btn--lg {
    height: 2.5rem;
    padding-inline: 2rem;
    padding-block: 0;
}

/* icon: h-9 w-9 */
.pt-btn--icon {
    height: 2.25rem;
    width: 2.25rem;
    padding: 0;
}

/* ────────────────────────────────────────────────────────────────────────────
   CARD
   Origem: ui/card.tsx — rounded-xl border bg-card text-card-foreground shadow
   ──────────────────────────────────────────────────────────────────────────── */

.pt-card {
    border-radius: 0.75rem;
    border: 1px solid hsl(var(--border));
    background-color: hsl(var(--card));
    color: hsl(var(--card-foreground));
    box-shadow: var(--shadow);
}

.pt-card__header {           /* flex flex-col space-y-1.5 p-6 */
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
}
.pt-card__header > * + * { margin-top: 0.375rem; }

.pt-card__title {            /* font-semibold leading-none tracking-tight */
    font-weight: 600;
    line-height: 1;
    letter-spacing: -0.025em;
}

.pt-card__description {      /* text-sm text-muted-foreground */
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: hsl(var(--muted-foreground));
}

.pt-card__content {          /* p-6 pt-0 */
    padding: 1.5rem;
    padding-top: 0;
}

.pt-card__footer {           /* flex items-center p-6 pt-0 */
    display: flex;
    align-items: center;
    padding: 1.5rem;
    padding-top: 0;
}

/* ────────────────────────────────────────────────────────────────────────────
   CAMPOS DE FORMULÁRIO
   Origem: ui/input.tsx, ui/textarea.tsx, ui/label.tsx, ui/select.tsx
   ──────────────────────────────────────────────────────────────────────────── */

/* input: flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1
          text-base shadow-sm transition-colors md:text-sm */
.pt-input,
.pt-select,
.pt-textarea {
    display: flex;
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid hsl(var(--input));
    background-color: transparent;
    padding-inline: 0.75rem;
    padding-block: 0.25rem;
    font-size: 1rem;
    color: hsl(var(--foreground));
    box-shadow: var(--shadow-sm);
    transition: border-color 150ms, box-shadow 150ms;
}

.pt-input,
.pt-select { height: 2.25rem; }

.pt-textarea {
    min-height: 4rem;
    padding-block: 0.5rem;
    resize: vertical;
    line-height: 1.5;
}

@media (min-width: 768px) {
    .pt-input, .pt-select, .pt-textarea { font-size: 0.875rem; }
}

.pt-input::placeholder,
.pt-textarea::placeholder { color: hsl(var(--muted-foreground)); }

.pt-input:focus-visible,
.pt-select:focus-visible,
.pt-textarea:focus-visible {
    outline: none;
    box-shadow: 0 0 0 1px hsl(var(--ring));
}

.pt-input:disabled,
.pt-select:disabled,
.pt-textarea:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* O <select> nativo herda o fundo do SO em alguns navegadores; forçamos o token
   para o campo não aparecer branco no tema escuro. */
.pt-select { background-color: hsl(var(--background)); }
.pt-select option { background-color: hsl(var(--popover)); color: hsl(var(--popover-foreground)); }

/* label: text-sm font-medium leading-none peer-disabled:opacity-70 */
.pt-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1;
    margin-bottom: 0.5rem;
}

/* Mensagem de erro de validação sob o campo. */
.pt-field-error {
    font-size: 0.8125rem;
    color: hsl(var(--destructive));
    margin-top: 0.375rem;
}

/* Aviso sob o campo que NÃO bloqueia o envio: alerta de grafia, de duplicidade,
   de consequência. Diferente de .pt-field-error, que marca campo inválido. */
.pt-hint {
    font-size: 0.8125rem;
    line-height: 1.45;
    color: hsl(var(--muted-foreground));
    margin-top: 0.375rem;
}

.pt-hint--alerta {
    color: hsl(38 92% 45%);
    border-left: 2px solid hsl(38 92% 45%);
    padding-left: 0.625rem;
}

@media (prefers-color-scheme: dark) {
    .pt-hint--alerta { color: hsl(38 92% 62%); border-left-color: hsl(38 92% 62%); }
}

.pt-input--invalid,
.pt-select--invalid,
.pt-textarea--invalid { border-color: hsl(var(--destructive)); }

/* Checkbox e switch */
.pt-checkbox {
    width: 1rem;
    height: 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid hsl(var(--input));
    accent-color: hsl(var(--primary));
    cursor: pointer;
    flex-shrink: 0;
}
.pt-checkbox:disabled { cursor: not-allowed; opacity: 0.5; }

.pt-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 2.75rem;
    height: 1.5rem;
    border-radius: 9999px;
    background-color: hsl(var(--secondary));
    border: 1px solid hsl(var(--border));
    transition: background-color 150ms;
    cursor: pointer;
    flex-shrink: 0;
}
.pt-switch[aria-checked="true"] { background-color: hsl(var(--primary)); }
.pt-switch:disabled { cursor: not-allowed; opacity: 0.5; }
.pt-switch__thumb {
    position: absolute;
    left: 0.125rem;
    width: 1.125rem;
    height: 1.125rem;
    border-radius: 9999px;
    background-color: hsl(var(--foreground));
    transition: transform 150ms;
}
.pt-switch[aria-checked="true"] .pt-switch__thumb { transform: translateX(1.25rem); }

/* ────────────────────────────────────────────────────────────────────────────
   BADGE
   Origem: ui/badge.tsx — inline-flex items-center rounded-full border
           px-2.5 py-0.5 text-xs font-semibold
   ──────────────────────────────────────────────────────────────────────────── */

.pt-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 9999px;
    border: 1px solid transparent;
    padding-inline: 0.625rem;
    padding-block: 0.125rem;
    font-size: 0.75rem;
    line-height: 1rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background-color 150ms;
}

.pt-badge--default { background-color: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.pt-badge--secondary { background-color: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.pt-badge--destructive { background-color: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }
.pt-badge--outline { background-color: transparent; border-color: hsl(var(--border)); color: hsl(var(--foreground)); }
.pt-badge--success { background-color: hsl(var(--success)); color: hsl(var(--success-foreground)); }
.pt-badge--warning { background-color: hsl(var(--warning)); color: hsl(var(--warning-foreground)); }

/* ────────────────────────────────────────────────────────────────────────────
   TABELA
   Origem: ui/table.tsx
   ──────────────────────────────────────────────────────────────────────────── */

.pt-table-wrapper {          /* relative w-full overflow-auto */
    position: relative;
    width: 100%;
    overflow: auto;
}

.pt-table {                  /* w-full caption-bottom text-sm */
    width: 100%;
    caption-side: bottom;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.pt-table thead tr { border-bottom: 1px solid hsl(var(--border)); }

.pt-table tbody tr {         /* border-b transition-colors hover:bg-muted/50 */
    border-bottom: 1px solid hsl(var(--border));
    transition: background-color 150ms;
}
.pt-table tbody tr:last-child { border-bottom: 0; }
.pt-table tbody tr:hover { background-color: hsl(var(--muted) / 0.5); }
.pt-table tbody tr[data-selected="true"] { background-color: hsl(var(--muted)); }

.pt-table th {               /* h-10 px-2 text-left align-middle font-medium text-muted-foreground */
    height: 2.5rem;
    padding-inline: 0.5rem;
    text-align: left;
    vertical-align: middle;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    white-space: nowrap;
}

.pt-table td {               /* p-2 align-middle */
    padding: 0.5rem;
    vertical-align: middle;
}

.pt-table tfoot {            /* border-t bg-muted/50 font-medium */
    border-top: 1px solid hsl(var(--border));
    background-color: hsl(var(--muted) / 0.5);
    font-weight: 500;
}

.pt-table caption {          /* mt-4 text-sm text-muted-foreground */
    margin-top: 1rem;
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
}

/* Estado vazio dentro da tabela. */
.pt-table__empty {
    padding-block: 2.5rem;
    text-align: center;
    color: hsl(var(--muted-foreground));
}

/* ────────────────────────────────────────────────────────────────────────────
   ABAS
   Origem: ui/tabs.tsx
   ──────────────────────────────────────────────────────────────────────────── */

.pt-tabs__list {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    border-radius: var(--radius-lg);
    background-color: hsl(var(--muted) / 0.5);
    padding: 0.25rem;
    color: hsl(var(--muted-foreground));
    flex-wrap: wrap;
}

.pt-tabs__trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
    border-radius: var(--radius-md);
    padding-inline: 0.75rem;
    padding-block: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 150ms, color 150ms;
    cursor: pointer;
    background-color: transparent;
    color: inherit;
}

.pt-tabs__trigger:hover:not([aria-selected="true"]) { color: hsl(var(--foreground)); }

.pt-tabs__trigger[aria-selected="true"] {
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    box-shadow: var(--shadow-sm);
}

.pt-tabs__trigger svg { width: 1rem; height: 1rem; flex-shrink: 0; }

.pt-tabs__content { margin-top: 1rem; }

/* ────────────────────────────────────────────────────────────────────────────
   MODAL (dialog / alert-dialog)
   Origem: ui/dialog.tsx, ui/alert-dialog.tsx
   ──────────────────────────────────────────────────────────────────────────── */

.pt-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-overlay);
    background-color: rgb(0 0 0 / 0.8);
    animation: portal-fade-in 150ms ease-out;
}

.pt-dialog {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: var(--z-dialog);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 32rem;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    border: 1px solid hsl(var(--border));
    background-color: hsl(var(--background));
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-lg);
    animation: portal-zoom-in 150ms ease-out;
}

.pt-dialog--lg { max-width: 48rem; }
.pt-dialog--xl { max-width: 64rem; }

.pt-dialog__header {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    text-align: left;
}

.pt-dialog__title {
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1;
    letter-spacing: -0.025em;
}

.pt-dialog__description {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
}

.pt-dialog__footer {
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
}

@media (min-width: 640px) {
    .pt-dialog__footer {
        flex-direction: row;
        justify-content: flex-end;
    }
}

.pt-dialog__close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    border-radius: var(--radius-sm);
    opacity: 0.7;
    background: transparent;
    color: hsl(var(--foreground));
    padding: 0.25rem;
    line-height: 0;
    transition: opacity 150ms;
}
.pt-dialog__close:hover { opacity: 1; }

/* Trava a rolagem do fundo enquanto um modal está aberto. */
body.pt-scroll-locked { overflow: hidden; }

/* ────────────────────────────────────────────────────────────────────────────
   TOAST (sonner)
   Origem: ui/sonner.tsx
   ──────────────────────────────────────────────────────────────────────────── */

.pt-toaster {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: min(24rem, calc(100vw - 2rem));
    pointer-events: none;
}

.pt-toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    border-radius: var(--radius-lg);
    border: 1px solid hsl(var(--border));
    background-color: hsl(var(--popover));
    color: hsl(var(--popover-foreground));
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: portal-slide-in-right 200ms ease-out;
}

.pt-toast--success { border-left: 4px solid hsl(var(--success)); }
.pt-toast--error { border-left: 4px solid hsl(var(--destructive)); }
.pt-toast--warning { border-left: 4px solid hsl(var(--warning)); }
.pt-toast--info { border-left: 4px solid hsl(var(--info)); }

.pt-toast__body { flex: 1 1 0%; min-width: 0; }
.pt-toast__title { font-size: 0.875rem; font-weight: 600; }
.pt-toast__description {
    font-size: 0.8125rem;
    color: hsl(var(--muted-foreground));
    margin-top: 0.125rem;
    overflow-wrap: anywhere;
}
.pt-toast__close {
    background: transparent;
    color: hsl(var(--muted-foreground));
    padding: 0;
    line-height: 0;
    flex-shrink: 0;
}
.pt-toast__close:hover { color: hsl(var(--foreground)); }

/* ────────────────────────────────────────────────────────────────────────────
   MENU SUSPENSO
   Origem: ui/dropdown-menu.tsx
   ──────────────────────────────────────────────────────────────────────────── */

.pt-dropdown { position: relative; display: inline-block; }

.pt-dropdown__content {
    position: absolute;
    right: 0;
    top: calc(100% + 0.25rem);
    z-index: var(--z-dropdown);
    min-width: 10rem;
    overflow: hidden;
    border-radius: var(--radius-md);
    border: 1px solid hsl(var(--border));
    background-color: hsl(var(--popover));
    color: hsl(var(--popover-foreground));
    padding: 0.25rem;
    box-shadow: var(--shadow-md);
    animation: portal-zoom-in 120ms ease-out;
}

.pt-dropdown__item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    border-radius: var(--radius-sm);
    padding-inline: 0.5rem;
    padding-block: 0.375rem;
    font-size: 0.875rem;
    cursor: pointer;
    background: transparent;
    text-align: left;
    transition: background-color 120ms;
}
.pt-dropdown__item:hover { background-color: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.pt-dropdown__item--destructive { color: hsl(var(--destructive)); }
.pt-dropdown__item svg { width: 1rem; height: 1rem; flex-shrink: 0; }

.pt-dropdown__separator {
    height: 1px;
    background-color: hsl(var(--border));
    margin-block: 0.25rem;
    margin-inline: -0.25rem;
}

.pt-dropdown__label {
    padding-inline: 0.5rem;
    padding-block: 0.375rem;
    font-size: 0.875rem;
    font-weight: 600;
}

/* ────────────────────────────────────────────────────────────────────────────
   ESTADOS: carregando, vazio, separador, progresso
   ──────────────────────────────────────────────────────────────────────────── */

/* Spinner do legado: animate-spin rounded-full h-12 w-12 border-b-2 border-primary */
.pt-spinner {
    border-radius: 9999px;
    border: 2px solid transparent;
    border-bottom-color: hsl(var(--primary));
    animation: portal-spin 1s linear infinite;
    width: 3rem;
    height: 3rem;
}
.pt-spinner--sm { width: 1rem; height: 1rem; border-width: 2px; }
.pt-spinner--md { width: 1.5rem; height: 1.5rem; }

.pt-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding-block: 3rem;
}
.pt-loading__text { color: hsl(var(--muted-foreground)); font-weight: 500; }

.pt-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding-block: 3rem;
    text-align: center;
    color: hsl(var(--muted-foreground));
}

.pt-separator {
    height: 1px;
    width: 100%;
    background-color: hsl(var(--border));
    flex-shrink: 0;
}
.pt-separator--vertical { height: auto; width: 1px; align-self: stretch; }

.pt-progress {
    position: relative;
    height: 0.5rem;
    width: 100%;
    overflow: hidden;
    border-radius: 9999px;
    background-color: hsl(var(--secondary));
}
.pt-progress__bar {
    height: 100%;
    background-color: hsl(var(--primary));
    transition: width 300ms ease;
}
.pt-progress__bar--warning { background-color: hsl(var(--warning)); }
.pt-progress__bar--danger { background-color: hsl(var(--destructive)); }

/* ────────────────────────────────────────────────────────────────────────────
   OVERLAY DE ERRO DO BLAZOR
   Substitui o visual padrão amarelo do framework pelo tema do portal.
   ──────────────────────────────────────────────────────────────────────────── */

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background-color: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
    padding: 0.75rem 1.25rem;
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
}

#blazor-error-ui .reload { text-decoration: underline; margin-inline: 0.5rem; }
#blazor-error-ui .dismiss { cursor: pointer; float: right; }

/* ────────────────────────────────────────────────────────────────────────────
   SELETOR DE PAINEL
   Alterna entre o Portal Addaxis AI (negócio) e o painel do Gateway
   (operação: chaves, providers, logs). Ver Shared/SeletorPainel.razor.
   ──────────────────────────────────────────────────────────────────────────── */

.pt-seletor-painel {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem;
    border-radius: var(--radius-lg);
    background-color: hsl(var(--muted) / 0.5);
    border: 1px solid hsl(var(--border));
}

.pt-seletor-painel__item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    border-radius: var(--radius-md);
    padding-inline: 0.75rem;
    padding-block: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    transition: background-color 150ms, color 150ms;
}

.pt-seletor-painel__item:hover { color: hsl(var(--foreground)); }

/* O painel atual fica destacado; o outro permanece discreto. */
.pt-seletor-painel__item--ativo {
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    box-shadow: var(--shadow-sm);
}

/* Em telas estreitas some o rótulo e fica só o ícone, para não empurrar
   o botão "Sair" para fora da linha. */
@media (max-width: 640px) {
    .pt-seletor-painel__item span { display: none; }
}
