/* FleetLog – camada mobile-first global
   Ajustes para tornar as páginas internas utilizáveis em smartphones sem alterar regras de negócio. */
:root {
  --mobile-gutter: clamp(0.75rem, 3.6vw, 1rem);
  --mobile-radius: 1.15rem;
  --mobile-touch: 46px;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

img,
svg,
video,
canvas {
  max-width: 100%;
  height: auto;
}

button,
a,
input,
select,
textarea,
summary,
[role="button"] {
  -webkit-tap-highlight-color: rgba(204, 19, 25, .12);
}

input,
select,
textarea {
  font-size: 16px !important; /* evita zoom automático no iOS */
}

button,
.btn,
.app-btn,
.action-btn,
.soft-button,
.btn-reto,
.flat-btn,
a.btn,
a.app-btn,
a.soft-button {
  min-height: var(--mobile-touch);
  touch-action: manipulation;
}

.table-actions,
.table-actions--mobile,
.list-footer-bar,
.list-footer-pagination,
.app-modal-footer,
.mobile-actions,
.action-row {
  gap: .65rem;
}

@media (max-width: 900px) {
  body .app-topbar,
  body .fleet-topbar,
  body .topbar-mobile-stack,
  body .topbar-shell {
    min-height: 50px;
    height: auto;
    padding-left: var(--mobile-gutter) !important;
    padding-right: var(--mobile-gutter) !important;
  }

  body details.account-menu,
  body details[data-account-menu] {
    max-width: 100%;
  }

  body .account-menu-trigger {
    max-width: calc(100vw - 2rem);
    overflow: hidden;
  }

  body .account-menu-panel,
  body details.account-menu[open] > .account-menu-panel,
  body details[data-account-menu][open] > .account-menu-panel {
    left: 0 !important;
    right: auto !important;
    width: min(22rem, calc(100vw - 1.25rem));
    max-width: calc(100vw - 1.25rem);
  }
}

@media (max-width: 768px) {
  body.app-shell,
  body.page-standard,
  body.dash-bg,
  body.login-body {
    background-attachment: fixed;
  }

  body > .container,
  .container.mx-auto,
  .max-w-7xl,
  .max-w-6xl,
  .max-w-5xl,
  .max-w-4xl,
  .max-w-3xl,
  .max-w-2xl,
  .max-w-xl {
    max-width: 100% !important;
  }

  body > .container,
  .container.mx-auto {
    width: 100% !important;
    padding-left: var(--mobile-gutter) !important;
    padding-right: var(--mobile-gutter) !important;
  }

  .fleet-page-frame,
  .page-main-shell,
  .controle-page-card,
  .premium-shell,
  main.max-w-7xl,
  .app-shell main.max-w-7xl,
  .app-shell .max-w-7xl.mx-auto.bg-white,
  .app-shell .max-w-3xl.mx-auto.bg-white,
  .app-shell .max-w-2xl.mx-auto.bg-white,
  .app-shell .max-w-xl.mx-auto.bg-white {
    width: 100% !important;
    margin: .45rem auto 1rem !important;
    padding: var(--mobile-gutter) !important;
    border-radius: calc(var(--mobile-radius) + .25rem) !important;
  }

  .hero-panel,
  .page-header-card,
  .filter-panel,
  .table-shell,
  .panel-card,
  .metric-card,
  .stat-card,
  .chart-card,
  .insight-card,
  .mobile-card,
  .dashboard-card,
  .soft-card,
  .form-card,
  .content-card,
  .info-card,
  .ab-panel,
  .ab-report-header,
  .ab-filterbar,
  .ab-kpi-card,
  .ab-chart-panel,
  .ab-insight-card,
  .ab-compare-panel,
  .ab-cost-composition {
    border-radius: var(--mobile-radius) !important;
  }

  .hero-panel,
  .page-header-card,
  .filter-panel,
  .panel-card,
  .table-shell,
  .info-card,
  .ab-report-header,
  .ab-filterbar {
    padding: var(--mobile-gutter) !important;
  }

  .hero-panel > .flex,
  .page-header-card > .flex,
  .ab-report-header,
  .ab-report-header__inner,
  .ab-filterbar__form,
  .multas-filter-form,
  .vehicle-hero-layout,
  .manutencao-hero-layout,
  .requisicoes-hero-layout,
  .co2-hero-layout,
  .audit-hero-layout,
  .audit-filter-layout,
  .list-footer-bar,
  .page-title-row,
  .section-title-row,
  .form-actions,
  .modal-actions {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .hero-panel .text-right,
  .page-header-card .text-right,
  .ab-report-header .text-right,
  .metric-card .text-right,
  .stat-card .text-right {
    text-align: left !important;
  }

  .hero-panel h1,
  .page-header-title,
  .page-title,
  .ab-report-title,
  .dashboard-title,
  .app-shell h1 {
    font-size: clamp(1.35rem, 7vw, 1.85rem) !important;
    line-height: 1.08 !important;
    letter-spacing: -.045em !important;
    word-break: normal;
    overflow-wrap: anywhere;
  }

  .hero-panel h2,
  .app-shell h2,
  .panel-title,
  .section-title {
    font-size: clamp(1.08rem, 5vw, 1.35rem) !important;
    line-height: 1.16 !important;
  }

  .hero-panel p,
  .page-header-subtitle,
  .ab-report-subtitle,
  .section-subtitle {
    font-size: .94rem !important;
    line-height: 1.45 !important;
  }

  .section-chip,
  .eyebrow,
  .app-kicker,
  .page-header-badge,
  .badge,
  .mobile-card-badge,
  .status-badge,
  .audit-badge,
  .ab-status-pill {
    max-width: 100%;
    white-space: nowrap !important;
  }

  .grid,
  .ab-kpi-grid,
  .ab-compare-grid,
  .ab-cost-composition__grid,
  .ab-insight-grid,
  .unit-meta-grid,
  .multa-create-grid,
  .vehicle-modal-grid,
  .req-form-grid,
  .field-grid,
  .filter-grid,
  .stats-grid,
  .dashboard-grid,
  .permission-grid,
  .metric-grid {
    grid-template-columns: 1fr !important;
  }

  .grid.grid-cols-2,
  .grid.sm\:grid-cols-2,
  .grid.md\:grid-cols-2,
  .grid.lg\:grid-cols-2,
  .grid.xl\:grid-cols-2,
  .grid-cols-2 {
    grid-template-columns: 1fr !important;
  }

  .hero-panel .grid,
  .page-header-card .grid,
  .metric-card .grid,
  .stat-card .grid,
  .mobile-card .grid {
    gap: .75rem !important;
  }

  .metric-card,
  .stat-card,
  .mobile-card,
  .dashboard-order-card,
  .ab-kpi-card,
  .ab-chart-panel,
  .insight-card,
  .panel-card {
    padding: .95rem !important;
  }

  .metric-card .text-2xl,
  .stat-card .text-2xl,
  .ab-kpi-card__value,
  .stat-value {
    font-size: 1.45rem !important;
    line-height: 1.1 !important;
  }

  form,
  .form-grid,
  .filter-form,
  .ab-filterbar__form,
  .multas-filter-form,
  .vehicle-filter-form,
  .manutencao-filter-form,
  .requisicao-filter-form,
  .audit-filter-form,
  .fleet-filter-form {
    width: 100% !important;
  }

  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  select,
  textarea,
  .soft-input,
  .form-control,
  .input-control {
    width: 100% !important;
    min-height: var(--mobile-touch) !important;
  }

  .app-btn,
  .btn,
  .soft-button,
  .btn-primary-soft,
  .action-btn,
  .flat-btn,
  .btn-reto,
  .ab-icon-button,
  .ab-report-action,
  button[type="submit"],
  button[type="button"] {
    min-height: var(--mobile-touch) !important;
    justify-content: center !important;
  }

  .table-actions,
  .table-actions--mobile,
  .ab-filterbar__actions,
  .list-footer-pagination,
  .list-footer-actions,
  .action-group,
  .actions-row {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
  }

  .table-actions > *,
  .table-actions--mobile > *,
  .ab-filterbar__actions > *,
  .list-footer-pagination > *,
  .list-footer-actions > *,
  .action-group > *,
  .actions-row > * {
    width: 100% !important;
  }

  .list-footer-bar {
    width: 100% !important;
  }

  .list-footer-chip,
  .pagination-chip {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .overflow-x-auto,
  .overflow-auto {
    max-width: 100% !important;
  }

  .app-modal-overlay {
    align-items: flex-end !important;
    justify-content: center !important;
    padding: .6rem !important;
    overflow-y: auto !important;
  }

  .app-modal-card,
  .dashboard-modal-card,
  .multa-info-modal-panel,
  .multa-info-modal-panel--compact,
  .vehicle-modal-panel,
  .logistica-modal,
  .pedagio-modal {
    width: min(100%, 680px) !important;
    max-width: 100% !important;
    max-height: calc(100dvh - 1.2rem) !important;
    border-radius: 1.35rem !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }

  .app-modal-header,
  .modal-header,
  .multa-info-header,
  .vehicle-modal-header {
    padding: .9rem 1rem !important;
  }

  .app-modal-body,
  .modal-body,
  .multa-info-body,
  .vehicle-modal-body,
  .logistica-modal-body {
    padding: .95rem !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .app-modal-footer,
  .modal-footer,
  .multa-info-footer,
  .vehicle-modal-footer,
  .logistica-modal-footer {
    padding: .85rem !important;
    flex-direction: column-reverse !important;
    align-items: stretch !important;
  }

  .app-modal-footer > *,
  .modal-footer > *,
  .multa-info-footer > *,
  .vehicle-modal-footer > *,
  .logistica-modal-footer > * {
    width: 100% !important;
  }

  .mobile-card,
  .mobile-vehicle-card,
  .mobile-maint-card,
  .fleetlog-generated-card {
    overflow: hidden;
  }

  .mobile-card .truncate,
  .mobile-vehicle-card .truncate,
  .mobile-maint-card .truncate,
  .fleetlog-generated-card .truncate {
    max-width: 100%;
  }

  .whitespace-nowrap {
    white-space: normal !important;
  }

  .badge,
  .audit-badge,
  .status-badge,
  .section-chip,
  .app-kicker,
  .eyebrow,
  .mobile-card-badge,
  .ab-status-pill {
    white-space: nowrap !important;
  }

  .hide-on-mobile,
  .desktop-only {
    display: none !important;
  }
}

@media (max-width: 520px) {
  :root { --mobile-gutter: .75rem; }

  .fleet-page-frame,
  .page-main-shell,
  .controle-page-card,
  .premium-shell,
  main.max-w-7xl {
    border-radius: 1rem !important;
  }

  .hero-panel,
  .page-header-card,
  .filter-panel,
  .table-shell,
  .panel-card,
  .metric-card,
  .stat-card,
  .mobile-card,
  .dashboard-card,
  .ab-report-header,
  .ab-filterbar,
  .ab-kpi-card {
    border-radius: 1rem !important;
  }

  .text-3xl,
  .text-4xl,
  .text-5xl {
    font-size: 1.55rem !important;
    line-height: 1.08 !important;
  }

  .text-2xl {
    font-size: 1.35rem !important;
    line-height: 1.12 !important;
  }

  .px-6,
  .p-6,
  .p-8,
  .py-8 {
    padding: .95rem !important;
  }

  .gap-6 { gap: .95rem !important; }
  .gap-5 { gap: .85rem !important; }
  .gap-4 { gap: .75rem !important; }
}

/* Tabelas sem card mobile manual: transformadas em cards por fleetlog-mobile.js */
@media (max-width: 768px) {
  table.fleetlog-mobile-table {
    width: 100% !important;
    min-width: 0 !important;
    border-collapse: separate !important;
    border-spacing: 0 .75rem !important;
  }

  table.fleetlog-mobile-table thead,
  table.fleetlog-mobile-table colgroup {
    display: none !important;
  }

  table.fleetlog-mobile-table tbody,
  table.fleetlog-mobile-table tfoot,
  table.fleetlog-mobile-table tr,
  table.fleetlog-mobile-table td,
  table.fleetlog-mobile-table th {
    display: block !important;
    width: 100% !important;
  }

  table.fleetlog-mobile-table tbody tr,
  table.fleetlog-mobile-table tfoot tr {
    margin: 0 0 .75rem !important;
    padding: .85rem !important;
    border: 1px solid rgba(226, 232, 240, .96) !important;
    border-radius: 1rem !important;
    background: linear-gradient(180deg, #fff, #f8fafc) !important;
    box-shadow: 0 12px 26px rgba(15, 23, 42, .06) !important;
  }

  table.fleetlog-mobile-table td,
  table.fleetlog-mobile-table th {
    display: grid !important;
    grid-template-columns: minmax(6.5rem, 38%) minmax(0, 1fr) !important;
    gap: .65rem !important;
    align-items: center !important;
    padding: .55rem 0 !important;
    border: 0 !important;
    text-align: left !important;
    white-space: normal !important;
    word-break: break-word !important;
  }

  table.fleetlog-mobile-table td + td,
  table.fleetlog-mobile-table th + th {
    border-top: 1px solid rgba(226, 232, 240, .76) !important;
  }

  table.fleetlog-mobile-table td::before,
  table.fleetlog-mobile-table th::before {
    content: attr(data-mobile-label);
    color: #64748b;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
  }

  table.fleetlog-mobile-table td[data-mobile-label=""],
  table.fleetlog-mobile-table th[data-mobile-label=""] {
    grid-template-columns: 1fr !important;
  }

  table.fleetlog-mobile-table td[data-mobile-label=""]::before,
  table.fleetlog-mobile-table th[data-mobile-label=""]::before {
    display: none !important;
  }
}
