/* /public/css/layout/sidebar-mobile.css */
/* Mobile nav components, member layout, mobile bottom nav bar.
   Also hides the desktop sidebar on mobile viewports. */

/* =========================================================
   HIDE DESKTOP SIDEBAR ON MOBILE
   ========================================================= */
@media (max-width: 991px) {
    .dashboard-sidebar { display: none; }

    .mobile-nav-link {
        padding: 12px 16px;
        font-size: 1rem;
        border-bottom: 1px solid #f1f5f9;
        display: flex;
        align-items: center;
        gap: 12px;
    }
}

/* =========================================================
   MOBILE MENU COMPONENTS (ACTION GRID & ACCORDION)
   ========================================================= */

/* --- A. ACTION GRID (Top Buttons) --- */
.mobile-action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 16px;
    background-color: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}

/*
   LAYOUT FIX: Prevent scrollbar jumping
   'scrollbar-gutter: stable' reserves space for the scrollbar
   even when content doesn't overflow, preventing horizontal layout shifts.
*/
.mobile-nav-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    padding-bottom: 30px;
    scrollbar-gutter: stable; /* FIX: Prevents layout shift */
}

.mobile-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 14px 10px; /* Taller touch target */
    border-radius: 12px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.2;
    transition: transform 0.1s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    text-align: center;
}

.mobile-action-btn i {
    font-size: 1.25rem;
    margin-bottom: 6px;
}

/* Primary Action (New Request) - Indigo */
.mobile-action-primary {
    background-color: var(--color-primary);
    color: #ffffff;
    border: 1px solid var(--color-primary);
}
.mobile-action-primary:hover {
    background-color: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
    color: #ffffff;
    text-decoration: none;
}
.mobile-action-primary:active {
    background-color: var(--color-primary-dark);
    transform: scale(0.96);
}

/* Secondary Action (Earn) - Dark Navy */
.mobile-action-secondary {
    background-color: #1e293b;
    color: #ffffff;
    border: 1px solid #1e293b;
}
.mobile-action-secondary i {
    color: #fbbf24;
}
.mobile-action-secondary:hover {
    background-color: #0f172a;
    border-color: #0f172a;
    color: #ffffff;
    text-decoration: none;
}
.mobile-action-secondary:hover i {
    color: #fbbf24;
}
.mobile-action-secondary:active {
    background-color: #0f172a;
    transform: scale(0.96);
}

/* --- A2. STANDALONE LINK (Mobile — prominent direct link) --- */
.mobile-nav-standalone {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #4338ca;
    text-decoration: none;
    border-bottom: 1px solid #f1f5f9;
    background-color: #ffffff;
    transition: background-color 0.15s ease;
}
.mobile-nav-standalone i {
    color: #6366f1;
    font-size: 0.95rem;
    width: 20px;
    text-align: center;
}
.mobile-nav-standalone:hover,
.mobile-nav-standalone:active {
    background-color: rgba(79, 70, 229, 0.06);
    text-decoration: none;
}
.mobile-nav-standalone.is-active {
    background-color: rgba(79, 70, 229, 0.08);
    border-left: 3px solid #6366f1;
}

/* --- B. SMOOTH ACCORDION (Checkbox Hack) ---
   Replaces the native <details> to allow CSS transition of grid-template-rows.
   This creates the smooth slide effect.
*/

/* Container */
.mobile-nav-accordion {
    border-bottom: 1px solid #f1f5f9;
    background-color: #ffffff;
    display: block;
}

/* Hidden Checkbox */
.mobile-nav-accordion-checkbox {
    display: none;
}

/* The Label (Acts as the Summary/Trigger) */
.mobile-nav-accordion-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    min-height: 48px;

    font-size: 0.75rem;
    font-weight: 800;
    color: var(--color-gray-500);
    text-transform: uppercase;
    letter-spacing: 0.08em;

    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease, color 0.2s ease, border-left 0.2s ease;
    background-color: #ffffff;
    border-left: 3px solid transparent;
}

/* Active State for Label — indigo accent when expanded */
.mobile-nav-accordion-checkbox:checked + .mobile-nav-accordion-label {
    background-color: var(--color-gray-50);
    color: var(--color-gray-700);
    border-left-color: var(--color-primary);
    padding-left: 17px; /* Compensate for 3px border */
}

/* Chevron Rotation */
.mobile-nav-accordion-label .accordion-icon {
    font-size: 0.8rem;
    color: #94a3b8;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-nav-accordion-checkbox:checked + .mobile-nav-accordion-label .accordion-icon {
    transform: rotate(180deg);
    color: var(--color-primary);
}

/*
   The Content Wrapper (Grid Transition)
   Animates height from 0 to auto seamlessly.
*/
.mobile-nav-accordion-content {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s ease-out; /* Smooth slide */
    background-color: #fcfcfc; /* Subtle off-white for nested feel */
}

.mobile-nav-accordion-checkbox:checked ~ .mobile-nav-accordion-content {
    grid-template-rows: 1fr;
    border-top: 1px solid #f1f5f9;
}

/* Inner Container for actual content (Overflow hidden required for grid trick) */
.mobile-nav-accordion-inner {
    overflow: hidden;
}

/* Staggered fade-in for accordion items */
.mobile-nav-accordion-checkbox:checked ~ .mobile-nav-accordion-content .mobile-nav-link {
    animation: mobileNavItemFadeIn 0.2s ease both;
}
.mobile-nav-accordion-checkbox:checked ~ .mobile-nav-accordion-content li:nth-child(1) .mobile-nav-link { animation-delay: 0.02s; }
.mobile-nav-accordion-checkbox:checked ~ .mobile-nav-accordion-content li:nth-child(2) .mobile-nav-link { animation-delay: 0.04s; }
.mobile-nav-accordion-checkbox:checked ~ .mobile-nav-accordion-content li:nth-child(3) .mobile-nav-link { animation-delay: 0.06s; }
.mobile-nav-accordion-checkbox:checked ~ .mobile-nav-accordion-content li:nth-child(4) .mobile-nav-link { animation-delay: 0.08s; }
.mobile-nav-accordion-checkbox:checked ~ .mobile-nav-accordion-content li:nth-child(5) .mobile-nav-link { animation-delay: 0.10s; }
.mobile-nav-accordion-checkbox:checked ~ .mobile-nav-accordion-content li:nth-child(6) .mobile-nav-link { animation-delay: 0.12s; }
.mobile-nav-accordion-checkbox:checked ~ .mobile-nav-accordion-content li:nth-child(7) .mobile-nav-link { animation-delay: 0.14s; }
.mobile-nav-accordion-checkbox:checked ~ .mobile-nav-accordion-content li:nth-child(8) .mobile-nav-link { animation-delay: 0.16s; }
.mobile-nav-accordion-checkbox:checked ~ .mobile-nav-accordion-content li:nth-child(9) .mobile-nav-link { animation-delay: 0.18s; }

@keyframes mobileNavItemFadeIn {
    from { opacity: 0; transform: translateX(8px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .mobile-nav-accordion-checkbox:checked ~ .mobile-nav-accordion-content .mobile-nav-link {
        animation: none;
    }
    .mobile-nav-panel {
        transition-duration: 0.01s;
    }
    .mobile-nav-overlay {
        transition-duration: 0.01s;
    }
}

/* =========================================================
   MEMBER AREA LAYOUT (Sidebar + Main Content)
   Used by ALL member pages via base_members.twig
   ========================================================= */
:root {
    --dash-bg: #f8f9fb;
}

/* Sidebar + Content side-by-side on desktop */
.member-app-layout {
    display: flex;
    min-height: 100vh;
}

.member-app-right {
    flex: 1;
    min-width: 0;
    overflow-x: clip; /* clip avoids breaking position:sticky on header */
}

.member-layout {
    display: flex;
    min-height: calc(100vh - var(--header-height, 56px));
    background-color: var(--dash-bg);
}

.member-main {
    flex: 1;
    padding: var(--space-8) var(--space-6) var(--space-8);
}

/* On mobile, the header switches to position:fixed (header.css ~line 766)
   which removes it from document flow. Add top padding so page content
   isn't hidden underneath the fixed header.
   Also: .member-main is a flex child (flex:1) whose default min-width:auto
   prevents it from shrinking below content's intrinsic width — causing
   horizontal overflow on pages with wide content. min-width:0 fixes this.
   Side padding reduced from 24px to 12px — pages add their own container
   padding, so the double-padding was eating 60px+ per side on 360px screens. */
@media (max-width: 991px) {
    .member-layout {
        min-height: 100vh;
    }
    .member-main {
        padding: calc(var(--header-height, 56px) + var(--space-2)) var(--space-3) var(--space-4);
        min-width: 0;
        overflow-x: hidden;
    }
}

/* =========================================================
   MOBILE BOTTOM NAVIGATION BAR
   Fixed 56px bar at bottom of screen — mobile only.
   Hidden on desktop (>767px).
   ========================================================= */
.mobile-bottom-nav {
    display: none; /* Hidden on desktop */
}

@media (max-width: 767px) {
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 56px;
        background: #ffffff;
        border-top: 1px solid #e2e8f0;
        z-index: 900;
        align-items: stretch;
    }

    .mobile-bottom-nav__item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        text-decoration: none;
        color: #94a3b8;
        font-size: 0.6rem;
        font-weight: 600;
        letter-spacing: 0.02em;
        background: none;
        border: none;
        cursor: pointer;
        padding: 0;
        transition: color 0.15s ease;
        -webkit-tap-highlight-color: transparent;
        min-width: 44px;
    }

    .mobile-bottom-nav__item i {
        font-size: 1.1rem;
        line-height: 1;
    }

    .mobile-bottom-nav__item:hover,
    .mobile-bottom-nav__item:active {
        color: #6366f1;
    }

    .mobile-bottom-nav__item--active {
        color: #6366f1;
    }

    .mobile-bottom-nav__item--active i {
        color: #6366f1;
    }

    /* Push page content above the bottom nav so nothing hides behind it */
    .member-main {
        padding-bottom: calc(56px + var(--space-4));
    }
}
