/* ============================================================
 * bottom-nav.css — Bottom Navigation Bar
 * InspectorPRO NR-13 — Cerrado Mechanic Engenharia
 * 
 * Premium mobile bottom tab bar with:
 *   - Dark navy glassmorphism background
 *   - Cyan (var(--brand-accent, #00d4ff)) active states with glow
 *   - Raised center FAB button for "Nova Inspeção"
 *   - Safe area insets for iPhone notch/home indicator
 *   - Only visible on screens ≤ 768px
 *
 * z-index: 100 (below modals/toasts, above page content)
 * ============================================================ */

/* ============================================================
 *  1. BOTTOM NAV CONTAINER
 * ============================================================ */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;

    /* Glassmorphism dark background */
    background: rgba(10, 15, 28, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);

    /* Subtle top border */
    border-top: 1px solid rgba(255, 255, 255, 0.06);

    /* Layout: 5 items evenly distributed */
    display: none; /* Hidden by default, shown via media query */
    align-items: flex-end;
    justify-content: space-around;

    /* Height: 64px content + safe area for iPhone home indicator */
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);

    /* Performance: GPU layer for smooth blur */
    will-change: transform;
    transform: translateZ(0);

    /* Shadow for depth separation */
    box-shadow:
        0 -4px 24px rgba(0, 0, 0, 0.4),
        0 -1px 8px rgba(0, 0, 0, 0.2);

    /* Entrance animation */
    animation: bottomNavSlideUp 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Entrance animation keyframes */
@keyframes bottomNavSlideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}


/* ============================================================
 *  2. NAVIGATION ITEMS (each tab)
 * ============================================================ */

.bottom-nav__item {
    /* Reset button styles */
    appearance: none;
    -webkit-appearance: none;
    background: none;
    border: none;
    outline: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;

    /* Layout: icon + label vertically stacked */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;

    /* Sizing */
    flex: 1;
    height: 64px;
    min-width: 0;
    padding: 6px 0 8px;

    /* Default inactive color */
    color: #64748b;

    /* Smooth transitions */
    transition: color 0.2s ease, transform 0.2s ease;

    /* Prevent text selection */
    user-select: none;
    -webkit-user-select: none;

    /* Relative for the active indicator */
    position: relative;
}

/* Icon */
.bottom-nav__icon {
    font-size: 1.2rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    transition: transform 0.2s ease;
}

/* Label */
.bottom-nav__label {
    font-size: 0.7rem;   /* [R824] 0.65rem = 10.4px no celular — abaixo do legivel */
    font-weight: 500;
    font-family: 'Inter', 'Outfit', -apple-system, sans-serif;
    letter-spacing: 0.02em;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 64px;
    text-align: center;
    transition: color 0.2s ease;
}


/* ============================================================
 *  3. ACTIVE STATE
 * ============================================================ */

.bottom-nav__item.is-active {
    color: var(--brand-accent, #00d4ff);
}

/* Active icon glow */
.bottom-nav__item.is-active .bottom-nav__icon {
    transform: scale(1.1);
    filter: drop-shadow(0 0 6px rgba(var(--brand-accent-rgb, 0, 212, 255), 0.5));
}

/* Active label */
.bottom-nav__item.is-active .bottom-nav__label {
    color: var(--brand-accent, #00d4ff);
    font-weight: 600;
}

/* Active indicator dot below the label */
.bottom-nav__item.is-active::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--brand-accent, #00d4ff);
    box-shadow: 0 0 8px rgba(var(--brand-accent-rgb, 0, 212, 255), 0.6);
    animation: bottomNavDotPulse 2s ease-in-out infinite;
}

@keyframes bottomNavDotPulse {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 8px rgba(var(--brand-accent-rgb, 0, 212, 255), 0.6);
    }
    50% {
        opacity: 0.6;
        box-shadow: 0 0 4px rgba(var(--brand-accent-rgb, 0, 212, 255), 0.3);
    }
}


/* ============================================================
 *  4. HOVER & PRESS STATES
 * ============================================================ */

/* Hover (non-touch devices) */
@media (hover: hover) {
    .bottom-nav__item:not(.is-active):hover {
        color: #94a3b8;
    }

    .bottom-nav__item:not(.is-active):hover .bottom-nav__icon {
        transform: scale(1.05);
    }
}

/* Press / Active touch state */
.bottom-nav__item:active {
    transform: scale(0.92);
}

/* Ripple effect container */
.bottom-nav__item::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 12px;
    background: radial-gradient(circle, rgba(var(--brand-accent-rgb, 0, 212, 255), 0.12) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.bottom-nav__item:active::before {
    opacity: 1;
}


/* ============================================================
 *  5. CENTER FAB BUTTON (Nova Inspeção — raised action)
 * ============================================================ */

.bottom-nav__item--fab {
    /* Override default sizing */
    position: relative;
}

/* The raised circular container for the icon */
.bottom-nav__item--fab .bottom-nav__icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;

    /* Cyan gradient background */
    background: linear-gradient(135deg, var(--brand-accent, #00d4ff) 0%, #0099cc 100%);

    /* Lift above the bar */
    margin-top: -20px;

    /* Icon styling inside the circle */
    font-size: 1.4rem;
    color: #fff;

    /* Shadow for depth/elevation */
    box-shadow:
        0 4px 16px rgba(var(--brand-accent-rgb, 0, 212, 255), 0.4),
        0 2px 8px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);

    /* Smooth transitions */
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    filter: none; /* Override active icon glow filter */
}

/* FAB hover */
@media (hover: hover) {
    .bottom-nav__item--fab:hover .bottom-nav__icon {
        transform: scale(1.1);
        box-shadow:
            0 6px 24px rgba(var(--brand-accent-rgb, 0, 212, 255), 0.5),
            0 4px 12px rgba(0, 0, 0, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
    }
}

/* FAB press */
.bottom-nav__item--fab:active .bottom-nav__icon {
    transform: scale(0.95);
    box-shadow:
        0 2px 8px rgba(var(--brand-accent-rgb, 0, 212, 255), 0.3),
        0 1px 4px rgba(0, 0, 0, 0.2);
}

/* FAB label is always white/cyan regardless of active state */
.bottom-nav__item--fab .bottom-nav__label {
    color: var(--brand-accent, #00d4ff);
    font-weight: 600;
    margin-top: 2px;
}

/* FAB active state — brighter glow ring */
.bottom-nav__item--fab.is-active .bottom-nav__icon {
    box-shadow:
        0 0 0 3px rgba(var(--brand-accent-rgb, 0, 212, 255), 0.25),
        0 6px 24px rgba(var(--brand-accent-rgb, 0, 212, 255), 0.5),
        0 4px 12px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    filter: none; /* No drop-shadow on FAB, it has its own glow */
}

/* No active dot on FAB — the ring glow is enough */
.bottom-nav__item--fab.is-active::after {
    display: none;
}


/* ============================================================
 *  6. MAIN CONTENT BOTTOM PADDING
 *     Prevents content from hiding behind the fixed bottom nav.
 * ============================================================ */

.has-bottom-nav main,
.has-bottom-nav .main-content,
.has-bottom-nav #main-content {
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
}


/* ============================================================
 *  7. MEDIA QUERY — Only show on mobile (≤ 768px)
 * ============================================================ */

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

/* Hide on desktop/tablet landscape */
@media (min-width: 769px) {
    .bottom-nav {
        display: none !important;
    }

    /* Remove bottom padding compensation on desktop */
    .has-bottom-nav main,
    .has-bottom-nav .main-content,
    .has-bottom-nav #main-content {
        padding-bottom: 0 !important;
    }
}


/* ============================================================
 *  8. LANDSCAPE PHONE ADJUSTMENTS
 *     Reduce height in landscape to save vertical space.
 * ============================================================ */

@media (max-width: 768px) and (orientation: landscape) and (max-height: 500px) {
    .bottom-nav {
        height: calc(48px + env(safe-area-inset-bottom, 0px));
    }

    .bottom-nav__item {
        height: 48px;
        padding: 4px 0 4px;
    }

    .bottom-nav__label {
        font-size: 0.7rem;   /* [R824] idem — telas estreitas nao podem ser AINDA menores */
    }

    .bottom-nav__item--fab .bottom-nav__icon {
        width: 40px;
        height: 40px;
        margin-top: -14px;
        font-size: 1.2rem;
    }

    /* Less bottom padding in landscape */
    .has-bottom-nav main,
    .has-bottom-nav .main-content,
    .has-bottom-nav #main-content {
        padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important;
    }
}


/* ============================================================
 *  9. REDUCED MOTION (Accessibility)
 * ============================================================ */

@media (prefers-reduced-motion: reduce) {
    .bottom-nav {
        animation: none;
    }

    .bottom-nav__item,
    .bottom-nav__icon,
    .bottom-nav__label {
        transition: none;
    }

    .bottom-nav__item.is-active::after {
        animation: none;
    }
}


/* ============================================================
 *  10. DARK MODE FORCED (for browsers that override)
 * ============================================================ */

@media (prefers-color-scheme: dark) {
    .bottom-nav {
        background: rgba(10, 15, 28, 0.97);
    }
}

/* ============================================================
 *  11. [FIX BADGE-OVERLAP] Badge de sync/modo acima do bottom-nav (mobile)
 *  O #sync-status-container fica em bottom:16px e cobria a barra de
 *  navegação inferior (64px). Quando o bottom-nav está ativo, sobe o badge.
 * ============================================================ */
.has-bottom-nav #sync-status-container {
    bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
}
