/* ==========================================
   PWA MOBILE - Layout Reestruturado
   Prioridade: telas cheias, velocidade, offline
   ========================================== */

/* Reset PWA */
.pwa-screen {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    background: #f5f5f5;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999;
    -webkit-overflow-scrolling: touch;
}

.pwa-screen.hidden {
    display: none !important;
}

/* Quando PWA está ativo, esconder layout web */
body.pwa-mode #appScreen {
    display: none !important;
}

/* ==========================================
   HEADER PWA
   ========================================== */
.pwa-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    min-height: 48px;
    padding: 0 12px;
    background: #dc2626;
    color: #fff;
    flex-shrink: 0;
    padding-top: env(safe-area-inset-top, 0);
    z-index: 100;
}

.pwa-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.pwa-user-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    width: 100%;
}

.pwa-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.pwa-sync-badge {
    position: relative;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    font-size: 16px;
}

.pwa-sync-badge:active {
    background: rgba(255,255,255,0.3);
}

.pwa-sync-badge span {
    display: inline-block;
}

.pwa-pending {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #fbbf24;
    color: #000;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
}

.pwa-pending.hidden {
    display: none;
}

.pwa-online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    flex-shrink: 0;
}

.pwa-online-dot.offline {
    background: #fbbf24;
}

/* ==========================================
   CONTENT PWA - Área principal scrollável
   ========================================== */
.pwa-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    padding: 0;
    will-change: scroll-position;
    transform: translateZ(0);
    scroll-behavior: smooth;
}

/* ==========================================
   BOTTOM TABS PWA
   ========================================== */
.pwa-tabs {
    display: flex !important;
    height: 56px;
    min-height: 56px;
    background: #fff;
    border-top: 1px solid #e5e5e5;
    flex-shrink: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 100;
}

.pwa-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: none;
    background: none;
    color: #9ca3af;
    font-size: 10px;
    padding: 4px 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s;
    user-select: none;
    -webkit-user-select: none;
}

.pwa-tab:active {
    background: #f3f4f6;
}

.pwa-tab.active {
    color: #dc2626;
}

.pwa-tab-icon {
    font-size: 20px;
    line-height: 1;
}

.pwa-tab-label {
    font-weight: 500;
    letter-spacing: -0.01em;
}

/* ==========================================
   PÁGINAS PWA - Layout de tela cheia
   ========================================== */
.pwa-page {
    padding: 12px;
    min-height: 100%;
}

.pwa-fullscreen-page {
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.pwa-page-header-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 50;
}

.pwa-page-header-title {
    font-size: 17px;
    font-weight: 700;
    color: #1f2937;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-back-btn {
    background: none;
    border: none;
    font-size: 22px;
    color: #374151;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 6px;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.pwa-back-btn:active {
    background: #f3f4f6;
}

.pwa-page-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ==========================================
   WELCOME CARD (Home)
   ========================================== */
.pwa-welcome-card {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: #fff;
    padding: 20px 18px;
    border-radius: 12px;
    margin-bottom: 16px;
}

.pwa-welcome-greeting {
    font-size: 14px;
    opacity: 0.9;
}

.pwa-welcome-name {
    font-size: 20px;
    font-weight: 700;
    margin-top: 2px;
}

.pwa-welcome-date {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 6px;
}

/* ==========================================
   SECTION TITLE
   ========================================== */
.pwa-section-title {
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin: 16px 0 10px 0;
}

/* ==========================================
   CARDS
   ========================================== */
.pwa-card {
    background: #fff;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    transform: translateZ(0);
}

/* ==========================================
   ACTION BUTTONS
   ========================================== */
.pwa-action-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    margin-bottom: 8px;
    font-size: 15px;
    font-weight: 500;
    color: #1f2937;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.1s;
    text-align: left;
}

.pwa-action-btn:active {
    background: #f3f4f6;
}

.pwa-action-btn .pwa-action-icon {
    font-size: 24px;
    width: 36px;
    text-align: center;
    flex-shrink: 0;
}

.pwa-action-btn .pwa-action-text {
    flex: 1;
}

.pwa-action-btn .pwa-action-arrow {
    color: #d1d5db;
    font-size: 18px;
}

/* ==========================================
   STATUS ROW (Home)
   ========================================== */
.pwa-status-row {
    display: flex;
    gap: 12px;
    background: #fff;
    border-radius: 10px;
    padding: 14px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.pwa-status-item {
    flex: 1;
    text-align: center;
}

.pwa-status-number {
    font-size: 24px;
    font-weight: 700;
}

.pwa-status-label {
    font-size: 11px;
    color: #6b7280;
    margin-top: 2px;
}

/* ==========================================
   ROTEIRO DO DIA (Home)
   ========================================== */
.pwa-roteiro-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f3f4f6;
    gap: 10px;
}

.pwa-roteiro-item:last-child {
    border-bottom: none;
}

.pwa-roteiro-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.pwa-roteiro-status.visitado {
    background: #22c55e;
}

.pwa-roteiro-status.pendente {
    background: #e5e7eb;
}

.pwa-roteiro-status.atual {
    background: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}

.pwa-roteiro-info {
    flex: 1;
    min-width: 0;
}

.pwa-roteiro-nome {
    font-size: 14px;
    font-weight: 500;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-roteiro-detalhe {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 2px;
}

.pwa-roteiro-hora {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
    white-space: nowrap;
}

/* ==========================================
   CONSULTAS LIST
   ========================================== */
.pwa-consulta-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: #fff;
    border-radius: 10px;
    margin-bottom: 8px;
    gap: 12px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.pwa-consulta-item:active {
    background: #f9fafb;
}

.pwa-consulta-icon {
    font-size: 24px;
    width: 36px;
    text-align: center;
    flex-shrink: 0;
}

.pwa-consulta-label {
    flex: 1;
    font-size: 15px;
    font-weight: 500;
    color: #1f2937;
}

.pwa-consulta-arrow {
    color: #d1d5db;
    font-size: 18px;
}

/* ==========================================
   MENU (Mais)
   ========================================== */
.pwa-menu-group {
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.pwa-menu-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: #fff;
    gap: 12px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.pwa-menu-item:last-child {
    border-bottom: none;
}

.pwa-menu-item:active {
    background: #f9fafb;
}

.pwa-menu-icon {
    font-size: 20px;
    width: 28px;
    text-align: center;
}

.pwa-menu-label {
    flex: 1;
    font-size: 15px;
    color: #1f2937;
}

.pwa-menu-value {
    font-size: 13px;
    color: #9ca3af;
}

.pwa-menu-item.danger .pwa-menu-label {
    color: #dc2626;
}

/* Avatar */
.pwa-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #dc2626;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    margin: 0 auto;
}

/* ==========================================
   FILTROS COLAPSÁVEIS - Para consultas PWA
   ========================================== */
.pwa-filtros-toggle {
    display: block;
    width: 100%;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    text-align: left;
    margin-bottom: 8px;
    -webkit-tap-highlight-color: transparent;
}

.pwa-filtros-toggle:active {
    background: #f3f4f6;
}

.pwa-filtros-wrapper {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.pwa-filtros-wrapper.pwa-filtros-aberto {
    max-height: 2000px;
}

/* Override: filtros dentro do PWA ficam em coluna */
body.pwa-mode .pwa-filtros-wrapper .filter-bar,
body.pwa-mode .pwa-filtros-wrapper .filter-bar-wide {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    padding: 12px !important;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    margin-bottom: 8px;
}

body.pwa-mode .pwa-filtros-wrapper .filter-bar > *,
body.pwa-mode .pwa-filtros-wrapper .filter-bar-wide > * {
    width: 100% !important;
    max-width: 100% !important;
}

/* ==========================================
   MODAL INLINE NO PWA (v3 - zero overlays)
   Modal de captura renderizado DENTRO do
   pwaContent como conteúdo inline
   ========================================== */

/* Quando o modal está inline (dentro do pwaContent), remover comportamento de overlay */
body.pwa-mode .modal.pwa-inline-modal {
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    height: 100% !important;
    flex: 1 !important;
    min-height: 0 !important;
    background: none !important;
    z-index: auto !important;
    padding: 0 !important;
    overflow: hidden !important;
    align-items: stretch !important;
}

body.pwa-mode .modal.pwa-inline-modal .modal-content,
body.pwa-mode .modal.pwa-inline-modal .modal-content.captura-modal {
    position: relative !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    overflow: hidden !important;
}

/* Esconder backdrop/overlay quando modal é inline */
body.pwa-mode .modal.pwa-inline-modal::before,
body.pwa-mode .modal.pwa-inline-modal::after {
    display: none !important;
}

/* Modais NÃO-captura: tela dedicada fullscreen (sem popup flutuante) */
body.pwa-mode .modal.active:not(.pwa-inline-modal) {
    z-index: 10001 !important;
    padding: 0 !important;
    align-items: stretch !important;
    background: #fff !important;
    pointer-events: auto !important;
}

body.pwa-mode .modal.active:not(.pwa-inline-modal) .modal-content {
    max-width: 100vw !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    animation: none !important;
}

body.pwa-mode .modal.active:not(.pwa-inline-modal) .modal-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 12px 16px !important;
}

body.pwa-mode .modal.active:not(.pwa-inline-modal) .modal-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

body.pwa-mode .modal.active:not(.pwa-inline-modal) .modal-footer {
    position: sticky;
    bottom: 0;
    z-index: 10;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    padding: 12px 16px !important;
}

/* Modal-backdrop do criarModalOverlay: tela dedicada fullscreen */
body.pwa-mode .modal-backdrop {
    z-index: 10001 !important;
    background: #fff !important;
    padding: 0 !important;
}

body.pwa-mode .modal-backdrop .modal-container {
    max-width: 100vw !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

body.pwa-mode .modal-overlay {
    z-index: 10001 !important;
}

/* Header do modal captura: estilo de tela dedicada */
body.pwa-mode .captura-header {
    padding: 12px 16px !important;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 10;
}

body.pwa-mode .captura-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

body.pwa-mode .captura-title-group {
    flex: 1;
    min-width: 0;
}

body.pwa-mode .captura-title-group h3 {
    font-size: 16px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Botão fechar do modal: estilo de botão voltar */
body.pwa-mode .captura-close {
    font-size: 28px !important;
    padding: 4px 8px !important;
    order: -1;
}

/* Camera area no PWA: maximizar espaço */
body.pwa-mode .captura-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 12px !important;
    display: flex;
    flex-direction: column;
}

body.pwa-mode .camera-wrapper {
    width: 100% !important;
    flex: 1 !important;
    display: flex;
    flex-direction: column;
}

body.pwa-mode .camera-area {
    width: 100% !important;
    flex: 1 !important;
    max-height: none !important;
    display: flex;
    flex-direction: column;
}

body.pwa-mode #videoPreview,
body.pwa-mode #canvasCaptura {
    flex: 1 !important;
    width: 100% !important;
    max-height: none !important;
    /* contain garante WYSIWYG: o que o usuário vê na área é exatamente
       o que será capturado (sem corte/zoom invisível) */
    object-fit: contain;
    background: #000;
}

/* Footer do modal: botões compactos no topo */
body.pwa-mode .captura-footer {
    padding: 6px 10px !important;
    gap: 6px !important;
    flex-wrap: nowrap;
    border-top: none;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
    position: sticky;
    top: 0;
    order: -1;
    z-index: 10;
    flex-shrink: 0;
}

body.pwa-mode .captura-actions-left {
    display: none !important; /* Esconder btn permitir câmera no topo */
}

body.pwa-mode .captura-actions-right {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    width: 100%;
    justify-content: space-between;
}

body.pwa-mode .captura-actions-right .btn {
    flex: 1;
    min-width: 0;
    padding: 8px 4px !important;
    font-size: 11px !important;
    text-align: center;
    justify-content: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

body.pwa-mode .captura-actions-right .btn .btn-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Localização no PWA: compacta */
body.pwa-mode .captura-localizacao {
    padding: 4px 10px 0 !important;
    flex-shrink: 0;
}

body.pwa-mode .gps-chip {
    width: 100% !important;
    padding: 6px 10px !important;
}

/* Ocultar hint text no PWA (economiza espaço) */
body.pwa-mode #capturaHint {
    display: none !important;
}

/* Resumo de atividades no PWA */
body.pwa-mode .resumo-atividades {
    margin: 0 12px !important;
    border-radius: 8px;
}

/* ==========================================
   CHECK-IN BADGE (tela dedicada)
   ========================================== */
.pwa-checkin-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.pwa-checkin-info {
    padding: 10px 16px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.pwa-checkin-cliente {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
}

.pwa-checkin-endereco {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

.pwa-checkin-data {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 2px;
}

.pwa-checkin-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    color: #6b7280;
    font-size: 14px;
}

.pwa-checkin-modal-area {
    flex: 1;
    overflow-y: auto;
}

/* Área inline para o modal de captura dentro do checkin */
.pwa-checkin-inline-area {
    flex: 1;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
    background: #fff;
    display: flex;
    flex-direction: column;
}

.pwa-checkin-page {
    height: 100%;
}

/* ==========================================
   INPUTS PWA
   ========================================== */
.pwa-input-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    -webkit-appearance: none;
}

.pwa-input-textarea:focus {
    outline: none;
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.pwa-btn-primary {
    width: 100%;
    padding: 14px;
    background: #1f2937;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.pwa-btn-primary:active {
    background: #111827;
}

.pwa-btn-primary:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

/* ==========================================
   ALERTAS PWA
   ========================================== */
.pwa-alert-success {
    background: #d1fae5;
    color: #065f46;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    border-left: 4px solid #10b981;
}

.pwa-alert-warning {
    background: #fef3c7;
    color: #92400e;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    border-left: 4px solid #f59e0b;
}

.pwa-alert-error {
    background: #fef2f2;
    color: #991b1b;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    border-left: 4px solid #ef4444;
}

/* ==========================================
   TOAST (notificações flutuantes)
   Posicionado acima das tabs, desaparece
   automaticamente, sem bloquear cliques
   ========================================== */
.pwa-toast {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: #1f2937;
    color: #fff;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    z-index: 20000;
    transition: transform 0.3s ease, opacity 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    white-space: nowrap;
    max-width: 90vw;
    text-align: center;
    pointer-events: none;
    opacity: 0;
}

.pwa-toast-error {
    background: #dc2626;
}

.pwa-toast-show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    display: block !important;
}

/* ==========================================
   LOADING / EMPTY STATES
   ========================================== */
.pwa-loading-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px;
    color: #6b7280;
    font-size: 14px;
}

.pwa-spinner-small {
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #dc2626;
    border-radius: 50%;
    animation: pwa-spin 0.8s linear infinite;
}

.pwa-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #9ca3af;
}

.pwa-empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.pwa-empty-text {
    font-size: 14px;
    color: #6b7280;
}

.pwa-empty-hint {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 4px;
}

/* Loading skeleton */
.pwa-skeleton {
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: pwa-shimmer 1.2s ease-in-out infinite;
    border-radius: 6px;
    height: 16px;
    margin-bottom: 8px;
}

@keyframes pwa-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes pwa-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Overlay bloqueante durante envio do checkout */
#pwaCheckoutOverlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pwa-checkout-overlay-inner {
    background: #fff;
    border-radius: 16px;
    padding: 32px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    min-width: 200px;
}

.pwa-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top: 4px solid #dc2626;
    border-radius: 50%;
    animation: pwa-spin 0.8s linear infinite;
}

.pwa-checkout-overlay-msg {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #374151;
    text-align: center;
}

/* ==========================================
   PERFORMANCE - Otimizações
   ========================================== */
@media (hover: none) {
    .pwa-tab:hover,
    .pwa-action-btn:hover,
    .pwa-consulta-item:hover,
    .pwa-menu-item:hover {
        background: inherit;
    }
}

/* Safe area for notch phones */
@supports (padding-top: env(safe-area-inset-top)) {
    .pwa-header {
        height: calc(48px + env(safe-area-inset-top));
        padding-top: env(safe-area-inset-top);
    }

    .pwa-tabs {
        height: calc(56px + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Login PWA override */
body.pwa-mode .login-screen {
    z-index: 10000;
}

body.pwa-mode .login-container {
    min-height: 100dvh;
}

body.pwa-mode .login-card {
    max-width: 100%;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 24px 20px;
}

body.pwa-mode .login-logo {
    width: 80px;
    height: 80px;
}

body.pwa-mode .login-card h1 {
    font-size: 20px;
}

body.pwa-mode .login-card h2 {
    font-size: 14px;
}

/* ==========================================
   PWA MODE OVERRIDES para conteúdo do app.js
   Garante que as páginas delegadas ao app.js
   fiquem com layout correto no PWA
   ========================================== */

/* Filtros: no PWA forçar layout vertical */
body.pwa-mode .pwa-page-body .filter-bar,
body.pwa-mode .pwa-page-body .filter-bar-wide,
body.pwa-mode .pwa-page-body .doc-filter-section,
body.pwa-mode .pwa-page-body .performance-filters {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    padding: 12px !important;
    position: relative !important;
    top: auto !important;
    z-index: auto !important;
}

/* Inputs no PWA: largura total */
body.pwa-mode .pwa-page-body .form-group,
body.pwa-mode .pwa-page-body .filter-group {
    width: 100% !important;
}

body.pwa-mode .pwa-page-body select,
body.pwa-mode .pwa-page-body input[type="text"],
body.pwa-mode .pwa-page-body input[type="date"],
body.pwa-mode .pwa-page-body input[type="number"] {
    width: 100% !important;
    font-size: 16px !important; /* Evita zoom no iOS */
    padding: 10px !important;
}

/* Botões de ação no PWA */
body.pwa-mode .pwa-page-body .btn {
    padding: 12px 16px !important;
    font-size: 14px !important;
}

/* ==========================================
   ROUTE ITEMS - Layout mobile otimizado
   Cards de cliente no registro de rota
   ========================================== */

/* Card do cliente: layout em coluna para mobile */
body.pwa-mode .route-item {
    display: flex !important;
    flex-direction: column !important;
    padding: 14px !important;
    margin-bottom: 8px !important;
    border-radius: 10px !important;
    background: #fff;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

body.pwa-mode .route-item-info {
    width: 100% !important;
    margin-bottom: 10px;
}

body.pwa-mode .route-item-name {
    font-size: 15px !important;
    font-weight: 600 !important;
    color: #1f2937;
    line-height: 1.3;
}

body.pwa-mode .route-item-address {
    font-size: 12px !important;
    color: #6b7280;
    margin-top: 4px;
    line-height: 1.4;
}

body.pwa-mode .route-item-distance {
    font-size: 12px !important;
    color: #6b7280;
    margin-top: 4px;
}

body.pwa-mode .route-item-time {
    font-size: 12px !important;
    color: #059669;
    margin-top: 4px;
}

/* Status badge */
body.pwa-mode .route-status {
    display: inline-block;
    padding: 4px 10px !important;
    border-radius: 12px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    margin-bottom: 8px;
}

/* Botões de ação: grid para aproveitamento do espaço */
body.pwa-mode .route-item-actions {
    width: 100% !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    margin-top: 0 !important;
}

body.pwa-mode .route-item-actions .btn-small {
    flex: 1 1 auto;
    min-width: 0;
    padding: 10px 8px !important;
    font-size: 13px !important;
    border-radius: 8px !important;
    text-align: center;
    justify-content: center;
    white-space: nowrap;
}

/* Botão de Check-in: destaque */
body.pwa-mode .route-item-actions .btn-small:first-child {
    flex: 1 1 100%;
}

/* Cards de resultado no PWA: full width */
body.pwa-mode .pwa-page-body .roteiro-card,
body.pwa-mode .pwa-page-body .visita-item,
body.pwa-mode .pwa-page-body .visit-item,
body.pwa-mode .pwa-page-body .doc-item {
    width: 100% !important;
    max-width: 100% !important;
}

/* Container do roteiro no PWA */
body.pwa-mode #roteiroContainer {
    padding: 0 4px !important;
}

body.pwa-mode #roteiroContainer .empty-state {
    padding: 30px 20px;
}

/* Tabelas no PWA: scroll horizontal */
body.pwa-mode .pwa-page-body table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 13px;
}

body.pwa-mode .pwa-page-body th,
body.pwa-mode .pwa-page-body td {
    white-space: nowrap;
    padding: 8px 10px !important;
}

/* Upload section no PWA */
body.pwa-mode .pwa-page-body .doc-upload-section {
    padding: 12px !important;
}

body.pwa-mode .pwa-page-body .doc-upload-section .form-row {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
}

/* Esconder sticky filters (já colapsáveis) */
body.pwa-mode .pwa-page-body .filter-bar[style*="sticky"],
body.pwa-mode .pwa-page-body .filter-bar[style*="position: sticky"] {
    position: relative !important;
}

/* ==========================================
   PWA ROTA BODY - Estilos da tela de rota
   ========================================== */
.pwa-rota-body {
    padding: 0 !important;
    background: #f5f5f5;
}

/* Notificações do app.js no PWA: posicionar no topo */
body.pwa-mode .notification {
    position: fixed !important;
    top: 56px !important;
    left: 8px !important;
    right: 8px !important;
    z-index: 10003 !important;
    border-radius: 8px !important;
    font-size: 13px !important;
    padding: 10px 12px !important;
}

/* ==========================================
   PWA FOCO CLIENTE - Quando em atendimento
   ========================================== */

/* Card do cliente em foco (em atendimento) */
body.pwa-mode .route-item.pwa-cliente-foco {
    border: 2px solid #3b82f6;
    border-radius: 12px;
    padding: 16px;
    margin: 8px;
    background: #fff;
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.15);
}

body.pwa-mode .route-item.pwa-cliente-foco .route-item-name {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
}

body.pwa-mode .route-item.pwa-cliente-foco .route-item-address {
    font-size: 14px;
    color: #6b7280;
    margin-top: 4px;
}

/* Botões grandes no modo foco */
body.pwa-mode .route-item.pwa-cliente-foco .route-item-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

body.pwa-mode .route-item.pwa-cliente-foco .route-item-actions .btn-small {
    flex: 1 1 calc(50% - 4px);
    min-height: 52px;
    font-size: 15px;
    font-weight: 600;
    padding: 12px 8px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

body.pwa-mode .route-item.pwa-cliente-foco .route-item-actions .btn-atividades {
    background: #3b82f6;
    color: #fff;
    order: 1;
}

body.pwa-mode .route-item.pwa-cliente-foco .route-item-actions .btn-campanha {
    background: #f59e0b;
    color: #fff;
    order: 2;
}

body.pwa-mode .route-item.pwa-cliente-foco .route-item-actions .btn-checkout {
    background: #dc2626;
    color: #fff;
    order: 3;
}

body.pwa-mode .route-item.pwa-cliente-foco .route-item-actions .btn-pesquisa {
    order: 4;
}

body.pwa-mode .route-item.pwa-cliente-foco .route-item-actions .btn-danger {
    flex: 1 1 100%;
    order: 10;
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #d1d5db;
}

body.pwa-mode .route-item.pwa-cliente-foco .route-status {
    width: 100%;
    text-align: center;
    font-size: 16px;
    padding: 10px 16px;
    border-radius: 12px;
    margin-bottom: 24px;
}

/* ==========================================
   PWA ATIVIDADES INLINE
   ========================================== */

/* Modal de atividades renderizado inline no PWA */
body.pwa-mode .pwa-atividades-inline {
    position: relative;
    background: #fff;
    border-radius: 0;
    width: 100%;
    max-width: 100%;
    max-height: none;
    overflow-y: auto;
    box-shadow: none;
}

body.pwa-mode .pwa-atividades-inline .modal-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 12px 16px;
}

body.pwa-mode .pwa-atividades-inline .modal-body {
    padding: 16px;
}

body.pwa-mode .pwa-atividades-inline .modal-footer {
    position: sticky;
    bottom: 0;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    padding: 12px 16px;
    display: flex;
    gap: 8px;
}

body.pwa-mode .pwa-atividades-inline .modal-footer .btn {
    flex: 1;
    min-height: 48px;
    font-size: 15px;
}


/* Utilities */
body.pwa-mode .pwa-hidden {
    display: none !important;
}


/* ==========================================
   PWA GALLERY OVERRIDE (Campanha - horizontal acima da câmera)
   ========================================== */

/* captura-main vira flex column para controlar ordem */
body.pwa-mode .pwa-inline-modal .captura-main {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    min-height: 0 !important;
}

/* Galeria fica ACIMA da câmera (order: -1) */
body.pwa-mode .pwa-inline-modal .captura-thumbs-wrapper {
    order: -1;
    flex-shrink: 0;
    display: flex !important;
    flex-direction: column;
    max-height: 90px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

body.pwa-mode .pwa-inline-modal .captura-thumbs-header {
    padding: 2px 8px;
    font-size: 10px;
    color: #6b7280;
    display: flex;
    justify-content: space-between;
    flex-shrink: 0;
}

/* Linha horizontal de miniaturas com scroll */
body.pwa-mode .pwa-inline-modal .camera-thumbs {
    display: flex !important;
    flex-direction: row !important;
    grid-template-columns: unset !important;
    gap: 6px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 4px 8px !important;
    flex: 1;
    align-items: center;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

body.pwa-mode .pwa-inline-modal .camera-thumbs::-webkit-scrollbar {
    display: none;
}

/* Miniaturas: quadradas e compactas */
body.pwa-mode .pwa-inline-modal .camera-thumb {
    width: 60px !important;
    height: 60px !important;
    min-width: 60px !important;
    aspect-ratio: unset !important;
    border-radius: 6px !important;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

body.pwa-mode .pwa-inline-modal .camera-thumb img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    background: #000;
    border-radius: 6px;
}

body.pwa-mode .pwa-inline-modal .camera-thumb .btn-remover-foto {
    width: 20px !important;
    height: 20px !important;
    font-size: 11px !important;
    top: 2px !important;
    right: 2px !important;
    background: rgba(220, 38, 38, 0.9) !important;
    border-radius: 50% !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    line-height: 1;
    min-width: unset !important;
}

/* Fotos já registradas: overlay verde com checkmark */
body.pwa-mode .pwa-inline-modal .camera-thumb-saved {
    border: 2px solid #16a34a !important;
    opacity: 0.85;
}

body.pwa-mode .pwa-inline-modal .thumb-saved-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: rgba(22, 163, 74, 0.9);
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Gallery fora do inline (non-PWA / outros) */
body.pwa-mode .camera-thumbs {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 16px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    padding: 10px 0 !important;
}

body.pwa-mode .camera-thumb {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 4/3;
    border-radius: 12px !important;
}

body.pwa-mode .camera-thumb img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    background: #000;
}

body.pwa-mode .camera-thumb .btn-remover-foto {
    width: 40px !important;
    height: 40px !important;
    font-size: 20px !important;
    top: 10px !important;
    right: 10px !important;
    background: rgba(220, 38, 38, 0.9) !important;
}

body.pwa-mode .captura-thumbs-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Preview de foto no espaço da câmera ao clicar miniatura */
.camera-preview-thumb {
    position: absolute;
    inset: 0;
    z-index: 50;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.camera-preview-thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.btn-fechar-preview {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    z-index: 51;
}

/* Cursor pointer em miniaturas clicáveis */
.camera-thumb {
    cursor: pointer;
}


/* ==========================================
   PWA ATIVIDADES INLINE OVERRIDES (Aggressive 1-column)
   ========================================== */
body.pwa-mode .atividades-form-grid,
body.pwa-mode .atividades-checklist-grid,
body.pwa-mode #modalAtividadesBody > div {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
}

body.pwa-mode .atividades-checklist-grid {
    gap: 12px !important;
}

body.pwa-mode .atividades-checklist-grid label.checkbox-label {
    padding: 16px !important;
    background: #f8fafc !important;
    border-radius: 12px !important;
    border: 1px solid #e2e8f0 !important;
    white-space: normal !important;
    word-break: break-word !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    margin: 0 !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

body.pwa-mode .atividades-checklist-grid input[type="checkbox"] {
    width: 24px !important;
    height: 24px !important;
    margin: 0 !important;
}

body.pwa-mode .form-group label {
    font-size: 16px !important;
    margin-bottom: 8px !important;
    display: block !important;
}

body.pwa-mode .form-group input[type="number"],
body.pwa-mode .form-group select {
    width: 100% !important;
    padding: 16px !important;
    font-size: 16px !important;
    border-radius: 12px !important;
    border: 1px solid #cbd5e1 !important;
    background: #fff !important;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}

body.pwa-mode .modal-title-pwa-hidden { display: none !important; }

/* Expande modal atividades para 95% e otimiza espaços para evitar scroll */
body.pwa-mode #modalAtividades .modal-content {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

body.pwa-mode #modalAtividades .modal-body {
    padding: 0 16px !important;
}

body.pwa-mode #modalAtividades .modal-header {
    padding-bottom: 8px !important;
    margin-bottom: 8px !important;
}

body.pwa-mode #modalAtividades .modal-footer {
    padding-top: 8px !important;
    margin-top: 8px !important;
}

body.pwa-mode .atividades-form-grid {
    gap: 8px !important;
}

body.pwa-mode .atividades-checklist-grid {
    gap: 8px !important;
}

body.pwa-mode .atividades-checklist-grid label.checkbox-label {
    padding: 12px 0 !important;
    font-size: 16px !important;
    background: transparent !important;
    border: none !important;
    border-bottom: 1px solid #e2e8f0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

body.pwa-mode .form-group label {
    margin-bottom: 4px !important;
}

body.pwa-mode .form-group input[type="number"],
body.pwa-mode .form-group select {
    padding: 10px !important;
}


body.pwa-mode .captura-hint {
    font-size: 14px !important;
    text-align: center !important;
    font-weight: 500 !important;
    margin: 8px 16px 0 !important;
    background: #f1f5f9 !important;
    padding: 8px !important;
    border-radius: 8px !important;
}

body.pwa-mode .captura-header {
    display: none !important;
}

body.pwa-mode .captura-localizacao {
    padding-top: 16px !important;
}

/* ==========================================
   PWA DOCS CAMERA OVERRIDE
   Make document camera fullscreen and push gallery to bottom
   ========================================== */
body.pwa-mode #modalCameraDocumentos .modal-content {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
}

body.pwa-mode #modalCameraDocumentos .modal-body {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
    overflow: hidden !important;
}

body.pwa-mode #modalCameraDocumentos .camera-area {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    background: #000;
}

body.pwa-mode #modalCameraDocumentos .camera-video {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
}

body.pwa-mode #modalCameraDocumentos .captura-thumbs-wrapper {
    flex-shrink: 0 !important;
    padding: 10px !important;
    background: #fff;
    max-height: 110px;
    overflow: hidden;
}

/* Thumbnails horizontais para câmera de documentos (igual estilo campanha) */
body.pwa-mode #modalCameraDocumentos .camera-thumbs {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    gap: 8px !important;
    grid-template-columns: unset !important;
    padding-bottom: 4px;
    scrollbar-width: none;
}

body.pwa-mode #modalCameraDocumentos .camera-thumbs::-webkit-scrollbar {
    display: none;
}

body.pwa-mode #modalCameraDocumentos .camera-thumb {
    width: 80px !important;
    height: 80px !important;
    min-width: 80px !important;
    flex-shrink: 0 !important;
    aspect-ratio: 1 !important;
    object-fit: cover !important;
    border-radius: 6px !important;
}

body.pwa-mode #modalCameraDocumentos .captura-hint {
    display: none !important; /* Hide hint to save space */
}

body.pwa-mode #modalCameraDocumentos .modal-footer {
    padding: 12px 16px !important;
}


/* ==========================================
   AGGRESSIVE MODAL TO SCREEN PWA OVERRIDE
   The user explicitly wants "no modals on top of posts", everything should feel like a screen
   ========================================== */
body.pwa-mode .modal.active {
    background: #fff !important;
}

body.pwa-mode .modal-content {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    display: flex !important;
    flex-direction: column !important;
}

body.pwa-mode .modal-header {
    flex-shrink: 0;
    padding: 16px !important;
    border-radius: 0 !important;
    background: #f8fafc !important;
    position: sticky;
    top: 0;
    z-index: 10;
}

body.pwa-mode .modal-body {
    flex: 1 !important;
    overflow-y: auto !important;
    padding: 16px !important;
}

body.pwa-mode .modal-footer {
    flex-shrink: 0;
    padding: 16px !important;
    background: #fff !important;
    position: sticky;
    bottom: 0;
    z-index: 10;
    border-radius: 0 !important;
}

/* ==========================================
   TELA DE SINCRONIZAÇÃO DIÁRIA
   ========================================== */

.pwa-daily-sync-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(160deg, #1e3a5f 0%, #dc2626 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 24px;
}

.pwa-daily-sync-overlay.hidden {
    display: none;
}

.pwa-daily-sync-card {
    background: rgba(255, 255, 255, 0.97);
    border-radius: 20px;
    padding: 40px 32px;
    text-align: center;
    width: 100%;
    max-width: 320px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.pwa-daily-sync-logo {
    width: 72px;
    height: 72px;
    border-radius: 14px;
    margin: 0 auto 20px;
    display: block;
}

.pwa-daily-sync-title {
    font-size: 22px;
    font-weight: 700;
    color: #1e3a5f;
    margin-bottom: 24px;
}

.pwa-daily-sync-spinner {
    font-size: 40px;
    color: #dc2626;
    animation: pwa-sync-spin 1.2s linear infinite;
    display: block;
    margin-bottom: 16px;
    line-height: 1;
}

@keyframes pwa-sync-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.pwa-daily-sync-status {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 24px;
    min-height: 20px;
    transition: opacity 0.3s ease;
}

.pwa-daily-sync-steps {
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
}

.pwa-sync-step {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #9ca3af;
    padding: 8px 12px;
    border-radius: 8px;
    background: #f9fafb;
    transition: all 0.3s ease;
}

.pwa-sync-step::before {
    content: '\25CB';
    font-size: 16px;
    flex-shrink: 0;
    color: #d1d5db;
}

.pwa-sync-step.active {
    color: #1e3a5f;
    background: #eff6ff;
}

.pwa-sync-step.active::before {
    content: '\27F3';
    color: #dc2626;
    animation: pwa-sync-spin 1s linear infinite;
    display: inline-block;
}

.pwa-sync-step.done {
    color: #065f46;
    background: #d1fae5;
}

.pwa-sync-step.done::before {
    content: '\2713';
    color: #10b981;
    animation: none;
}

/* ==========================================
   TELA DE ATENDIMENTO EM ANDAMENTO
   ========================================== */

.pwa-atendimento-page {
    padding-bottom: 16px;
}

.pwa-atendimento-cliente-card {
    margin: 16px;
    background: linear-gradient(135deg, #1e3a5f 0%, #2d5a87 100%);
    color: white;
    border-radius: 16px;
    padding: 20px;
}

.pwa-atendimento-cliente-nome {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 6px;
    line-height: 1.3;
}

.pwa-atendimento-cliente-end {
    font-size: 13px;
    opacity: 0.85;
    margin-bottom: 10px;
}

.pwa-atendimento-checkin-hora {
    font-size: 13px;
    background: rgba(255,255,255,0.2);
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    margin-top: 4px;
}

/* Grid 2x2 para botões de ação */
.pwa-atendimento-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 0 16px 16px;
}

.pwa-atendimento-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 12px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.pwa-atendimento-action-btn:active {
    transform: scale(0.96);
    background: #f9fafb;
}

.pwa-atendimento-action-icon {
    font-size: 28px;
    line-height: 1;
}

.pwa-atendimento-action-checkout {
    border-color: #fecaca;
    background: #fef2f2;
    color: #dc2626;
}

.pwa-atendimento-action-checkout:active {
    background: #fee2e2;
}

.pwa-atendimento-action-checkout.pwa-checkout-bloqueado,
.pwa-atendimento-action-checkout[disabled] {
    border-color: #e5e7eb;
    background: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
    pointer-events: none;
    opacity: 0.7;
}

.pwa-atendimento-cancelar-btn {
    width: 100%;
    padding: 14px;
    background: transparent;
    border: 2px solid #d1d5db;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.15s;
}

.pwa-atendimento-cancelar-btn:active {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}

/* ==========================================
   CORREÇÕES PWA - MODAIS E ATIVIDADES
   ========================================== */

/* Centrar botões do modal cancelar atendimento em PWA */
body.pwa-mode .modal-footer-inline {
    justify-content: center !important;
    gap: 16px !important;
}

/* Botão Confirmar no header de atividades */
.pwa-header-confirmar-btn {
    margin-left: auto;
    background: #16a34a;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.pwa-header-confirmar-btn:active {
    background: #15803d;
    transform: scale(0.97);
}

/* Atividades inline: conteúdo ocupa todo o espaço disponível */
.pwa-atividades-inline {
    box-shadow: none !important;
    border-radius: 0 !important;
    max-height: none !important;
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.pwa-atividades-inline .modal-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ==========================================
   BANNER - ATENDIMENTO ATIVO NO ROTEIRO
   ========================================== */

.pwa-atendimento-ativo-banner {
    margin: 12px 16px 0;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    color: white;
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
    animation: pwa-banner-pulse 2.5s ease-in-out infinite;
}

@keyframes pwa-banner-pulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35); }
    50%       { box-shadow: 0 4px 24px rgba(37, 99, 235, 0.60); }
}

.pwa-aab-info {
    flex: 1;
    min-width: 0;
}

.pwa-aab-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.8;
    margin-bottom: 2px;
}

.pwa-aab-nome {
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-aab-end {
    font-size: 12px;
    opacity: 0.75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.pwa-aab-btn {
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Quando há atendimento ativo, esconder botões de ação dos cards de cliente */
.pwa-atendimento-ativo .route-item-actions .btn-small,
.pwa-atendimento-ativo .route-item-actions .btn-checkout,
.pwa-atendimento-ativo .route-item-actions .btn-atividades,
.pwa-atendimento-ativo .route-item-actions .btn-pesquisa,
.pwa-atendimento-ativo .route-item-actions .btn-campanha,
.pwa-atendimento-ativo .route-item-actions .btn-danger {
    display: none !important;
}

/* ==========================================
   CAMPANHA: FOOTER DE BOTÕES ACIMA DA GALERIA
   ========================================== */

/* Em PWA inline o footer de captura deve ficar no TOPO */
body.pwa-mode .pwa-inline-modal .captura-footer {
    order: -2;
    position: sticky;
    top: 0;
    bottom: auto !important;
    border-top: none !important;
    border-bottom: 1px solid #e5e7eb;
    z-index: 20;
    flex-shrink: 0;
}

/* GPS logo abaixo dos botões */
body.pwa-mode .pwa-inline-modal .captura-localizacao {
    order: -1;
    flex-shrink: 0;
}

/* O modal-body (câmera + galeria) preenche o espaço restante */
body.pwa-mode .pwa-inline-modal .captura-body {
    order: 0;
    overflow: hidden;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0 !important;
}

/* camera-wrapper ocupa todo espaço restante */
body.pwa-mode .pwa-inline-modal .camera-wrapper {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

body.pwa-mode .pwa-inline-modal .camera-area {
    flex: 1;
    min-height: 0;
}

/* ==========================================
   CANCELAR ATENDIMENTO: BOTÕES CENTRALIZADOS
   ========================================== */

body.pwa-mode .modal-footer-inline {
    display: flex !important;
    flex-direction: row !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 12px !important;
    flex-wrap: wrap;
}

body.pwa-mode .modal-footer-inline .btn {
    flex: 1;
    min-width: 120px;
    max-width: 200px;
    text-align: center;
    justify-content: center;
}

/* ==========================================
   HOME: AVISO DE ATENDIMENTO EM ANDAMENTO
   ========================================== */

.pwa-home-atendimento-aviso {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 16px 8px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #f59e0b;
    border-radius: 14px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    animation: pwa-banner-pulse 2.5s ease-in-out infinite;
}

.pwa-home-aviso-icon {
    font-size: 22px;
    flex-shrink: 0;
}

.pwa-home-aviso-info {
    flex: 1;
    min-width: 0;
}

.pwa-home-aviso-title {
    font-size: 12px;
    font-weight: 700;
    color: #92400e;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.pwa-home-aviso-nome {
    font-size: 14px;
    font-weight: 600;
    color: #78350f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.pwa-home-aviso-btn {
    font-size: 13px;
    font-weight: 700;
    color: #92400e;
    white-space: nowrap;
    flex-shrink: 0;
}
