/* ==========================================
   Kolibri Log — Tema compartilhado (todas as páginas)
   Identidade derivada do logotipo: penas em camadas
   com a borda amarela deslocada ("pólen").
   Fontes auto-hospedadas: o CSP do CloudFront só
   permite font-src 'self'.
   Cores do Tailwind remapeadas em js/tema.js.
   ========================================== */

@font-face {
    font-family: 'Lexend';
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url('../fonts/lexend-latin.woff2') format('woff2');
}

@font-face {
    font-family: 'Lexend Exa';
    font-style: normal;
    font-weight: 500 700;
    font-display: swap;
    src: url('../fonts/exa-latin.woff2') format('woff2');
}

:root {
    --petrol: #0E6F8C;
    --petrol-escuro: #0B5D76;
    --plumagem: #1B93BA;
    --salvia: #6A9494;
    --salvia-clara: #93B8B8;
    --polen: #FFF0A0;
    --tinta: #0A3442;
    --tinta-suave: #4A6670;
    --nevoa: #F3F8F8;
    --linha: #C8DADB;
    --branco: #FFFFFF;

    --deslocamento: 4px 4px 0 var(--polen);
    --raio: 10px;
}

/* ---------- Base ---------- */

body {
    font-family: 'Lexend', system-ui, sans-serif;
    color: var(--tinta);
    -webkit-font-smoothing: antialiased;
}

/* Títulos de página e de seção na largura ampla, como o logotipo */
h1,
h2,
.fixed h3 {
    font-family: 'Lexend Exa', 'Lexend', sans-serif;
    letter-spacing: -0.035em;
}

/* ---------- Cabeçalhos das áreas logadas ---------- */

header.bg-blue-700,
header.bg-gray-900 {
    box-shadow: inset 0 -3px 0 var(--polen);
}

/* ---------- Botões principais: a pena com a borda de pólen ---------- */

button.bg-blue-700,
button.bg-blue-600,
a.bg-blue-700,
a.bg-blue-600 {
    box-shadow: 3px 3px 0 var(--polen);
    transition: background-color 120ms ease, transform 80ms ease, box-shadow 80ms ease;
}

button.bg-blue-700:active:not(:disabled),
button.bg-blue-600:active:not(:disabled),
a.bg-blue-700:active,
a.bg-blue-600:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 var(--polen);
}

/* ---------- Campos com foco: borda petróleo + deslocamento de pólen ---------- */

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus,
select:focus,
textarea:focus {
    outline: 1px solid var(--petrol) !important;
    outline-offset: 0 !important;
    border-color: var(--petrol) !important;
    box-shadow: var(--deslocamento) !important;
}

/* Foco de teclado visível em tudo que é clicável */
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
summary:focus-visible {
    outline: 2.5px solid var(--tinta);
    outline-offset: 3px;
}

header a:focus-visible,
header button:focus-visible,
.faixa-marca a:focus-visible {
    outline-color: var(--polen);
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--petrol);
}

::selection {
    background: var(--polen);
    color: var(--tinta);
}

/* ---------- Asa em leque (penas do logotipo) ---------- */

.asa {
    position: absolute;
    pointer-events: none;
    height: auto;
}

.pena {
    transform-box: view-box;
    transform-origin: 0 0;
    transform: rotate(var(--r));
}

@media (prefers-reduced-motion: no-preference) {
    .pena {
        animation: abrir-asa 1100ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
        animation-delay: calc(var(--i) * 90ms + 150ms);
    }

    @keyframes abrir-asa {
        from {
            transform: rotate(-6deg);
            opacity: 0;
        }
        25% {
            opacity: 1;
        }
        to {
            transform: rotate(var(--r));
            opacity: 1;
        }
    }
}

/* ---------- Faixa da marca (páginas de cadastro) ---------- */

.faixa-marca {
    position: relative;
    overflow: hidden;
    background: var(--petrol);
    color: var(--branco);
    padding: 1.75rem 1rem 3rem;
}

.faixa-marca__conteudo {
    position: relative;
    z-index: 1;
    max-width: 42rem;
    margin: 0 auto;
}

.faixa-marca__voltar {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--branco);
    text-decoration: underline;
    text-decoration-color: rgba(255, 255, 255, 0.4);
    text-underline-offset: 0.2em;
}

.faixa-marca__voltar:hover {
    text-decoration-color: currentColor;
}

.faixa-marca__nome {
    font-family: 'Lexend Exa', 'Lexend', sans-serif;
    font-weight: 600;
    font-size: 0.9375rem;
    letter-spacing: -0.02em;
    margin: 2rem 0 0.75rem;
}

.faixa-marca__titulo {
    font-weight: 600;
    font-size: clamp(1.625rem, 4.5vw, 2.25rem);
    line-height: 1.15;
    margin: 0 0 0.75rem;
    max-width: 18ch;
}

.faixa-marca__texto {
    font-weight: 300;
    font-size: 1rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.86);
    max-width: 44ch;
    margin: 0;
}

.faixa-marca .asa {
    width: 360px;
    right: max(-40px, calc(50% - 24rem));
    bottom: -96px;
}

@media (max-width: 640px) {
    .faixa-marca {
        padding-bottom: 6.5rem;
    }

    .faixa-marca .asa {
        width: 270px;
        right: -30px;
        bottom: -78px;
    }
}

/* ==========================================
   Celular
   ========================================== */

/* Campos com 16px: abaixo disso o Safari do iPhone dá zoom ao tocar */
@media (max-width: 639px) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]),
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* Alvos de toque de pelo menos 44px em telas de toque */
@media (pointer: coarse) {
    button:not(.tab-btn),
    input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]),
    select {
        min-height: 2.75rem;
    }

    button[aria-label] {
        min-width: 2.75rem;
    }

    input[type="checkbox"],
    input[type="radio"] {
        width: 1.25rem;
        height: 1.25rem;
        flex-shrink: 0;
    }
}

@media (max-width: 639px) {
    /* Cabeçalho mais baixo: sobra tela para o conteúdo */
    header.bg-blue-700 > div {
        padding-top: 0.625rem;
        padding-bottom: 0.625rem;
    }

    header.bg-blue-700 h1 {
        font-size: 1.125rem;
    }

    header.bg-gray-900 {
        padding: 0.625rem 0.875rem;
    }

    header.bg-gray-900 .text-xl {
        font-size: 1.0625rem;
    }

    /* Painéis com menos recuo */
    main .p-6,
    main .p-5 {
        padding: 1rem;
    }

    /* Modais ocupam quase a tela toda e respeitam a barra do navegador */
    .fixed.inset-0.p-4 {
        padding: 0.75rem;
    }

    .fixed.inset-0 > .overflow-y-auto {
        max-height: calc(100vh - 1.5rem);
        max-height: calc(100dvh - 1.5rem);
    }

    .fixed.inset-0 > .p-8 {
        padding: 1.5rem 1.25rem;
    }

    /* Avisos na largura da tela */
    #toast-container {
        top: 0.75rem;
        left: 0.75rem;
        right: 0.75rem;
    }

    #toast-container > div {
        max-width: none;
    }
}

/* ---------- Menu de abas com rolagem (admin) ---------- */

nav .overflow-x-auto:has(> .tab-btn) {
    scrollbar-width: none;
    scroll-padding-inline: 1rem;
}

nav .overflow-x-auto:has(> .tab-btn)::-webkit-scrollbar {
    display: none;
}

@media (max-width: 1023px) {
    /* Esmaece a borda direita: indica que há mais abas ao arrastar */
    nav:not(.menu-inferior) .overflow-x-auto:has(> .tab-btn) {
        padding-right: 2rem;
        -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2.5rem), transparent);
        mask-image: linear-gradient(to right, #000 calc(100% - 2.5rem), transparent);
    }
}

/* ---------- Menu de abas na base da tela (motorista e cliente) ---------- */

@media (max-width: 639px) {
    /* nav.: vence bg-white/shadow-sm do Tailwind, que é injetado depois deste arquivo */
    nav.menu-inferior {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 40;
        background: var(--petrol);
        border: 0;
        box-shadow: inset 0 3px 0 var(--polen);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .menu-inferior > div {
        padding: 0;
        overflow: visible;
    }

    .menu-inferior .tab-btn:not(.hidden) {
        position: relative;
        flex: 1 1 0;
        min-width: 0;
        flex-direction: column;
        justify-content: center;
        gap: 0.25rem;
        padding: 0.75rem 0.25rem 0.625rem;
        font-size: 0.75rem;
        line-height: 1.2;
        text-align: center;
        white-space: normal;
        border: 0;
    }

    .menu-inferior .tab-btn.active,
    .menu-inferior .tab-btn:not(.active),
    .menu-inferior .tab-btn:not(.active):hover {
        border: 0;
    }

    .menu-inferior .tab-btn:not(.active) {
        color: rgba(255, 255, 255, 0.78);
        font-weight: 400;
    }

    .menu-inferior .tab-btn.active {
        color: var(--polen);
        font-weight: 600;
    }

    /* Traço de pólen sobre a aba atual */
    .menu-inferior .tab-btn.active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 28%;
        right: 28%;
        height: 3px;
        border-radius: 0 0 3px 3px;
        background: var(--polen);
    }

    .menu-inferior .tab-btn svg {
        width: 1.375rem;
        height: 1.375rem;
    }

    .menu-inferior .tab-btn:focus-visible {
        outline-color: var(--polen);
        outline-offset: -4px;
    }

    /* Contadores e pendências ficam sobre o ícone */
    .menu-inferior .tab-btn > span {
        position: absolute;
        top: 0.45rem;
        left: calc(50% + 0.4rem);
        min-width: 1.125rem;
        padding: 0.0625rem 0.3rem;
        font-size: 0.625rem;
        line-height: 1rem;
        box-shadow: 0 0 0 2px var(--petrol);
    }

    .menu-inferior .tab-btn > span[data-ponto] {
        min-width: 0;
        width: 0.625rem;
        height: 0.625rem;
        padding: 0;
        font-size: 0;
        background: var(--polen);
    }

    body:has(.menu-inferior:not(.hidden)) {
        padding-bottom: calc(4.25rem + env(safe-area-inset-bottom));
    }
}

/* ---------- Tabelas no celular: uma linha vira um bloco empilhado ---------- */
/* Rótulos vêm de js/tabelas-responsivas.js (data-label = texto do cabeçalho). */

@media (max-width: 639px) {
    .tabela-cartoes thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .tabela-cartoes,
    .tabela-cartoes tbody {
        display: block;
        width: 100%;
    }

    .tabela-cartoes tbody > tr {
        display: block;
        padding: 0.875rem 1rem;
        border-bottom: 1px solid var(--linha);
    }

    .tabela-cartoes tbody > tr:last-child {
        border-bottom: 0;
    }

    .tabela-cartoes tbody > tr > td:not(.hidden),
    .tabela-cartoes tbody > tr > td[class*="md:table-cell"],
    .tabela-cartoes tbody > tr > td[class*="lg:table-cell"] {
        display: grid;
        grid-template-columns: minmax(6rem, 36%) minmax(0, 1fr);
        gap: 0.75rem;
        align-items: baseline;
        padding: 0.25rem 0;
        text-align: left;
        white-space: normal;
        overflow-wrap: anywhere;
        border: 0;
    }

    /* Selos e botões mantêm a largura natural dentro da célula */
    .tabela-cartoes tbody > tr > td > * {
        justify-self: start;
    }

    .tabela-cartoes tbody > tr > td::before {
        content: attr(data-label);
        font-size: 0.8125rem;
        font-weight: 400;
        color: var(--tinta-suave);
    }

    /* Primeira coluna: o nome da linha, com o rótulo em cima */
    .tabela-cartoes tbody > tr > td:first-child:not(.celula-cheia) {
        display: block;
        padding-bottom: 0.5rem;
        font-size: 1rem;
        font-weight: 600;
        color: var(--tinta);
    }

    .tabela-cartoes tbody > tr > td:first-child:not(.celula-cheia)::before {
        display: block;
        margin-bottom: 0.125rem;
        font-size: 0.75rem;
    }

    /* Ações: botões em linha própria, sem rótulo */
    .tabela-cartoes tbody > tr > td.celula-acoes {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        padding-top: 0.75rem;
    }

    .tabela-cartoes tbody > tr > td.celula-acoes::before {
        content: none;
    }

    .tabela-cartoes tbody > tr > td.celula-acoes > div {
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    /* Linha de aviso (carregando, vazio, erro) */
    .tabela-cartoes tbody > tr > td.celula-cheia {
        display: block;
        text-align: center;
    }

    .tabela-cartoes tbody > tr > td.celula-cheia::before {
        content: none;
    }

    .tabela-cartoes [class*="min-w-"] {
        min-width: 0;
    }
}

@media (max-width: 639px) {
    nav .tab-btn {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}
