/* ═══════════════════════════════════════════════════════════
   SIWARGA — Mobile Navigation CSS
   Bottom Nav + Sidebar Mobile + Swipe Support
   Target: <992px (Bootstrap lg breakpoint)
═══════════════════════════════════════════════════════════ */

/* ── Safe area untuk iPhone notch / Home Indicator ── */
:root {
    --bn-height: 64px;
    --bn-safe:   env(safe-area-inset-bottom, 0px);
    --bn-total:  calc(var(--bn-height) + var(--bn-safe));
    --bn-bg:     #ffffff;
    --bn-active: #6366f1;
    --bn-muted:  #9ca3af;
    --bn-border: rgba(0,0,0,0.08);
    --sidebar-w: 280px;
    --anim-fast: 0.18s;
    --anim-std:  0.28s;
}

/* ══════════════════════════════════════════
   BOTTOM NAVIGATION BAR
══════════════════════════════════════════ */

/* Spacer agar konten tidak tertutup bottom nav */
@media (max-width: 991.98px) {
    body { padding-bottom: var(--bn-total) !important; }
    .main-footer { margin-bottom: var(--bn-total) !important; }
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1045;
    background: var(--bn-bg);
    border-top: 1px solid var(--bn-border);
    padding-bottom: var(--bn-safe);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.09);
    /* Smooth rounded top */
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    /* Hardware-accelerated */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
}

/* Row item container */
.bn-items {
    display: flex;
    align-items: stretch;
    height: var(--bn-height);
    padding: 0 4px;
}

/* ── Individual nav item ── */
.bn-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--bn-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px 2px;
    position: relative;
    transition: color var(--anim-fast) ease;
    -webkit-tap-highlight-color: transparent;
    border-radius: 14px;
    margin: 6px 2px;
}

/* Touch feedback */
.bn-item:active {
    background: rgba(99, 102, 241, 0.08);
    transform: scale(0.94);
    transition: transform 0.1s ease, background 0.1s ease;
}

/* ── Icon wrapper (for indicator dot) ── */
.bn-icon-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.bn-icon-wrap i {
    font-size: 1.2rem;
    transition: transform var(--anim-fast) ease;
}

/* ── Label ── */
.bn-label {
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    font-family: 'Outfit', sans-serif;
    transition: color var(--anim-fast) ease;
}

/* ── Active state ── */
.bn-item.bn-active {
    color: var(--bn-active);
}
.bn-item.bn-active .bn-icon-wrap i {
    transform: translateY(-1px) scale(1.1);
}
.bn-item.bn-active .bn-label {
    font-weight: 700;
    color: var(--bn-active);
}

/* Active pill indicator (background pill) */
.bn-item.bn-active .bn-icon-wrap::before {
    content: '';
    position: absolute;
    inset: -4px -10px;
    background: rgba(99, 102, 241, 0.12);
    border-radius: 10px;
    z-index: -1;
}

/* Dot indicator bawah icon */
.bn-indicator {
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--bn-active);
}

/* ── Tombol More ── */
.bn-more {
    color: var(--bn-muted);
}
.bn-more:active {
    background: rgba(99, 102, 241, 0.08);
}

/* ══════════════════════════════════════════
   SIDEBAR MOBILE OVERRIDES
══════════════════════════════════════════ */

@media (max-width: 991.98px) {

    /* Sidebar: slide dari kiri (offcanvas style) */
    .sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        height: 100dvh; /* dynamic viewport height */
        width: var(--sidebar-w) !important;
        z-index: 1055;
        transform: translateX(-110%) !important;
        transition: transform var(--anim-std) cubic-bezier(0.4, 0, 0.2, 1) !important;
        border-radius: 0 20px 20px 0;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    /* Sidebar terbuka */
    .sidebar.active {
        transform: translateX(0) !important;
        box-shadow: 4px 0 40px rgba(0, 0, 0, 0.25) !important;
    }

    /* Overlay backdrop */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 1050;
        background: rgba(0, 0, 0, 0);
        backdrop-filter: blur(0px);
        transition:
            background var(--anim-std) ease,
            backdrop-filter var(--anim-std) ease;
        cursor: pointer;
    }
    .sidebar-overlay.active {
        display: block;
        background: rgba(0, 0, 0, 0.45);
        backdrop-filter: blur(2px);
    }

    /* Main content tidak bergeser di mobile */
    .main-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* Header mobile: lebih compact */
    .header {
        padding: 10px 16px !important;
        min-height: 56px;
    }

    /* Card: kurangi padding di mobile */
    .card {
        padding: 1rem !important;
        border-radius: 14px !important;
        margin-bottom: 0.85rem !important;
    }

    /* Table: hide columns less important on small screen */
    .d-none-xs { display: none !important; }

    /* Tombol: tinggi minimum 44px (Apple HIG) */
    .btn {
        min-height: 40px;
        font-size: 0.875rem;
    }
    .btn-sm { min-height: 34px; }

    /* Form inputs: tinggi minimum touch-friendly */
    .form-control, .form-select {
        min-height: 44px;
        font-size: 16px !important; /* Cegah auto-zoom iOS */
        border-radius: 10px !important;
    }

    /* Badge: sedikit lebih besar di mobile */
    .badge { font-size: 0.75rem; }

    /* Datatable: scroll horizontal smooth */
    .dataTables_wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* Page title di header: truncate jika panjang */
    .page-title {
        font-size: 1rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 60vw;
    }

    /* FAB menu: pastikan di atas bottom nav */
    .fab-container .dropdown-menu {
        bottom: calc(var(--bn-total) + 8px) !important;
        right: 12px !important;
    }
    .fab-container .fab-btn {
        bottom: calc(var(--bn-total) + 8px) !important;
        right: 12px !important;
    }

    /* Toast: di atas bottom nav */
    .toast-container {
        bottom: calc(var(--bn-total) + 8px) !important;
    }

    /* Offline banner: di atas bottom nav */
    #offlineBanner {
        bottom: calc(var(--bn-total) + 8px) !important;
    }
}

/* ══════════════════════════════════════════
   SWIPE GESTURE SUPPORT (JS akan handle)
══════════════════════════════════════════ */

/* Hint visual untuk swipe area (kiri 20px) */
@media (max-width: 991.98px) {
    .swipe-hint {
        position: fixed;
        top: 40%;
        left: 0;
        width: 4px;
        height: 60px;
        background: rgba(99,102,241,0.3);
        border-radius: 0 4px 4px 0;
        z-index: 1000;
        opacity: 0;
        transition: opacity 0.3s;
        pointer-events: none;
    }
}

/* ══════════════════════════════════════════
   SCROLL SMOOTH — sidebar
══════════════════════════════════════════ */
.sidebar-content {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Nav item di sidebar: lebih besar di mobile agar mudah dipencet */
@media (max-width: 991.98px) {
    .sidebar .nav-link {
        padding: 10px 16px !important;
        min-height: 44px;
        border-radius: 10px;
        margin: 1px 8px;
    }
    .sidebar .nav-header {
        padding: 14px 16px 4px !important;
        font-size: 0.65rem;
    }
    /* Close button sidebar: lebih besar */
    #sidebar-close-btn {
        width: 36px;
        height: 36px;
        display: flex !important;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: rgba(255,255,255,0.12);
    }
}

/* ══════════════════════════════════════════
   MICRO ANIMATIONS
══════════════════════════════════════════ */

/* Bounce ringan saat icon dipilih */
@keyframes bn-pop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.2) translateY(-2px); }
    100% { transform: scale(1.1) translateY(-1px); }
}
.bn-item.bn-active .bn-icon-wrap i {
    animation: bn-pop 0.25s ease forwards;
}

/* Sidebar slide-in */
@keyframes sidebar-in {
    from { transform: translateX(-100%); opacity: 0.8; }
    to   { transform: translateX(0);    opacity: 1; }
}