/* ═══════════════════════════════════════════════════════════════════
   PORTAIS PÚBLICOS — passageiro / motorista
   Refeito em 3.24.0 com responsividade mobile-first (iPhone 375px → desktop)
   ═══════════════════════════════════════════════════════════════════ */

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
.te-body {
    min-height: 100%;
    background: #f0f0f1;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    color: #1a1a1a;
    -webkit-font-smoothing: antialiased;
    /* Safe area iOS (iPhone com notch) */
    padding-top: env(safe-area-inset-top, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
}
a { color: var(--gold, #F5A623); }
button { cursor: pointer; }
input, select, textarea, button { font-family: inherit; }

:root {
    --gold: #F5A623;
    --dark: #1a1a1a;
    --green: #00a32a;
    --red: #d63638;
    --border: #e0e0e0;
    --r: 12px;
}

/* ─────────────── LAYOUT BASE ─────────────── */
.te-portal {
    max-width: 900px;
    margin: 40px auto;
    padding: 0 20px;
}
.te-portal h1 { font-size: 22px; font-weight: 700; margin-bottom: 24px; color: var(--dark); }
.te-portal h2 { font-size: 17px; font-weight: 600; margin-bottom: 16px; color: var(--dark); }

.te-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

/* ─────────────── KPIs ─────────────── */
.te-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.te-kpi {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 16px;
    text-align: center;
}
.te-kpi__label { font-size: 11px; color: #777; font-weight: 600; text-transform: uppercase; margin-bottom: 6px; }
.te-kpi__value { font-size: 22px; font-weight: 700; color: var(--dark); line-height: 1.2; }
.te-kpi__value.gold  { color: var(--gold); }
.te-kpi__value.green { color: var(--green); }
.te-kpi__value.red   { color: var(--red); }

/* ─────────────── BOTÕES ─────────────── */
/* Touch target mínimo 44x44 px conforme Apple HIG */
.te-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: .15s;
    line-height: 1.2;
}
.te-btn:active { transform: scale(.97); }
.te-btn-primary { background: var(--gold); color: #fff; }
.te-btn-primary:hover { background: #e69510; color: #fff; }
.te-btn-secondary {
    background: #f5f5f5;
    color: var(--dark);
    border: 1px solid var(--border);
}
.te-btn-secondary:hover { background: #e8e8e8; }
.te-btn-full { width: 100%; }

/* ─────────────── FORMULÁRIOS ─────────────── */
.te-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}
.te-field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--dark);
}
.te-field input,
.te-field select,
.te-field textarea {
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 16px; /* CRÍTICO: ≥16px previne zoom no iOS Safari */
    width: 100%;
    box-sizing: border-box;
    /* Reduz "tap delay" iOS */
    -webkit-tap-highlight-color: rgba(245,166,35,.15);
    -webkit-appearance: none;
    appearance: none;
    background-color: #fff;
}
.te-field input:focus,
.te-field select:focus,
.te-field textarea:focus {
    border-color: var(--gold);
    outline: none;
    box-shadow: 0 0 0 3px rgba(245,166,35,.15);
}
.te-field textarea { resize: vertical; min-height: 80px; }
/* Select arrow custom (já que removemos appearance) */
.te-field select {
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%231a1a1a' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px;
    padding-right: 36px;
}

.te-grid2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* ─────────────── TABELAS ─────────────── */
.te-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.te-table th {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #777;
    padding: 10px 12px;
    border-bottom: 2px solid var(--border);
    text-align: left;
}
.te-table td {
    padding: 12px;
    border-bottom: 1px solid #f5f5f5;
    vertical-align: middle;
}
.te-table tr:last-child td { border-bottom: none; }
.te-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ─────────────── LOGIN ─────────────── */
.te-login { max-width: 420px; margin: 80px auto; padding: 0 20px; }
.te-login .te-card { padding: 36px; }
.te-login-logo { text-align: center; margin-bottom: 28px; }
.te-login-logo h1 { font-size: 26px; font-weight: 800; color: var(--dark); }
.te-login-logo h1 span { color: var(--gold); }

/* ─────────────── BADGES ─────────────── */
.te-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}
.te-badge-green { background: #e9f6ed; color: #1a7340; }
.te-badge-blue  { background: #e8f0fc; color: #1a5fa9; }
.te-badge-amber { background: #fef3cd; color: #854f0b; }
.te-badge-red   { background: #fcebeb; color: #a32d2d; }
.te-badge-gray  { background: #f0f0f1; color: #50575e; }

/* ─────────────── DRIVER ACTION CARD ─────────────── */
.te-action-card {
    border: 2px solid var(--gold);
    border-radius: var(--r);
    padding: 20px;
    margin-bottom: 16px;
    background: #fffdf5;
}
.te-action-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.te-action-sub { font-size: 13px; color: #777; margin-bottom: 14px; }

.te-progress {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.te-progress-step {
    flex: 1;
    min-width: 60px;
    text-align: center;
    padding: 6px 4px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    background: #f0f0f1;
    color: #777;
}
.te-progress-step.active { background: var(--gold); color: #fff; }
.te-progress-step.done   { background: #e9f6ed; color: #1a7340; }

/* ═══════════════════════════════════════════════════════════════════
   REGRAS GLOBAIS DE RESPONSIVIDADE (catch-all pra estilos inline)
   ═══════════════════════════════════════════════════════════════════ */

/* Garante que botões inline em portal também tenham touch target */
.te-portal button:not(.te-btn):not(.te-iconbtn) {
    min-height: 40px;
}

/* Tabelas dentro do portal sempre podem rolar horizontalmente */
.te-portal table {
    max-width: 100%;
}
.te-portal table:not(.te-no-scroll) {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
}

/* Imagens responsivas */
.te-portal img { max-width: 100%; height: auto; }

/* Evita overflow horizontal acidental do body */
.te-body { overflow-x: hidden; }
.te-portal { overflow-x: hidden; }

/* ═══════════════════════════════════════════════════════════════════
   BREAKPOINT 768px — tablets pequenos
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .te-portal {
        margin: 20px auto;
        padding: 0 16px;
    }
    .te-portal h1 { font-size: 20px; margin-bottom: 18px; }
    .te-portal h2 { font-size: 16px; margin-bottom: 14px; }
    .te-card { padding: 18px; margin-bottom: 14px; border-radius: 10px; }
    .te-kpis { gap: 10px; margin-bottom: 18px; }
}

/* ═══════════════════════════════════════════════════════════════════
   BREAKPOINT 600px — celular grande / tablet pequeno
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
    .te-grid2 { grid-template-columns: 1fr; gap: 10px; }
    .te-kpis { grid-template-columns: repeat(2, 1fr); }
    .te-kpi { padding: 12px 8px; }
    .te-kpi__value { font-size: 18px; }
    .te-action-card { padding: 16px; }
    .te-action-title { font-size: 14px; }
    .te-progress-step { font-size: 9px; min-width: 48px; padding: 5px 2px; }
}

/* ═══════════════════════════════════════════════════════════════════
   BREAKPOINT 480px — celulares (iPhone padrão / Android médio)
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .te-portal {
        margin: 12px auto;
        padding: 0 12px;
    }
    .te-portal h1 { font-size: 18px; margin-bottom: 14px; }
    .te-portal h2 { font-size: 15px; margin-bottom: 12px; }
    .te-card {
        padding: 14px;
        margin-bottom: 12px;
        border-radius: 10px;
    }
    .te-kpis { gap: 8px; }
    .te-kpi { padding: 10px 6px; }
    .te-kpi__label { font-size: 10px; }
    .te-kpi__value { font-size: 17px; }

    /* Botões mais "tap-friendly" no celular */
    .te-btn {
        padding: 12px 18px;
        font-size: 14px;
        width: 100%; /* default: full width — fica mais fácil de clicar */
    }
    .te-btn.te-btn-auto { width: auto; } /* override pra quando quer manter auto */

    /* Login */
    .te-login {
        margin: 30px auto;
        padding: 0 16px;
    }
    .te-login .te-card { padding: 22px; }
    .te-login-logo { margin-bottom: 20px; }
    .te-login-logo h1 { font-size: 22px; }
}

/* ═══════════════════════════════════════════════════════════════════
   BREAKPOINT 375px — iPhone SE, iPhones pequenos
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 375px) {
    .te-portal { padding: 0 10px; }
    .te-card { padding: 12px; }
    .te-kpis { grid-template-columns: 1fr 1fr; }
    .te-kpi__value { font-size: 15px; }
    .te-field input,
    .te-field select,
    .te-field textarea { padding: 10px 12px; }
}

/* ═══════════════════════════════════════════════════════════════════
   UTILITÁRIOS DE RESPONSIVIDADE — pra views usarem
   ═══════════════════════════════════════════════════════════════════ */
.te-only-mobile  { display: none; }
.te-only-desktop { display: initial; }
@media (max-width: 600px) {
    .te-only-mobile  { display: initial; }
    .te-only-desktop { display: none; }
    .te-hide-mobile  { display: none !important; }
    .te-stack-mobile {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }
    .te-stack-mobile > * { width: 100%; }
}

/* ═══════════════════════════════════════════════════════════════════
   AJUSTES ESPECÍFICOS — passenger-dashboard / driver-dashboard
   Regras seletivas pra os elementos inline que mais causam problema mobile
   ═══════════════════════════════════════════════════════════════════ */

/* Topbar sticky — ajusta padding em mobile e garante respiração */
@media (max-width: 600px) {
    [style*="position:sticky"][style*="top:0"] {
        padding: 10px 12px !important;
    }
    /* Topbar avatar fica menor pra dar espaço ao nome */
    [style*="width:48px"][style*="height:48px"][style*="border-radius:50%"] {
        width: 40px !important;
        height: 40px !important;
        font-size: 15px !important;
    }
}

/* Drawer pra menu lateral — ocupa 90% da tela em celulares pequenos */
@media (max-width: 375px) {
    aside[id$="-menu-drawer"] {
        width: 92vw !important;
        max-width: 92vw !important;
    }
}

/* Cards pra ações principais (driver dashboard cards de OS) — padding menor mobile */
@media (max-width: 480px) {
    [style*="border:2px solid"][style*="border-radius:14px"] {
        padding: 14px !important;
    }
    [style*="border:1.5px solid"][style*="border-radius:14px"] {
        padding: 14px !important;
    }
}

/* Listas de viagens (cards horizontais) — quebra em coluna no mobile */
@media (max-width: 480px) {
    [style*="display:flex"][style*="justify-content:space-between"][style*="border-bottom"]:not([class]):not([id]) {
        flex-wrap: wrap !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   DRAWER — ITEM DE MENU (.pax-menu-item)
   ═══════════════════════════════════════════════════════════════════ */
.pax-menu-item {
    display: flex !important;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
    text-align: left;
    min-height: 50px;
    transition: background .15s;
}
.pax-menu-item:hover, .pax-menu-item:active { background: #fff8e5; }
.pax-menu-item.active { background: #fef3cd; color: #1a1a1a; font-weight: 700; }

/* ═══════════════════════════════════════════════════════════════════
   PWA BANNER (banner topo "Instalar app")
   ═══════════════════════════════════════════════════════════════════ */
#te-pwa-banner {
    line-height: 1.4;
}
@media (max-width: 480px) {
    #te-pwa-banner { font-size: 12px !important; padding: 10px 12px !important; }
}

/* ═══════════════════════════════════════════════════════════════════
   MODAIS — limita altura e adiciona scroll interno no mobile
   ═══════════════════════════════════════════════════════════════════ */
[style*="position:fixed"][style*="inset:0"][style*="z-index:999"]:not([id$="-overlay"]) {
    -webkit-overflow-scrolling: touch;
}
@media (max-width: 480px) {
    /* Forçar modais a ocuparem largura máxima com margem mínima no celular */
    [style*="max-width:420px"][style*="border-radius:14px"][style*="background:#fff"] {
        max-width: calc(100vw - 24px) !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
    }
    [style*="max-width:360px"][style*="border-radius:16px"],
    [style*="max-width:340px"][style*="border-radius:16px"] {
        max-width: calc(100vw - 32px) !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   BARRA DE STATUS PROGRESS (steps numerados)
   No mobile o gap entre bolinhas fica apertado — diminuímos
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    [style*="display:flex"][style*="flex-direction:column"][style*="align-items:center"][style*="flex:1"] {
        font-size: 10px;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   BOTÕES INLINE — touch target em todos os botões nos portais
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
    /* Garante touch target em botões com padding pequeno */
    button:not(.te-iconbtn):not([style*="width:34px"]):not([style*="width:44px"]) {
        min-height: 38px;
    }
    /* Botões de ação principal (cor dourada) ficam maiores */
    button[style*="background:#F5A623"]:not([style*="width:34px"]):not([style*="width:44px"]) {
        min-height: 44px;
        padding: 10px 16px !important;
        font-size: 14px !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   TABS internos do dashboard (Início / Histórico / Motoristas)
   ═══════════════════════════════════════════════════════════════════ */
.pax-tab { display: none; }
.pax-tab.active { display: block; }

/* ═══════════════════════════════════════════════════════════════════
   CORREÇÕES DE LAYOUT em viewport muito pequeno (320px - iPhone SE 1st gen)
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 360px) {
    .te-portal { padding: 0 8px; margin: 8px auto; }
    .te-card { padding: 12px; border-radius: 8px; }
    .te-portal h1 { font-size: 17px; }
    .te-portal h2 { font-size: 14px; }
}

/* ═══════════════════════════════════════════════════════════════════
   ANTI-ZOOM iOS — força font-size ≥ 16px em qualquer input/select inline
   (iOS Safari faz zoom automático em qualquer input com font-size < 16px)
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    input[type="text"]:not([style*="font-size:16"]),
    input[type="email"]:not([style*="font-size:16"]),
    input[type="password"]:not([style*="font-size:16"]),
    input[type="tel"]:not([style*="font-size:16"]),
    input[type="number"]:not([style*="font-size:16"]),
    input[type="search"]:not([style*="font-size:16"]),
    input[type="date"]:not([style*="font-size:16"]),
    input[type="datetime-local"]:not([style*="font-size:16"]),
    input[type="time"]:not([style*="font-size:16"]),
    input[type="url"]:not([style*="font-size:16"]),
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   LOGIN — card responsivo no mobile
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    /* Card de login com padding menor no celular */
    [style*="max-width:400px"][style*="border-radius:16px"][style*="padding:40px"] {
        padding: 28px 22px !important;
    }
    /* Logo NEWPRA menor em mobile */
    [style*="font-size:28px"][style*="font-weight:800"][style*="letter-spacing:2px"] {
        font-size: 22px !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   PAINEL ADMIN (admin/class-panel.php) — TOPBAR MOBILE
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
    /* Topbar do painel — não pode ficar com itens cortados */
    .te-panel-topbar {
        padding: 10px 12px !important;
    }
    .te-panel-topbar nav {
        gap: 4px !important;
    }
}
