/* /public/css/layout/sidebar.css */

/* --- 1. Main Sidebar Container --- */
.dashboard-sidebar {
    width: 280px;
    background-color: #ffffff;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 1040;
    position: sticky;
    /* DYNAMIC POSITIONING: Header Height (72px) + Hellobar Offset */
    top: calc(72px + var(--header-offset, 0px));
    /* DYNAMIC HEIGHT: Viewport - Header - Hellobar Offset */
    height: calc(100vh - 72px - var(--header-offset, 0px));
    transition: all 0.2s ease-out;
}

/* --- 2. Primary Action Area (Action Center) --- */
.sidebar-primary-action {
    /* Top: 24px, Side: 16px, Bottom: 16px (Symmetrical border spacing) */
    padding: 24px 16px 16px;
    background-color: #ffffff;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    /* Reduced gap to bring buttons closer together */
    gap: 8px;
    border-bottom: 1px solid #e2e8f0;
}

.sidebar-create-btn {
    width: 100%;
    justify-content: center;
    font-weight: 700;
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.15);
    transition: all 0.2s ease;
    border-radius: 10px;
    font-size: 0.95rem;
    padding: 12px;
    height: auto;
}

.sidebar-create-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(79, 70, 229, 0.25);
    text-decoration: none;
}

.sidebar-create-btn i {
    margin-right: 8px;
    font-size: 0.9em;
}

/* "Earn" Button (Dark Dashboard Style) */
.sidebar-earn-btn {
    width: 100%;
    justify-content: center;
    font-weight: 700;
    background-color: #334155; 
    border: 1px solid #334155;
    color: #ffffff; 
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
    border-radius: 10px;
    font-size: 0.95rem;
    padding: 10px 12px;
    height: auto;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.sidebar-earn-btn:hover {
    background-color: #1e293b;
    border-color: #1e293b;
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.15), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
    text-decoration: none;
}

.sidebar-earn-btn i {
    margin-right: 8px;
    font-size: 1em;
    color: #fbbf24;
    transition: transform 0.2s ease;
}

.sidebar-earn-btn:hover i {
    transform: scale(1.1);
}

/* --- 3. Scrollable Area --- */
.sidebar-scroll-area {
    flex-grow: 1;
    overflow: visible;
    padding: 16px 16px 24px;
    display: flex;
    flex-direction: column;
    /* Gap handles the 16px rhythm */
    gap: 16px;
}

/* --- 4. Navigation Groups (Flyout Architecture) --- */
.sidebar-group {
    position: relative;
    margin-bottom: 0;
}

/* The Trigger (Group Header) */
.sidebar-group-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #64748b;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    user-select: none;
    background-color: transparent;
}

.sidebar-group-trigger:hover,
.sidebar-group:hover .sidebar-group-trigger {
    background-color: #f1f5f9;
    color: #0f172a;
}

/* Active Parent Group Styling (Universal Blue) */
.sidebar-group-trigger.is-active-group {
    background-color: #eff6ff; /* Blue-50 */
    color: #2563eb; /* Blue-600 */
}

.sidebar-group-trigger i {
    font-size: 0.8rem;
    color: #cbd5e1;
    transition: transform 0.2s ease;
}

.sidebar-group-trigger.is-active-group i {
    color: currentColor;
}

.sidebar-group:hover .sidebar-group-trigger i {
    color: #94a3b8;
    transform: rotate(-90deg);
}

.sidebar-group:hover .sidebar-group-trigger.is-active-group i {
    color: currentColor; 
}

/* --- THE FLYOUT POPOUT MENU --- */
.sidebar-popout {
    position: absolute;
    left: 100%;
    top: -10px;
    width: 280px; 
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
    /* UPDATED: Increased padding for breathing room */
    padding: 12px;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-10px) scale(0.98);
    transform-origin: left top;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1050;
    margin-left: 10px;
}

.sidebar-popout::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -15px;
    width: 20px;
}

.sidebar-group:hover .sidebar-popout {
    opacity: 1;
    visibility: visible;
    transform: translateX(0) scale(1);
}

/* --- NEW: Internal Section Headers (Inside Popout) --- */
.popout-section-header {
    font-size: 0.7rem; /* Improved Readability */
    text-transform: uppercase;
    color: #475569; /* Slate-600 for contrast */
    font-weight: 800;
    letter-spacing: 0.05em;
    
    /* Visual Block Style */
    background-color: #f8fafc; /* Slate-50 */
    border-bottom: 1px solid #e2e8f0;
    border-radius: 6px; /* Soft block corners */
    
    /* Spacing */
    padding: 8px 12px;
    /* UPDATED: Increased vertical margins for separation */
    margin-top: 12px; 
    margin-bottom: 8px; 
}

/* Remove top margin from the very first header to keep it flush */
.popout-section-header:first-child {
    margin-top: 0;
}

/* --- 5. Links (Inside Popout or Main) --- */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    /* UPDATED: Increased vertical padding */
    padding: 10px 12px;
    border-radius: 8px;
    color: #64748b;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.15s ease-out;
    border: 1px solid transparent; 
    line-height: 1.2;
    width: 100%;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    /* UPDATED: Add margin between items */
    margin-bottom: 2px;
}

.sidebar-link i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    color: #94a3b8;
    transition: color 0.15s ease;
    flex-shrink: 0;
}

.sidebar-link span { 
    padding-right: 4px; 
    overflow: visible; 
    text-overflow: clip; 
}

.sidebar-link:hover {
    background-color: #f8fafc;
    color: #0f172a;
    text-decoration: none;
}
.sidebar-link:hover i { color: #3b82f6; }

.sidebar-link.is-active {
    background-color: #eff6ff;
    color: #2563eb;
    font-weight: 600;
}
.sidebar-link.is-active i { color: #2563eb; }

.sidebar-link.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: transparent;
}

.sidebar-link[href="/pricing"] {
    color: var(--color-primary-dark);
    font-weight: 600;
}
.sidebar-link[href="/pricing"] i { color: var(--color-primary-dark); }
.sidebar-link[href="/pricing"]:hover { background-color: #f0f1ff; }

/* Red Danger Link (Logout) */
.sidebar-link.text-danger,
.mobile-nav-link.text-danger {
    color: #ef4444; /* Red-500 */
}

.sidebar-link.text-danger i,
.mobile-nav-link.text-danger i {
    color: #ef4444;
}

.sidebar-link.text-danger:hover,
.mobile-nav-link.text-danger:hover {
    background-color: #fef2f2; /* Red-50 */
    color: #dc2626; /* Red-600 */
}

.sidebar-link.text-danger:hover i,
.mobile-nav-link.text-danger:hover i {
    color: #dc2626;
}

/* --- 6. Badges --- */
.sidebar-badge {
    margin-left: auto; 
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.65rem; 
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1;
    padding: 0 6px;
    height: 18px;
    border-radius: 4px;
    min-width: 0;
}

.sidebar-badge--new { background-color: #dbeafe; color: #1e40af; }
.sidebar-badge--hot { background-color: #fee2e2; color: #991b1b; }
.sidebar-badge--soon { background-color: #f1f5f9; color: #94a3b8; border: 1px solid #e2e8f0; }

/* --- 7. Sticky Footer --- */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid #e2e8f0;
    background-color: #ffffff;
    flex-shrink: 0;
    margin-top: auto;
}

.sidebar-plan-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    border-radius: 14px;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.sidebar-plan-card:hover {
    transform: translateY(-2px);
    text-decoration: none;
}

.sidebar-plan-card--free-compact {
    background-color: #ffffff;
    border: 1px solid var(--color-primary-dark);
    box-shadow: 0 4px 12px rgba(67, 56, 202, 0.15);
    padding: 12px 14px;
    gap: 0;
}

.sidebar-plan-card--free-compact:hover {
    box-shadow: 0 8px 20px rgba(67, 56, 202, 0.25);
    border-color: #3730a3;
}

.plan-card-compact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.plan-name-compact {
    font-size: 0.75rem; 
    font-weight: 800;
    color: #1e293b;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.plan-upgrade-pill {
    background-color: #e0e7ff;
    color: var(--color-primary-dark);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 4px 8px;
    border-radius: 6px;
    letter-spacing: 0.05em;
}

.plan-usage-row { margin-bottom: 6px; }

.plan-usage-text {
    font-size: 0.75rem; 
    color: #64748b;
    font-weight: 600;
    display: block;
}

.plan-usage-meter-compact { width: 100%; }

.plan-usage-meter-compact .meter-track {
    background-color: #f1f5f9;
    height: 6px;
    border-radius: 99px;
    overflow: hidden;
}

.meter-fill { height: 100%; transition: width 0.3s ease; border-radius: 99px; }
.meter-fill.is-safe { background-color: #10b981; }
.meter-fill.is-warning { background-color: #fbbf24; }
.meter-fill.is-danger { background-color: #ef4444; }

.sidebar-plan-card--paid-zen {
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 12px 16px;
    align-items: center;
    justify-content: center;
}
.sidebar-plan-card--paid-zen:hover { border-color: #cbd5e1; background-color: #f1f5f9; }
.sidebar-plan-card--paid-zen .plan-info-name { font-size: 0.8rem; font-weight: 700; color: #334155; }
.sidebar-plan-card--paid-zen .plan-info-status { font-size: 0.7rem; color: #16a34a; font-weight: 600; margin-left: auto; display: flex; gap: 4px; align-items: center; }

/* --- 8. Sidebar Divider (Visual Separation - Full Bleed) --- */
.sidebar-group-divider {
    height: 1px;
    background-color: #f1f5f9;
    /* 
       Margin Logic: 
       Top: 0 (Gap handles 16px)
       Bottom: 8px (Combines with gap for 24px)
       Side: -16px (Bleed)
    */
    margin: 0 -16px 8px -16px;
}

/* --- Mobile Nav Styles --- */
.mobile-nav-sub-header {
    font-size: 0.7rem;
    font-weight: 800;
    color: #cbd5e1; /* Even lighter for sub-headers */
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 20px 20px 8px; /* Extra top spacing */
    border-top: 1px solid #f8fafc;
    margin-top: 4px;
}

/* Remove border/margin from first sub-header in a group */
.mobile-group-title + .mobile-nav-sub-header {
    border-top: none;
    padding-top: 8px;
    margin-top: 0;
}

@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);
}


/* --- 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: #f8fafc; /* Soft-gray canvas for member area */
}

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

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