/* ═══════════════════════════════════════════════════════════════════════
   Guianeo PWA — Estilos Mobile
   Bottom Nav · Install Modal · Skeleton · Pull-to-Refresh · Standalone
═══════════════════════════════════════════════════════════════════════ */

/* ── Variáveis ────────────────────────────────────────────────────── */
:root {
    --pwa-primary:     #277493;
    --pwa-primary-bg:  #e8f4f8;
    --pwa-text:        #0f172a;
    --pwa-muted:       #94a3b8;
    --pwa-border:      #e2e8f0;
    --pwa-safe-bottom: env(safe-area-inset-bottom, 0px);
    --pwa-safe-top:    env(safe-area-inset-top, 0px);
    --pwa-nav-height:  60px;
}

/* ── Safe area para modo standalone (iPhone X+) ───────────────────── */
@media all and (display-mode: standalone) {
    body { overscroll-behavior: none; }
}

/* ═══════════════════════════════════════════════════════════════════
   BOTTOM NAVIGATION (só público, só mobile)
═══════════════════════════════════════════════════════════════════ */

.pwa-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 8500;
    background: #fff;
    border-top: 1px solid var(--pwa-border);
    box-shadow: 0 -2px 16px rgba(0,0,0,.06);
    padding-bottom: var(--pwa-safe-bottom);
}

@media (max-width: 768px) {
    .pwa-nav { display: flex; }

    /* Empurra o conteúdo para não ficar atrás da nav */
    body.has-pwa-nav { padding-bottom: calc(var(--pwa-nav-height) + var(--pwa-safe-bottom)); }

    /* Oculta footer na tela de empresa (já tem nav própria no app) */
    .gnv-footer { margin-bottom: calc(var(--pwa-nav-height) + var(--pwa-safe-bottom)); }
}

.pwa-nav__items {
    display: flex;
    align-items: stretch;
    width: 100%;
    height: var(--pwa-nav-height);
}

.pwa-nav__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--pwa-muted);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .2px;
    padding: 6px 2px;
    cursor: pointer;
    background: none;
    border: none;
    font-family: inherit;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    transition: color .15s;
}

.pwa-nav__item i {
    font-size: 20px;
    line-height: 1;
    transition: transform .2s cubic-bezier(.34,1.56,.64,1);
}

.pwa-nav__item span {
    line-height: 1;
    margin-top: 1px;
}

/* Active state */
.pwa-nav__item.pwa-active {
    color: var(--pwa-primary);
}

.pwa-nav__item.pwa-active i {
    transform: scale(1.15) translateY(-1px);
}

/* Active indicator pill */
.pwa-nav__item.pwa-active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: var(--pwa-primary);
    border-radius: 0 0 6px 6px;
}

/* Tap feedback */
.pwa-nav__item:active {
    transform: scale(.88);
}

/* Favoritos badge */
.pwa-nav__badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 16px);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: #ef4444;
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    border-radius: 99px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border: 1.5px solid #fff;
}

/* ═══════════════════════════════════════════════════════════════════
   INSTALL MODAL
═══════════════════════════════════════════════════════════════════ */

.pwa-install-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 99998;
    align-items: flex-end;
    justify-content: center;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.pwa-install-overlay.open {
    display: flex;
    animation: pwa-fadein .25s ease;
}

@keyframes pwa-fadein {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.pwa-install-box {
    background: #fff;
    border-radius: 24px 24px 0 0;
    padding: 0 0 0;
    width: 100%;
    max-width: 520px;
    animation: pwa-slideup .32s cubic-bezier(.32,.72,0,1);
    position: relative;
    overflow: hidden;
    padding-bottom: var(--pwa-safe-bottom);
}

@keyframes pwa-slideup {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.pwa-install-handle {
    display: flex;
    justify-content: center;
    padding: 12px 0 4px;
}

.pwa-install-handle span {
    width: 36px;
    height: 4px;
    background: var(--pwa-border);
    border-radius: 99px;
}

.pwa-install-inner {
    padding: 12px 24px 28px;
}

.pwa-install-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.pwa-install-icon {
    width: 58px;
    height: 58px;
    border-radius: 14px;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(0,0,0,.12);
}

.pwa-install-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pwa-install-header-text h3 {
    font-size: 18px;
    font-weight: 800;
    color: var(--pwa-text);
    margin: 0 0 3px;
}

.pwa-install-header-text p {
    font-size: 13px;
    color: var(--pwa-muted);
    margin: 0;
}

.pwa-install-benefits {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0 0 22px;
    padding: 14px;
    background: #f8fafc;
    border-radius: 14px;
}

.pwa-install-benefit {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pwa-install-benefit-icon {
    width: 32px;
    height: 32px;
    background: var(--pwa-primary-bg);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--pwa-primary);
    font-size: 14px;
    flex-shrink: 0;
}

.pwa-install-benefit-text {
    font-size: 13px;
    color: #374151;
    font-weight: 500;
}

.pwa-install-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pwa-install-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 15px 20px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: all .15s;
    -webkit-tap-highlight-color: transparent;
}

.pwa-install-btn--primary {
    background: var(--pwa-primary);
    color: #fff;
    box-shadow: 0 4px 16px rgba(39,116,147,.3);
}

.pwa-install-btn--primary:hover,
.pwa-install-btn--primary:active {
    background: #1d5a72;
}

.pwa-install-btn--secondary {
    background: none;
    color: var(--pwa-muted);
    font-size: 13px;
    font-weight: 500;
    padding: 10px;
}

/* iOS-specific instructions */
.pwa-ios-hint {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 10px;
    font-size: 12px;
    color: #15803d;
    font-weight: 500;
    margin-top: 8px;
}

.pwa-ios-hint i { font-size: 16px; }

/* ═══════════════════════════════════════════════════════════════════
   SKELETON LOADING
═══════════════════════════════════════════════════════════════════ */

.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e8edf5 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: skeleton-wave 1.6s linear infinite;
    border-radius: 8px;
    display: block;
}

@keyframes skeleton-wave {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-card  { height: 140px; border-radius: 14px; }
.skeleton-text  { height: 14px; margin-top: 8px; }
.skeleton-text-sm { height: 11px; width: 55%; margin-top: 6px; }
.skeleton-avatar { width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0; }

.skeleton-cards-row {
    display: flex;
    gap: 12px;
    overflow: hidden;
    padding: 4px 2px;
}

.skeleton-cards-row .skeleton-card {
    min-width: 160px;
    flex: 1;
}

/* ═══════════════════════════════════════════════════════════════════
   PULL-TO-REFRESH
═══════════════════════════════════════════════════════════════════ */

.pwa-ptr {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 8000;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    font-size: 13px;
    font-weight: 600;
    color: var(--pwa-primary);
    transform: translateY(-100%);
    transition: transform .22s cubic-bezier(.32,.72,0,1);
    pointer-events: none;
}

.pwa-ptr.pwa-ptr--visible {
    transform: translateY(0);
}

.pwa-ptr i {
    font-size: 18px;
    transition: transform .3s;
}

.pwa-ptr.pwa-ptr--loading i {
    animation: pwa-spin 1s linear infinite;
}

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

/* ═══════════════════════════════════════════════════════════════════
   APP UPDATE TOAST (banner de nova versão)
═══════════════════════════════════════════════════════════════════ */

.pwa-update-bar {
    display: none;
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    background: var(--pwa-text);
    color: #fff;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0,0,0,.2);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    max-width: calc(100vw - 32px);
    animation: pwa-fadein .25s ease;
}

.pwa-update-bar.pwa-update-bar--show {
    display: flex;
}

.pwa-update-bar button {
    background: var(--pwa-primary);
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════════
   MOBILE UX HELPERS
═══════════════════════════════════════════════════════════════════ */

/* Smooth page transitions */
@media (max-width: 768px) {
    .gnv-main-content,
    [data-pwa-content] {
        animation: pwa-content-in .2s ease;
    }
}

@keyframes pwa-content-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Larger touch targets */
@media (max-width: 768px) {
    a, button { min-height: 36px; }
}

/* Prevent text selection on nav taps */
.pwa-nav * { user-select: none; -webkit-user-select: none; }
