/**
 * Bottom Navigation Bar & Mobile Slide Drawers
 * Theme: Pengadilan Negeri Red (pn-red)
 * Style: Ultra-modern Liquid Glass / Soft Water Effect
 * Primary Accent: #9a2109
 */

/* ==========================================================================
   1. DESKTOP RESET (Hidden on Desktop screens >= 1000px)
   ========================================================================== */
@media (min-width: 1000px) {
    .cr-bottom-nav-wrap,
    .cr-bottom-nav-overlay,
    .cr-bottom-sheet-drawer {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }
}

/* ==========================================================================
   2. MOBILE / RESPONSIVE STYLES (Max Width: 999px)
   ========================================================================== */
@media (max-width: 999px) {

    /* Hide standard top header menu bar on mobile since bottom nav takes over */
    #cr-menu-wrap,
    #cr-menu-wrap-sticky-wrapper,
    .cr-header-menu-wrapper,
    .cr-header-menu-block-wrap {
        display: none !important;
    }

    /* Provide comfortable bottom breathing room for body content so nothing is cut off */
    body {
        padding-bottom: 78px !important;
    }

    /* --------------------------------------------------------------------------
       Backdrop Overlay for Drawers
       -------------------------------------------------------------------------- */
    .cr-bottom-nav-overlay {
        position: fixed;
        inset: 0;
        z-index: 10000000;
        background: rgba(15, 23, 42, 0.55);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        pointer-events: none;
        will-change: opacity;
    }

    .cr-bottom-nav-overlay.active {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    /* --------------------------------------------------------------------------
       The Liquid Glass Floating Bottom Navigation Bar (Always on Top)
       -------------------------------------------------------------------------- */
    .cr-bottom-nav-wrap {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 68px;
        z-index: 10000002;
        display: flex;
        align-items: center;
        justify-content: space-around;
        padding: 0 16px env(safe-area-inset-bottom, 0px) 16px;
        
        /* High-Performance Smooth Liquid Glass Effect */
        background: rgba(255, 255, 255, 0.94);
        backdrop-filter: blur(10px) saturate(160%);
        -webkit-backdrop-filter: blur(10px) saturate(160%);
        
        border-top: 1px solid rgba(255, 255, 255, 0.95);
        box-shadow: 0 -6px 20px rgba(154, 33, 9, 0.1), 0 -2px 6px rgba(0, 0, 0, 0.04);
        
        border-top-left-radius: 24px;
        border-top-right-radius: 24px;
        box-sizing: border-box;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
        
        /* GPU Hardware Acceleration for zero-lag scroll */
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
        will-change: transform;
        contain: layout style;
        transition: transform 0.25s ease;
    }

    /* Water wave reflection subtle highlight on top edge */
    .cr-bottom-nav-wrap::before {
        content: '';
        position: absolute;
        top: 0;
        left: 10%;
        right: 10%;
        height: 1.5px;
        background: linear-gradient(90deg, transparent 0%, rgba(154, 33, 9, 0.3) 25%, rgba(217, 119, 6, 0.4) 50%, rgba(154, 33, 9, 0.3) 75%, transparent 100%);
        border-radius: 100%;
        pointer-events: none;
    }

    /* Inner Nav Buttons Container */
    .cr-bottom-nav-items {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        max-width: 480px;
        margin: 0 auto;
        height: 100%;
        position: relative;
    }

    /* --------------------------------------------------------------------------
       Dynamic Floating Active Circle Bubble & Notch (Smooth Sliding)
       -------------------------------------------------------------------------- */
    .cr-nav-active-bubble-wrapper {
        position: absolute;
        top: -24px;
        left: 0;
        width: 33.333333%;
        height: 62px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        pointer-events: none;
        z-index: 10;
        /* Smooth physics spring-like transition */
        transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
        transform: translate3d(100%, 0, 0); /* Default center index: 1 */
        will-change: transform;
    }

    /* Notch Pressed Bar Effect behind the floating active bubble */
    .cr-nav-active-notch {
        position: absolute;
        top: 24px;
        width: 68px;
        height: 32px;
        background: rgba(255, 255, 255, 0.95);
        border-radius: 0 0 34px 34px;
        box-shadow: 0 4px 10px -2px rgba(154, 33, 9, 0.18), inset 0 2px 4px rgba(154, 33, 9, 0.05);
        border: 1px solid rgba(154, 33, 9, 0.08);
        border-top: none;
        pointer-events: none;
        transition: transform 0.3s ease;
    }

    /* Floating Elevated Active Circle Bubble */
    .cr-nav-active-bubble {
        position: relative;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: linear-gradient(145deg, #b9290f 0%, #9a2109 55%, #701402 100%);
        border: 3.5px solid #ffffff;
        box-shadow: 
            0 8px 18px -3px rgba(154, 33, 9, 0.42),
            0 3px 8px rgba(0, 0, 0, 0.1),
            inset 0 2px 4px rgba(255, 255, 255, 0.35);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        pointer-events: auto;
        transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .cr-nav-active-bubble:active {
        transform: scale(0.92);
    }

    /* Pulsing Water Aura Ring */
    .cr-nav-active-bubble::after {
        content: '';
        position: absolute;
        inset: -4px;
        border-radius: 50%;
        border: 1.5px solid rgba(154, 33, 9, 0.18);
        animation: crWaterPulse 2.6s infinite ease-out;
        pointer-events: none;
    }

    @keyframes crWaterPulse {
        0% { transform: scale(0.94); opacity: 0.7; }
        70% { transform: scale(1.18); opacity: 0; }
        100% { transform: scale(1.2); opacity: 0; }
    }

    .cr-nav-bubble-content {
        display: flex;
        align-items: center;
        justify-content: center;
        color: #ffffff;
        font-size: 20px;
        transition: transform 0.25s ease, opacity 0.2s ease;
    }

    .cr-nav-bubble-content img,
    .cr-bubble-logo-img {
        width: 32px;
        height: 32px;
        object-fit: contain;
        border-radius: 50%;
        filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
        pointer-events: none;
    }

    .cr-nav-bubble-content i,
    .cr-nav-bubble-content .fa {
        color: #ffffff !important;
        font-size: 20px !important;
        line-height: 1 !important;
    }

    /* --------------------------------------------------------------------------
       Nav Button Items (Unified & Interactive)
       -------------------------------------------------------------------------- */
    button.cr-bottom-nav-btn,
    .cr-bottom-nav-btn {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        height: 100% !important;
        background: transparent !important;
        border: none !important;
        outline: none !important;
        color: #1e293b !important;
        cursor: pointer !important;
        padding: 4px 8px !important;
        margin: 0 !important;
        position: relative !important;
        text-decoration: none !important;
        box-shadow: none !important;
        text-shadow: none !important;
        line-height: normal !important;
        transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
        -webkit-tap-highlight-color: transparent !important;
        z-index: 5;
    }

    button.cr-bottom-nav-btn:active,
    .cr-bottom-nav-btn:active {
        transform: scale(0.92) !important;
        background: transparent !important;
    }

    .cr-bottom-nav-btn .cr-btn-icon-box {
        position: relative !important;
        width: 38px !important;
        height: 26px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 17px !important;
        color: #64748b !important;
        background: transparent !important;
        border-radius: 8px !important;
        transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    }

    .cr-bottom-nav-btn .cr-btn-icon-box i,
    .cr-bottom-nav-btn .cr-btn-icon-box .fa {
        color: #64748b !important;
        font-size: 17px !important;
        line-height: 1 !important;
        transition: color 0.25s ease !important;
    }

    .cr-bottom-nav-btn .cr-btn-icon-box img,
    .cr-bottom-nav-btn .cr-center-logo-img {
        width: 24px !important;
        height: 24px !important;
        object-fit: contain !important;
        border-radius: 50% !important;
        opacity: 0.75 !important;
        transition: all 0.25s ease !important;
    }

    .cr-bottom-nav-btn .cr-btn-label {
        font-size: 11px !important;
        font-weight: 700 !important;
        letter-spacing: 0.2px !important;
        margin-top: 2px !important;
        line-height: 1.1 !important;
        color: #475569 !important;
        transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    }

    /* When a tab is ACTIVE (elevated by the sliding bubble) */
    .cr-bottom-nav-btn.active .cr-btn-icon-box {
        opacity: 0 !important;
        transform: translateY(-16px) scale(0.5) !important;
        pointer-events: none !important;
    }

    .cr-bottom-nav-btn.active .cr-btn-label {
        color: #9a2109 !important;
        font-weight: 800 !important;
        transform: translateY(12px) !important;
    }

    /* --------------------------------------------------------------------------
       Water Ripple Animation Effect on Click
       -------------------------------------------------------------------------- */
    .cr-ripple-effect {
        position: absolute;
        border-radius: 50%;
        background: radial-gradient(circle, rgba(154, 33, 9, 0.25) 0%, rgba(255, 255, 255, 0) 70%);
        transform: scale(0);
        animation: crRippleAnim 0.6s linear;
        pointer-events: none;
    }

    @keyframes crRippleAnim {
        to {
            transform: scale(3.5);
            opacity: 0;
        }
    }

    /* --------------------------------------------------------------------------
       Slide Drawers / Bottom Sheets (Common Foundation)
       -------------------------------------------------------------------------- */
    .cr-bottom-sheet-drawer {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 47px !important;
        width: 100%;
        max-height: calc(85vh - 47px);
        z-index: 10000001;
        
        background: #ffffff;
        border-top-left-radius: 26px;
        border-top-right-radius: 26px;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        
        box-shadow: 0 -15px 45px rgba(15, 23, 42, 0.22);
        
        display: flex;
        flex-direction: column;
        
        transform: translate3d(0, 105%, 0);
        -webkit-transform: translate3d(0, 105%, 0);
        opacity: 0;
        visibility: hidden;
        transition: transform 0.32s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.22s ease, visibility 0.32s;
        box-sizing: border-box;
        overflow: hidden;
        will-change: transform, opacity;
        contain: paint layout;
    }

    .cr-bottom-sheet-drawer.active {
        transform: translate3d(0, 0, 0) !important;
        -webkit-transform: translate3d(0, 0, 0) !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    /* Horizontal Slide-In & Slide-Out Directional Animations (GPU Accelerated) */
    .cr-bottom-sheet-drawer.cr-slide-from-right {
        transform: translate3d(100%, 0, 0) !important;
        -webkit-transform: translate3d(100%, 0, 0) !important;
        opacity: 0.7 !important;
        visibility: visible !important;
    }

    .cr-bottom-sheet-drawer.cr-slide-from-left {
        transform: translate3d(-100%, 0, 0) !important;
        -webkit-transform: translate3d(-100%, 0, 0) !important;
        opacity: 0.7 !important;
        visibility: visible !important;
    }

    .cr-bottom-sheet-drawer.cr-slide-out-left {
        transform: translate3d(-100%, 0, 0) !important;
        -webkit-transform: translate3d(-100%, 0, 0) !important;
        opacity: 0 !important;
        visibility: hidden !important;
        transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.2s ease, visibility 0.28s !important;
    }

    .cr-bottom-sheet-drawer.cr-slide-out-right {
        transform: translate3d(100%, 0, 0) !important;
        -webkit-transform: translate3d(100%, 0, 0) !important;
        opacity: 0 !important;
        visibility: hidden !important;
        transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.2s ease, visibility 0.28s !important;
    }

    /* Drawer Top Handle Pill & Header */
    .cr-drawer-handle-bar {
        width: 44px;
        height: 5px;
        background: #cbd5e1;
        border-radius: 10px;
        margin: 12px auto 6px auto;
        flex-shrink: 0;
    }

    .cr-drawer-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 22px 14px 22px;
        border-bottom: 1px solid #f1f5f9;
        flex-shrink: 0;
        background: #ffffff;
    }

    .cr-drawer-header-left {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .cr-drawer-header-icon {
        width: 36px;
        height: 36px;
        border-radius: 10px;
        background: linear-gradient(135deg, rgba(154, 33, 9, 0.1) 0%, rgba(217, 119, 6, 0.1) 100%);
        color: #9a2109;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 16px;
    }

    .cr-drawer-title {
        margin: 0;
        font-size: 17px;
        font-weight: 700;
        color: #0f172a;
        line-height: 1.2;
    }

    .cr-drawer-subtitle {
        margin: 2px 0 0 0;
        font-size: 12px;
        color: #64748b;
        line-height: 1;
    }

    button.cr-drawer-close-btn,
    .cr-drawer-close-btn {
        width: 34px !important;
        height: 34px !important;
        border-radius: 50% !important;
        background: #f1f5f9 !important;
        border: none !important;
        color: #475569 !important;
        padding: 0 !important;
        font-size: 15px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
        outline: none !important;
        box-shadow: none !important;
    }

    .cr-drawer-close-btn:hover,
    .cr-drawer-close-btn:active {
        background: #e2e8f0 !important;
        color: #0f172a !important;
        transform: rotate(90deg);
    }

    .cr-drawer-body {
        padding: 18px 20px 32px 20px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        flex: 1;
    }

    /* --------------------------------------------------------------------------
       DRAWER 1: Custom Action Sheet (Grid / Cards)
       -------------------------------------------------------------------------- */
    .cr-custom-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 14px 12px;
    }

    @media (max-width: 380px) {
        .cr-custom-grid {
            grid-template-columns: repeat(3, 1fr);
            gap: 10px 8px;
        }
    }

    .cr-custom-card {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 14px 8px 12px 8px;
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        border-radius: 16px;
        text-decoration: none;
        color: #1e293b;
        position: relative;
        transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
        -webkit-tap-highlight-color: transparent;
    }

    .cr-custom-card:active {
        transform: scale(0.94);
        background: #fff;
        border-color: #9a2109;
        box-shadow: 0 6px 16px rgba(154, 33, 9, 0.14);
    }

    .cr-custom-card-icon {
        width: 46px;
        height: 46px;
        border-radius: 14px;
        background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%);
        border: 1px solid #e2e8f0;
        color: #9a2109;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 20px;
        margin-bottom: 8px;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
        transition: all 0.25s ease;
    }

    .cr-custom-card:hover .cr-custom-card-icon,
    .cr-custom-card:active .cr-custom-card-icon {
        background: linear-gradient(135deg, #9a2109 0%, #771706 100%);
        color: #ffffff;
        border-color: #9a2109;
        box-shadow: 0 6px 14px rgba(154, 33, 9, 0.3);
    }

    .cr-custom-card-title {
        font-size: 12px;
        font-weight: 700;
        color: #1e293b;
        line-height: 1.25;
        max-width: 100%;
        word-break: break-word;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .cr-custom-card-desc {
        font-size: 10px;
        color: #64748b;
        line-height: 1.25;
        margin-top: 3px;
        font-weight: 500;
        max-width: 100%;
        word-break: break-word;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        transition: color 0.2s ease;
    }

    .cr-custom-card:hover .cr-custom-card-desc,
    .cr-custom-card:active .cr-custom-card-desc {
        color: #9a2109;
    }

    /* --------------------------------------------------------------------------
       DRAWER 2: Main Menu Navigation (Hierarchical Accordion)
       -------------------------------------------------------------------------- */
    .cr-mainmenu-sheet-body {
        padding: 12px 16px 28px 16px;
    }

    .cr-sheet-menu-list {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .cr-sheet-menu-list > li {
        border-bottom: 1px solid #f1f5f9;
        margin: 0;
        padding: 0;
    }

    .cr-sheet-menu-list > li:last-child {
        border-bottom: none;
    }

    .cr-sheet-menu-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 48px;
    }

    .cr-sheet-menu-link {
        flex: 1;
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 6px;
        font-size: 14.5px;
        font-weight: 600;
        color: #1e293b;
        text-decoration: none;
        transition: color 0.2s ease;
    }

    .cr-sheet-menu-link:hover,
    .cr-sheet-menu-link:active {
        color: #9a2109;
    }

    .cr-sheet-menu-icon {
        width: 28px;
        height: 28px;
        border-radius: 8px;
        background: #f8fafc;
        color: #64748b;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
        flex-shrink: 0;
    }

    button.cr-sheet-submenu-toggle,
    .cr-sheet-submenu-toggle {
        width: 38px !important;
        height: 38px !important;
        border: none !important;
        background: #f8fafc !important;
        color: #64748b !important;
        border-radius: 10px !important;
        font-size: 13px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        outline: none !important;
        padding: 0 !important;
        box-shadow: none !important;
        flex-shrink: 0 !important;
        margin-left: 8px !important;
        transition: transform 0.25s ease, background 0.2s ease, color 0.2s ease !important;
    }

    .cr-sheet-submenu-toggle:hover,
    .cr-sheet-submenu-toggle:active {
        background: #fee2e2 !important;
        color: #9a2109 !important;
    }

    .cr-sheet-submenu-toggle.expanded {
        transform: rotate(180deg) !important;
        background: #9a2109 !important;
        color: #ffffff !important;
    }

    /* Submenu Accordion Levels */
    ul.cr-sheet-sub-menu,
    .cr-sheet-sub-menu {
        display: none;
        list-style: none !important;
        margin: 4px 0 8px 12px !important;
        padding: 6px 0 8px 16px !important;
        border-left: 2.5px solid #fecaca !important;
        background: #fcfcfc !important;
        border-radius: 0 0 12px 12px !important;
    }

    .cr-sheet-sub-menu.open {
        display: block;
        animation: crSubFade 0.25s ease;
    }

    @keyframes crSubFade {
        from { opacity: 0; transform: translateY(-4px); }
        to { opacity: 1; transform: translateY(0); }
    }

    .cr-sheet-sub-menu li {
        list-style: none !important;
        margin: 0 !important;
        padding: 0 !important;
        border-bottom: 1px dashed #f1f5f9 !important;
    }

    .cr-sheet-sub-menu li:last-child {
        border-bottom: none !important;
    }

    .cr-sheet-sub-menu a {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        padding: 10px 10px !important;
        font-size: 13.5px !important;
        font-weight: 600 !important;
        color: #475569 !important;
        text-decoration: none !important;
        border-radius: 8px !important;
        transition: all 0.2s ease !important;
    }

    .cr-sheet-sub-menu a:hover,
    .cr-sheet-sub-menu a:active {
        background: #fef2f2 !important;
        color: #9a2109 !important;
        padding-left: 14px !important;
    }

    .cr-sheet-sub-menu .cr-sub-icon {
        width: 22px !important;
        height: 22px !important;
        border-radius: 6px !important;
        background: rgba(154, 33, 9, 0.08) !important;
        color: #9a2109 !important;
        font-size: 11px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* --------------------------------------------------------------------------
       DRAWER 3: Modern Search Sheet
       -------------------------------------------------------------------------- */
    .cr-search-sheet-body {
        padding: 16px 20px 32px 20px;
    }

    .cr-search-box-form {
        display: flex;
        align-items: center;
        background: #f8fafc;
        border: 2px solid #e2e8f0;
        border-radius: 16px;
        padding: 6px 8px 6px 16px;
        transition: border-color 0.25s ease, box-shadow 0.25s ease;
    }

    .cr-search-box-form:focus-within {
        border-color: #9a2109;
        background: #ffffff;
        box-shadow: 0 0 0 4px rgba(154, 33, 9, 0.12);
    }

    .cr-search-box-input {
        flex: 1;
        border: none;
        background: transparent;
        font-size: 15px;
        color: #0f172a;
        outline: none;
        padding: 8px 0;
    }

    .cr-search-box-input::placeholder {
        color: #94a3b8;
    }

    .cr-search-box-submit {
        width: 44px;
        height: 44px;
        border-radius: 12px;
        background: linear-gradient(135deg, #9a2109 0%, #771706 100%);
        border: none;
        color: #ffffff;
        font-size: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        outline: none;
        transition: transform 0.2s ease, opacity 0.2s ease;
        flex-shrink: 0;
    }

    .cr-search-box-submit:active {
        transform: scale(0.92);
    }

    .cr-search-quick-tags {
        margin-top: 18px;
    }

    .cr-quick-tag-label {
        font-size: 12px;
        font-weight: 600;
        color: #64748b;
        margin-bottom: 8px;
        display: block;
    }

    .cr-tag-chips {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .cr-tag-chip {
        display: inline-block;
        padding: 6px 12px;
        background: #f1f5f9;
        border-radius: 20px;
        font-size: 12px;
        color: #334155;
        text-decoration: none;
        transition: all 0.2s ease;
    }

    .cr-tag-chip:hover,
    .cr-tag-chip:active {
        background: #9a2109;
        color: #ffffff;
    }
}
