/* ===================================
   PANEL COMPONENT
   ===================================
   
   Non-collapsible section panel with consistent header + content structure.
   Uses ControlsBar molecule for filter/action layout.
   
   SPACING CONTRACT:
   - Panel owns internal padding (via .dashboard-section)
   - .section-content has NO padding (parent owns it)
   - .section-header has minimal vertical padding
   - Parent container owns gap between panels (no margin-bottom)
*/

/* Panel container - OWNS the internal padding */
.dashboard-section {
    background: var(--bg-surface);
    border: var(--border-width-1) solid var(--border-subtle);
    border-radius: var(--border-radius-xl);  /* 12px - matches Sidebar for consistency */
    overflow: hidden;
    padding: var(--space-3);  /* 12px - Panel owns internal spacing */
    margin: 0;  /* CONTRACT: Parent gap handles spacing between panels */
    
    /* Flex column for height inheritance - header fixed, content fills */
    display: flex;
    flex-direction: column;
    min-height: 0;  /* Allow shrinking in flex/grid contexts */
    box-sizing: border-box;
}

/* Panel header - flexbox layout with title left, controls right */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0 var(--space-2) 0;  /* Only bottom padding before border */
    margin-bottom: var(--space-3);  /* Gap to content */
    border-bottom: var(--border-width-1) solid var(--border-subtle);
    gap: var(--space-4);
    flex-wrap: wrap;
    flex-shrink: 0;  /* Header doesn't shrink */
}

.section-header:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Section title */
.section-title {
    font-size: var(--text-base);  /* 16px - professional, not oversized */
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

/* Section subtitle - inline with title, smaller and muted */
.section-subtitle {
    font-size: var(--text-sm);
    font-weight: var(--font-weight-normal);
    color: var(--text-muted);
}

/* Panel content - CONTRACT: NO padding, parent .dashboard-section owns it */
.section-content {
    padding: 0;
    flex: 1;  /* Fill remaining height */
    min-height: 0;  /* Allow shrinking for overflow scroll */
    overflow-y: auto;  /* Scroll when content exceeds available height */
}

/* Scrollable panel variant */
.scrollable-panel .section-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-surface);
}

.scrollable-panel .section-content {
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

/* ControlsBar integration - allow it to grow and take remaining space */
.section-header .controls-bar {
    flex: 1;
    justify-content: flex-end;
}

/* Grouped controls bars own their own layout -- don't override */
.section-header .controls-bar.controls-bar--groups {
    justify-content: space-between;
}

.section-header .controls-bar.controls-bar--groups-1 {
    justify-content: flex-start;
}

.section-header .controls-bar.controls-bar--groups-2 {
    justify-content: flex-start;
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-section {
        padding: var(--space-3);
    }
    
    .section-header {
        flex-direction: column;
        align-items: stretch;
        padding: 0 0 var(--space-1_5) 0;
    }
    
    .section-title {
        margin-bottom: var(--space-2);
    }
    
    /* ControlsBar handles its own responsive behavior */
    .section-header .controls-bar {
        justify-content: space-between;
    }
}
