/* Mobile Bottom Navigation — NTB Dev */

:root {
    --mobile-nav-height: 64px;
    --mobile-nav-fab-size: 56px;
    --mobile-nav-bg: #1e3a8a;
    --mobile-nav-bg-dark: #0f172a;
    --mobile-nav-active: #60a5fa;
    --mobile-nav-text: rgba(255, 255, 255, 0.75);
    --mobile-nav-text-active: #ffffff;
    --mobile-sheet-z: 1050;
    --mobile-nav-z: 1040;
    --mobile-overlay-z: 1045;
}

/* Body offset for fixed bottom nav */
@media (max-width: 991.98px) {
    body.has-mobile-nav {
        padding-bottom: calc(var(--mobile-nav-height) + 12px);
    }

    body.has-mobile-nav.admin-app {
        padding-bottom: calc(var(--mobile-nav-height) + 12px);
    }

    body.has-mobile-nav .footer {
        padding-bottom: calc(var(--mobile-nav-height) + 2rem);
    }

    body.has-mobile-nav .app-container {
        padding-bottom: calc(var(--mobile-nav-height) + 16px) !important;
    }
}

/* Hide bottom nav on desktop */
.mobile-bottom-nav,
.mobile-layanan-sheet,
.mobile-sheet-overlay {
    display: none;
}

@media (max-width: 991.98px) {
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: var(--mobile-nav-height);
        background: linear-gradient(180deg, var(--mobile-nav-bg) 0%, var(--mobile-nav-bg-dark) 100%);
        box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.25);
        z-index: var(--mobile-nav-z);
        align-items: flex-end;
        justify-content: space-around;
        padding: 0 4px 6px;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
    }

    .mobile-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-end;
        gap: 2px;
        padding: 6px 4px 4px;
        min-height: 44px;
        min-width: 44px;
        color: var(--mobile-nav-text);
        text-decoration: none;
        background: none;
        border: none;
        cursor: pointer;
        transition: color 0.2s ease, transform 0.15s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-nav-item:hover,
    .mobile-nav-item:focus {
        color: var(--mobile-nav-text-active);
        text-decoration: none;
    }

    .mobile-nav-item.active,
    .mobile-nav-item.active .mobile-nav-icon {
        color: var(--mobile-nav-active);
        text-decoration: none;
    }

    .mobile-nav-item--cart.active .mobile-nav-label {
        color: var(--mobile-nav-active);
    }

    .mobile-nav-icon {
        font-size: 1.25rem;
        line-height: 1;
        position: relative;
    }

    .mobile-nav-label {
        font-size: 0.625rem;
        font-weight: 500;
        letter-spacing: 0.01em;
        line-height: 1.2;
        text-align: center;
    }

    .mobile-bottom-nav .mobile-nav-item:not(.mobile-nav-item--cart) {
        padding: 6px 2px 4px;
    }

    .mobile-bottom-nav .mobile-nav-label {
        font-size: 0.575rem;
    }

    /* Center FAB — Keranjang */
    .mobile-nav-item--cart {
        position: relative;
        flex: 0 0 auto;
        margin: 0 4px;
        padding-bottom: 0;
    }

    .mobile-nav-fab {
        display: flex;
        align-items: center;
        justify-content: center;
        width: var(--mobile-nav-fab-size);
        height: var(--mobile-nav-fab-size);
        border-radius: 50%;
        background: #ffffff;
        color: var(--mobile-nav-bg);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2), 0 0 0 4px rgba(255, 255, 255, 0.15);
        margin-top: -28px;
        position: relative;
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    .mobile-nav-item--cart:hover .mobile-nav-fab,
    .mobile-nav-item--cart.active .mobile-nav-fab {
        transform: scale(1.05);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25), 0 0 0 4px rgba(96, 165, 250, 0.3);
    }

    .mobile-nav-fab .mobile-nav-icon {
        font-size: 1.4rem;
        color: var(--mobile-nav-bg);
    }

    .mobile-nav-badge {
        position: absolute;
        top: -4px;
        right: -4px;
        min-width: 18px;
        height: 18px;
        padding: 0 5px;
        border-radius: 9px;
        background: #ef4444;
        color: #fff;
        font-size: 0.65rem;
        font-weight: 700;
        line-height: 18px;
        text-align: center;
        border: 2px solid #fff;
    }

    .mobile-nav-badge:empty,
    .mobile-nav-badge[data-count="0"] {
        display: none;
    }

    /* Layanan Sheet */
    .mobile-sheet-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.5);
        z-index: var(--mobile-overlay-z);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        backdrop-filter: blur(2px);
    }

    .mobile-sheet-overlay.is-open {
        opacity: 1;
        visibility: visible;
    }

    .mobile-layanan-sheet {
        display: flex;
        flex-direction: column;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 85vh;
        background: #ffffff;
        border-radius: 1.25rem 1.25rem 0 0;
        z-index: var(--mobile-sheet-z);
        transform: translateY(100%);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 -8px 40px rgba(15, 23, 42, 0.15);
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .mobile-layanan-sheet.is-open {
        transform: translateY(0);
    }

    .mobile-sheet-handle {
        width: 40px;
        height: 4px;
        background: #e2e8f0;
        border-radius: 2px;
        margin: 12px auto 8px;
        flex-shrink: 0;
    }

    .mobile-sheet-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 1.25rem 1rem;
        border-bottom: 1px solid #f1f5f9;
    }

    .mobile-sheet-title {
        font-size: 1.125rem;
        font-weight: 700;
        color: #1e293b;
        margin: 0;
    }

    .mobile-sheet-close {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        border: none;
        background: #f1f5f9;
        color: #64748b;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: background 0.2s ease;
    }

    .mobile-sheet-close:hover {
        background: #e2e8f0;
    }

    .mobile-sheet-body {
        overflow-y: auto;
        padding: 1rem 1.25rem 1.5rem;
        -webkit-overflow-scrolling: touch;
    }

    .mobile-sheet-group {
        margin-bottom: 1.25rem;
    }

    .mobile-sheet-group:last-child {
        margin-bottom: 0;
    }

    .mobile-sheet-group-title {
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: #94a3b8;
        margin-bottom: 0.75rem;
    }

    .mobile-sheet-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .mobile-sheet-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
        padding: 1rem 0.75rem;
        border-radius: 0.85rem;
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        color: #1e293b;
        text-decoration: none;
        transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
        min-height: 44px;
    }

    .mobile-sheet-item:hover,
    .mobile-sheet-item:focus {
        background: #eff6ff;
        border-color: #bfdbfe;
        color: #1e3a8a;
        text-decoration: none;
        transform: translateY(-2px);
    }

    .mobile-sheet-item-icon {
        width: 44px;
        height: 44px;
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.25rem;
        color: #fff;
    }

    .mobile-sheet-item-label {
        font-size: 0.8rem;
        font-weight: 600;
        text-align: center;
        line-height: 1.3;
    }

    /* Admin sheet list style */
    .mobile-sheet-list .mobile-sheet-item {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        padding: 0.85rem 1rem;
        gap: 0.75rem;
    }

    .mobile-sheet-list .mobile-sheet-item-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
        flex-shrink: 0;
        background: #1e3a8a !important;
    }

    .mobile-sheet-list .mobile-sheet-item-label {
        text-align: left;
        font-size: 0.875rem;
    }

    .mobile-sheet-list .mobile-sheet-item-icon .material-icons-two-tone {
        color: #fff;
        filter: brightness(0) invert(1);
    }

    /* Hide heavy navbar collapse on mobile — bottom nav handles nav */
    body.has-mobile-nav .navbar .navbar-collapse {
        display: none !important;
    }

    body.has-mobile-nav .navbar .navbar-toggler {
        display: none !important;
    }

    body.has-mobile-nav .navbar .d-flex {
        margin-left: auto;
    }

    body.has-mobile-nav .navbar .d-flex .btn {
        padding: 0.35rem 0.75rem;
        font-size: 0.8rem;
    }
}

/* Cart page mobile-first */
.cart-page {
    padding-top: 80px;
    padding-bottom: 1rem;
    min-height: 100vh;
}

.cart-item-card {
    border-radius: 0.85rem;
    border: 1px solid #e2e8f0;
    background: #fff;
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.cart-item-card .cart-item-name {
    font-weight: 600;
    color: #1e293b;
}

.cart-item-card .cart-item-price {
    color: #1e3a8a;
    font-weight: 700;
}

.cart-qty-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cart-qty-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    color: #1e3a8a;
}

.cart-checkout-bar {
    position: fixed;
    bottom: calc(var(--mobile-nav-height) + 8px);
    left: 0;
    right: 0;
    padding: 0.75rem 1rem;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
    z-index: 1035;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

@media (min-width: 992px) {
    .cart-checkout-bar {
        bottom: 0;
        max-width: 600px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 1rem 1rem 0 0;
    }

    .cart-page {
        max-width: 600px;
        margin: 0 auto;
    }
}

.cart-catalog-card {
    border-radius: 0.85rem;
    border: 1px solid #e2e8f0;
    padding: 1rem;
    margin-bottom: 0.75rem;
    transition: border-color 0.2s ease;
}

.cart-catalog-card:hover {
    border-color: #bfdbfe;
}

.cart-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #64748b;
}

.cart-empty i {
    font-size: 3rem;
    color: #cbd5e1;
    margin-bottom: 1rem;
}

/* Package picker sheet */
.package-picker-sheet {
    max-height: 85vh;
}

.package-picker-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.package-picker-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.85rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 0.85rem;
    background: #fff;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.package-picker-card:hover {
    border-color: #93c5fd;
}

.package-picker-card.is-selected {
    border-color: var(--mobile-nav-bg, #1e3a8a);
    background: #eff6ff;
}

.package-picker-card-label {
    font-weight: 600;
    color: #0f172a;
    font-size: 0.95rem;
}

.package-picker-card-price {
    font-weight: 700;
    color: var(--mobile-nav-bg, #1e3a8a);
    font-size: 0.9rem;
    margin-top: 0.15rem;
}

.package-picker-card-period {
    font-weight: 400;
    color: #64748b;
    font-size: 0.8rem;
}

.package-picker-card-check {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    border: 2px solid #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    flex-shrink: 0;
    margin-left: 0.75rem;
    font-size: 0.7rem;
}

.package-picker-card.is-selected .package-picker-card-check {
    background: var(--mobile-nav-bg, #1e3a8a);
    border-color: var(--mobile-nav-bg, #1e3a8a);
    color: #fff;
}

.mobile-sheet-badge {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0.1rem 0.4rem;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: #f59e0b;
    color: #fff;
    border-radius: 0.35rem;
    vertical-align: middle;
}

.cart-coming-soon-badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    background: #94a3b8;
    color: #fff;
    border-radius: 0.4rem;
}

.service-cart-toast {
    position: fixed;
    bottom: calc(var(--mobile-nav-height, 64px) + 1rem);
    left: 50%;
    transform: translateX(-50%) translateY(1rem);
    background: #0f172a;
    color: #fff;
    padding: 0.65rem 1.1rem;
    border-radius: 2rem;
    font-size: 0.875rem;
    z-index: 1060;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
    max-width: calc(100vw - 2rem);
    text-align: center;
}

.service-cart-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (min-width: 992px) {
    .service-cart-toast {
        bottom: 1.5rem;
    }

    #packagePickerOverlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.5);
        z-index: var(--mobile-sheet-z);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    #packagePickerOverlay.is-open {
        opacity: 1;
        visibility: visible;
    }

    .package-picker-sheet {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 50%;
        left: 50%;
        bottom: auto;
        right: auto;
        width: min(480px, calc(100vw - 2rem));
        max-height: 80vh;
        transform: translate(-50%, -50%) scale(0.95);
        opacity: 0;
        visibility: hidden;
        background: #fff;
        border-radius: 1rem;
        z-index: calc(var(--mobile-sheet-z) + 1);
        box-shadow: 0 20px 60px rgba(15, 23, 42, 0.2);
        transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
    }

    .package-picker-sheet.is-open {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
        visibility: visible;
    }

    .package-picker-sheet .mobile-sheet-handle {
        display: none;
    }

    /* Admin app — Material 3 bottom navigation */
    body.admin-app .mobile-bottom-nav {
        height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px));
        padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
        background: #ffffff;
        border-top: 1px solid rgba(0, 0, 0, 0.08);
        box-shadow: 0 -2px 12px rgba(15, 23, 42, 0.08);
    }

    body.admin-app .mobile-nav-item {
        color: #64748b;
        position: relative;
    }

    body.admin-app .mobile-nav-item.active {
        color: #1e3a8a;
    }

    body.admin-app .mobile-nav-item.active::before {
        content: '';
        position: absolute;
        top: 4px;
        left: 50%;
        transform: translateX(-50%);
        width: 56px;
        height: 32px;
        background: rgba(30, 58, 138, 0.12);
        border-radius: 16px;
        z-index: -1;
    }

    body.admin-app .mobile-nav-label {
        font-size: 0.7rem;
        font-weight: 500;
        letter-spacing: 0;
    }

    body.admin-app .mobile-nav-item.active .mobile-nav-icon {
        color: #1e3a8a;
    }

    body.admin-app .mobile-nav-fab {
        box-shadow: 0 4px 12px rgba(30, 58, 138, 0.25), 0 0 0 4px rgba(30, 58, 138, 0.08);
    }

    body.admin-app .mobile-nav-item:active {
        transform: scale(0.92);
    }

    /* Admin bottom sheet — Android list style */
    body.admin-app .mobile-sheet-overlay {
        background: rgba(15, 23, 42, 0.6);
        backdrop-filter: blur(4px);
    }

    body.admin-app .mobile-layanan-sheet {
        border-radius: 1.5rem 1.5rem 0 0;
        box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.2);
    }

    body.admin-app .mobile-sheet-handle {
        width: 32px;
        height: 5px;
        background: #cbd5e1;
        border-radius: 3px;
        margin: 10px auto 6px;
    }

    body.admin-app .mobile-sheet-list .mobile-sheet-item {
        border-radius: 0;
        background: transparent;
        border: none;
        border-bottom: 1px solid #f1f5f9;
        padding: 0.9rem 0.5rem;
        flex-direction: row;
        min-height: 52px;
    }

    body.admin-app .mobile-sheet-list .mobile-sheet-item:last-child {
        border-bottom: none;
    }

    body.admin-app .mobile-sheet-list .mobile-sheet-item:active {
        background: rgba(30, 58, 138, 0.06);
        transform: none;
    }

    body.admin-app .mobile-sheet-list .mobile-sheet-item-icon {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: #1e3a8a !important;
    }

    body.admin-app .mobile-sheet-list .mobile-sheet-item::after {
        content: '\f054';
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        font-size: 0.7rem;
        color: #94a3b8;
        margin-left: auto;
        flex-shrink: 0;
    }

    body.admin-app .mobile-sheet-group-title {
        color: #1e3a8a;
        font-size: 0.8125rem;
        font-weight: 700;
        text-transform: none;
        letter-spacing: 0;
        padding: 0.5rem 0.5rem 0.25rem;
        border-bottom: 1px solid #e2e8f0;
        margin-bottom: 0;
    }
}
