@import 'tailwindcss';

@source '../**/*.blade.php';
@source '../**/*.js';
@source '../**/*.vue';

/*
 * Identidade visual FLXWash
 * Cores extraídas do logotipo oficial (Logo_FLXWash.png):
 * - navy:     azul-marinho (cor principal; navy-950 = fundo do selo do logo)
 * - electric: azul elétrico (destaque / ações; electric-500 = "Wash")
 * - aqua:     verde-água (secundária; aqua-400 = linha do carro)
 * Textos sobre fundo claro usam tons 700+ para manter contraste AA.
 */
@theme {
    --font-sans: 'Inter', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
        'Noto Color Emoji';

    --color-navy-50: #f0f4fa;
    --color-navy-100: #dde6f3;
    --color-navy-200: #c2d1e9;
    --color-navy-300: #98b2d9;
    --color-navy-400: #678bc4;
    --color-navy-500: #456bad;
    --color-navy-600: #345391;
    --color-navy-700: #2b4376;
    --color-navy-800: #1b2f57;
    --color-navy-900: #0f1f3d;
    --color-navy-950: #000f20;

    --color-electric-50: #ebfaff;
    --color-electric-100: #d2f3fe;
    --color-electric-200: #a6e8fd;
    --color-electric-300: #66d8fb;
    --color-electric-400: #1fc6f7;
    --color-electric-500: #00b4f0;
    --color-electric-600: #0091cc;
    --color-electric-700: #0072a6;
    --color-electric-800: #075f88;
    --color-electric-900: #0c4f70;

    --color-aqua-50: #ebfffd;
    --color-aqua-100: #cbfffa;
    --color-aqua-200: #9bfdf5;
    --color-aqua-300: #55f6ee;
    --color-aqua-400: #14e9e6;
    --color-aqua-500: #00cdcc;
    --color-aqua-600: #00a4a7;
    --color-aqua-700: #038287;
    --color-aqua-800: #0a676c;
    --color-aqua-900: #0e5559;
}

/* Cabeçalhos fixos (site e sistema) não cobrem o destino de âncoras. */
html {
    scroll-padding-block-start: 6rem;
}

@layer components {
    .form-label {
        @apply mb-1.5 block text-sm font-medium text-navy-900;
    }

    /* 16px evita o zoom automático do iOS; 48px de altura atende alvos de toque;
       borda slate-500 garante contraste mínimo de 3:1 com o fundo branco. */
    .form-input {
        @apply block min-h-12 w-full rounded-lg border border-slate-500 bg-white px-3.5 py-2.5 text-base text-navy-950 shadow-xs transition-colors placeholder:text-slate-500 focus:border-electric-600 focus:ring-3 focus:ring-electric-500/25 focus:outline-none;
    }

    /* Padrão de escrita (utils/letterCase.js): caixa alta, e-mail em minúsculo. */
    [data-letter-case='upper'] {
        @apply uppercase placeholder:normal-case;
    }

    [data-letter-case='lower'] {
        @apply lowercase placeholder:normal-case;
    }

    /* :user-invalid só marca o campo depois que a pessoa interagiu com ele. */
    .form-input:user-invalid,
    .form-input[aria-invalid='true'] {
        @apply border-red-600 focus:border-red-600 focus:ring-red-500/20;
    }

    .form-hint {
        @apply mt-1.5 text-sm text-slate-600;
    }

    .form-error {
        @apply mt-1.5 text-sm text-red-700;
    }

    .btn-primary {
        @apply inline-flex min-h-12 items-center justify-center gap-2 rounded-lg bg-electric-700 px-5 py-2.5 text-sm font-semibold text-white shadow-xs transition-colors hover:bg-electric-800 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-electric-700 disabled:cursor-not-allowed disabled:opacity-60;
    }

    .btn-secondary {
        @apply inline-flex min-h-12 items-center justify-center gap-2 rounded-lg border border-slate-300 bg-white px-5 py-2.5 text-sm font-semibold text-navy-900 shadow-xs transition-colors hover:bg-slate-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-electric-700;
    }

    /* Botões sobre fundo azul-marinho. */
    .btn-accent {
        @apply inline-flex min-h-12 items-center justify-center gap-2 rounded-lg bg-electric-400 px-5 py-2.5 text-sm font-semibold text-navy-950 transition-colors hover:bg-electric-300 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-electric-300;
    }

    .btn-outline-light {
        @apply inline-flex min-h-12 items-center justify-center gap-2 rounded-lg border border-white/30 px-5 py-2.5 text-sm font-semibold text-white transition-colors hover:bg-white/10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white;
    }

    /* Ação destrutiva ou de desativação (confirmações). */
    .btn-danger {
        @apply inline-flex min-h-12 items-center justify-center gap-2 rounded-lg bg-red-700 px-5 py-2.5 text-sm font-semibold text-white shadow-xs transition-colors hover:bg-red-800 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-red-700;
    }

    /* Ações compactas em linhas de tabela e listas. */
    .action-link {
        @apply inline-flex min-h-10 items-center gap-1.5 rounded-md px-2.5 text-sm font-medium whitespace-nowrap text-electric-700 transition-colors hover:bg-electric-50 hover:text-electric-800 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-electric-700;
    }

    .link {
        @apply font-medium text-electric-700 underline-offset-4 hover:text-electric-800 hover:underline;
    }

    /* Placa em texto (listas): ABC-1234 ou ABC1D23. */
    .plate-chip {
        @apply inline-block rounded-md border-2 border-navy-950 bg-white px-2 py-0.5 font-mono text-sm font-bold tracking-wider whitespace-nowrap text-navy-950 tabular-nums;
    }

    .card {
        @apply rounded-xl border border-slate-200 bg-white shadow-xs;
    }

    /* Passos numerados do atendimento rápido (veículo, serviços, resumo). */
    .step-title {
        @apply flex items-center gap-3 text-lg font-semibold text-navy-950 outline-none;
    }

    .step-number {
        @apply flex size-7 shrink-0 items-center justify-center rounded-full bg-electric-600 text-sm font-bold text-white;
    }

    .badge {
        @apply inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium;
    }

    .eyebrow {
        @apply text-sm font-semibold tracking-wider text-electric-700 uppercase;
    }
}

/* Texto corrido das páginas legais (privacidade e termos). */
.legal-content {
    color: var(--color-slate-700);
    line-height: 1.75;

    > * + * {
        margin-block-start: 1rem;
    }

    h2 {
        margin-block-start: 2.5rem;
        font-size: 1.25rem;
        font-weight: 700;
        color: var(--color-navy-950);
        text-wrap: balance;
    }

    ul {
        padding-inline-start: 1.25rem;
        list-style: disc;
    }

    li + li {
        margin-block-start: 0.375rem;
    }

    strong {
        color: var(--color-navy-900);
    }

    a {
        font-weight: 500;
        color: var(--color-electric-700);
        text-decoration: underline;
        text-underline-offset: 3px;
    }
}

/*
 * Revelação suave ao rolar a página (CSS puro, sem JavaScript).
 * Sem suporte a animações por rolagem, ou com movimento reduzido,
 * o conteúdo simplesmente aparece no estado final.
 */
@keyframes reveal-up {
    from {
        opacity: 0;
        translate: 0 1.5rem;
    }
}

.reveal {
    @media (prefers-reduced-motion: no-preference) {
        @supports (animation-timeline: view()) {
            animation: reveal-up linear both;
            animation-timeline: view();
            animation-range: entry 0% entry 60%;
        }
    }
}

/*
 * Navegação do site público: uma única lista que vira popover quando a
 * linha não cabe (estado padrão, inclusive sem JavaScript) e navegação
 * inline quando cabe (classe .is-wide definida por useFitNavigation).
 */
.site-header {
    .header-inner > * {
        flex-shrink: 0;
        white-space: nowrap;
    }

    .site-menu {
        position: fixed;
        inset: auto;
        inset-block-start: 4.75rem;
        inset-inline: 1rem;
        /* O navegador aplica width: fit-content a [popover]; auto ocupa o espaço entre as margens. */
        inline-size: auto;
        block-size: fit-content;
        max-block-size: calc(100dvh - 6rem);
        margin: 0;
        padding: 0.5rem;
        overflow: auto;
        border: 1px solid rgb(255 255 255 / 0.1);
        border-radius: 1rem;
        background: var(--color-navy-900);
        color: white;
        box-shadow: 0 24px 48px -12px rgb(0 0 0 / 0.5);
    }

    .site-menu:is(:popover-open, .\:popover-open) {
        display: grid;
        gap: 0.25rem;
    }

    .site-menu a {
        display: block;
        border-radius: 0.5rem;
        padding: 0.75rem 1rem;
        font-weight: 500;
        color: var(--color-navy-100);

        &:hover {
            background: rgb(255 255 255 / 0.08);
            color: white;
        }

        &[aria-current='page'] {
            color: white;
            text-decoration: underline;
            text-decoration-color: var(--color-aqua-400);
            text-decoration-thickness: 2px;
            text-underline-offset: 6px;
        }
    }

    &.is-wide {
        .menu-button {
            display: none;
        }

        .site-menu {
            position: static;
            display: flex;
            align-items: center;
            gap: 0.25rem;
            max-block-size: none;
            padding: 0;
            overflow: visible;
            border: 0;
            background: transparent;
            box-shadow: none;
            opacity: 1;
            translate: none;
        }

        .site-menu a {
            padding: 0.5rem 0.75rem;
            font-size: 0.875rem;
        }
    }

    &.is-measuring * {
        transition: none !important;
    }

    .login-label-extra {
        display: none;
    }

    &.is-wide .login-label-extra {
        display: inline;
    }

    /* Telas de até 360 px: o botão do menu fica só com o ícone (o texto continua para leitores de tela). */
    @media (max-width: 22.5rem) {
        .header-inner {
            gap: 0.5rem;
        }

        .menu-button {
            position: relative;
        }

        .menu-button span {
            position: absolute;
            width: 1px;
            height: 1px;
            overflow: hidden;
            clip-path: inset(50%);
            white-space: nowrap;
        }
    }
}

@media (prefers-reduced-motion: no-preference) {
    .site-header:not(.is-wide) .site-menu {
        opacity: 0;
        translate: 0 -0.5rem;
        transition:
            opacity 0.2s ease-out,
            translate 0.2s ease-out,
            display 0.2s,
            overlay 0.2s;
        transition-behavior: allow-discrete;
    }

    .site-header:not(.is-wide) .site-menu:is(:popover-open, .\:popover-open) {
        opacity: 1;
        translate: 0 0;
    }
}

@starting-style {
    .site-header:not(.is-wide) .site-menu:is(:popover-open, .\:popover-open) {
        opacity: 0;
        translate: 0 -0.5rem;
    }
}

/* Perguntas frequentes: <details> nativos, sem JavaScript. */
.faq-item {
    > summary {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        list-style: none;
        cursor: pointer;

        &::-webkit-details-marker {
            display: none;
        }

        /* Marcador junto ao texto, girado para o estado fechado. */
        &::before {
            content: '';
            inline-size: 1.25rem;
            block-size: 1.25rem;
            flex-shrink: 0;
            background-color: currentColor;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")
                no-repeat center / contain;
            rotate: -90deg;

            @media (prefers-reduced-motion: no-preference) {
                transition: rotate 0.2s;
            }
        }
    }

    &[open] > summary::before {
        rotate: 0deg;
    }

    &::details-content {
        interpolate-size: allow-keywords;
        overflow: clip;
        contain: layout;
    }

    &:not([open])::details-content {
        block-size: 0;
    }

    @media (prefers-reduced-motion: no-preference) {
        &::details-content {
            transition: block-size, content-visibility, display;
            transition-duration: 0.3s;
            transition-timing-function: ease-in-out;
            transition-behavior: allow-discrete;
        }
    }
}

/*
 * Abas da demonstração do sistema: a lista rola horizontalmente quando não
 * cabe, com esmaecimento nas bordas que ainda têm abas escondidas.
 */
@property --fade-start {
    syntax: '<length>';
    inherits: false;
    initial-value: 0px;
}

@property --fade-end {
    syntax: '<length>';
    inherits: false;
    initial-value: 0px;
}

@keyframes reveal-fade-start {
    to {
        --fade-start: var(--fade-size);
    }
}

@keyframes hide-fade-end {
    from {
        --fade-end: var(--fade-size);
    }
}

.tab-scroller {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    --fade-size: 2.5rem;
    scroll-padding-inline: var(--fade-size);
    mask:
        linear-gradient(black, black) no-clip subtract,
        linear-gradient(to right, black, transparent) 0 0 / var(--fade-start) 100% no-repeat no-clip,
        linear-gradient(to right, transparent, black) 100% 0 / var(--fade-end) 100% no-repeat no-clip;

    &::-webkit-scrollbar {
        display: none;
    }

    @supports (animation-timeline: scroll()) {
        animation:
            reveal-fade-start linear both,
            hide-fade-end linear both;
        animation-timeline: scroll(self inline);
        animation-range:
            0 var(--fade-size),
            calc(100% - var(--fade-size)) 100%;
    }

    /* Alternativa via IntersectionObserver (SystemShowcase.vue). */
    @supports not (animation-timeline: scroll()) {
        transition:
            --fade-start 0.2s,
            --fade-end 0.2s;

        &.more-start {
            --fade-start: var(--fade-size);
        }

        &.more-end {
            --fade-end: var(--fade-size);
        }
    }

    /* Navegação entre páginas (ex.: Configurações): links com aria-current. */
    > a {
        position: relative;
        flex: none;

        &[aria-current='page']::after {
            content: '';
            position: absolute;
            inset: auto 0.75rem 0;
            border-block-end: 3px solid var(--color-electric-600);
        }
    }

    > [role='tab'] {
        position: relative;
        flex: none;

        /* Indicador por forma (sublinhado), não só por cor; não altera o tamanho da aba. */
        &[aria-selected='true']::after {
            content: '';
            position: absolute;
            inset: auto 0.75rem 0;
            border-block-end: 3px solid var(--color-electric-600);
        }
    }
}

/*
 * Tabelas de dados (clientes, veículos). Quando o espaço do próprio
 * contêiner fica estreito, cada linha vira um cartão e os rótulos das
 * colunas aparecem ao lado dos valores (atributo data-label).
 */
.data-table-wrapper {
    container-type: inline-size;
    overflow-x: auto;
}

.data-table {
    inline-size: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--text-sm);
    line-height: var(--text-sm--line-height);
    text-align: start;

    /* O navegador centraliza <th> por padrão. */
    th {
        text-align: start;
    }

    thead th {
        padding: 0.75rem 1rem;
        background: var(--color-slate-50);
        font-size: var(--text-xs);
        font-weight: 500;
        letter-spacing: 0.025em;
        text-transform: uppercase;
        white-space: nowrap;
        color: var(--color-slate-600);
    }

    tbody th,
    tbody td {
        padding: 0.875rem 1rem;
        border-block-start: 1px solid var(--color-slate-100);
        vertical-align: middle;
        color: var(--color-slate-700);
    }

    /* Bordas alinhadas ao espaçamento interno dos cartões (1.25rem). */
    @container (width >= 56rem) {
        th:first-child {
            padding-inline-start: 1.25rem;
        }

        :is(th, td):last-child {
            padding-inline-end: 1.25rem;
        }
    }

    tbody th {
        font-weight: 500;
        color: var(--color-navy-950);
    }

    .is-actions {
        text-align: end;
    }

    /* Valores (preço, duração): alinhados à direita e com algarismos de mesma largura. */
    .is-numeric {
        text-align: end;
        white-space: nowrap;
        font-variant-numeric: tabular-nums;
    }

    /* Coluna ordenável (SortHeader): o botão preenche a célula e fornece o espaçamento. */
    thead th:has(> button) {
        padding: 0;
    }

    thead th > button {
        padding: 0.75rem 1rem;
    }

    @container (width >= 56rem) {
        thead th:first-child > button {
            padding-inline-start: 1.25rem;
        }

        thead th:last-child > button {
            padding-inline-end: 1.25rem;
        }
    }

    /* Abaixo de ~900px as 6 ou 7 colunas não cabem sem quebrar nomes e ações. */
    @container (width < 56rem) {
        &,
        tbody,
        tr,
        th,
        td {
            display: block;
        }

        thead {
            display: none;
        }

        tbody tr {
            padding: 1rem 1.25rem;
            border-block-start: 1px solid var(--color-slate-100);
        }

        tbody th,
        tbody td {
            padding: 0;
            border: 0;
        }

        tbody th {
            margin-block-end: 0.5rem;
        }

        tbody td {
            display: flex;
            justify-content: space-between;
            gap: 1rem;
            padding-block: 0.25rem;
            text-align: end;
        }

        tbody td[data-label]::before {
            content: attr(data-label);
            font-weight: 500;
            text-align: start;
            color: var(--color-slate-600);
        }

        .is-actions {
            justify-content: flex-start;
            margin-block-start: 0.5rem;
            margin-inline-start: -0.625rem;
        }
    }
}

/*
 * Diálogos modais nativos (<dialog> aberto com showModal()). O navegador
 * cuida do foco, da tecla Esc e de tornar a página inerte.
 */
.app-dialog {
    inline-size: min(32rem, 100% - 2rem);
    max-block-size: calc(100dvh - 2rem);
    margin: auto;
    padding: 0;
    border: 0;
    border-radius: var(--radius-2xl);
    background: white;
    color: var(--color-navy-950);
    box-shadow: var(--shadow-2xl);

    &:modal {
        /* Rolagem dentro do diálogo não passa para a página. */
        overscroll-behavior: contain;
    }

    &::backdrop {
        overflow: hidden;
        overscroll-behavior: contain;
        background: rgb(0 15 32 / 0.6);
    }
}

/*
 * Impressão do comprovante não fiscal (Configurações → Comprovantes → Prévia):
 * só o comprovante sai no papel, com as faixas de cor do estabelecimento.
 */
@media print {
    body:has(.receipt-document) {
        background: #fff;

        * {
            visibility: hidden;
        }

        .receipt-document,
        .receipt-document * {
            visibility: visible;
        }

        .receipt-document {
            position: absolute;
            inset-block-start: 0;
            inset-inline-start: 0;
            border: 0;
            print-color-adjust: exact;
        }
    }

    /* Cartaz do QR Code da vitrine: só ele sai na impressão. */
    body:has(.qr-print-sheet) {
        background: #fff;

        * {
            visibility: hidden;
        }

        .qr-print-sheet,
        .qr-print-sheet * {
            visibility: visible;
        }

        .qr-print-sheet {
            position: absolute;
            inset-block-start: 0;
            inset-inline-start: 0;
            inline-size: 100%;
            border: 0;
            box-shadow: none;
            print-color-adjust: exact;
        }
    }
}

/* Reordenação por arrastar (Minha Vitrine): o pegador não rola a página nem seleciona texto. */
.reorder-handle {
    cursor: grab;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.is-reordering,
.is-reordering * {
    cursor: grabbing !important;
}
