.agents-container-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden; /* Prevent any overflow */
    position: relative;
}

.agents-top-section {
    display: flex;
    flex: 1;
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: relative;
}

/* =====================================================================
   AGENT LIST PANEL - COLLAPSIBLE
   ===================================================================== */
.agents-list-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary, #1a1a2e);
    z-index: 100;
    transition: transform 0.3s ease, opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* When collapsed - slide off left */
.agents-list-panel.collapsed {
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
}

/* Agent list header */
.agents-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color, #374151);
    flex-shrink: 0;
}

.agents-title {
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.agent-count {
    font-size: 14px;
    color: var(--text-muted, #9ca3af);
    font-weight: normal;
}

/* Agent list content - scrollable grid */
.agents-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    align-content: start;
}

/* Agent cards in the list */
.agent-block {
    background: var(--bg-secondary, #16213e);
    border: 1px solid var(--border-color, #374151);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.agent-block:hover {
    border-color: var(--accent, #3b82f6);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.agent-block.selected {
    border-color: var(--accent, #3b82f6);
    background: rgba(59, 130, 246, 0.1);
}

/* =====================================================================
   AGENT DETAILS PANEL - TAKES FULL WIDTH WHEN LIST COLLAPSED
   ===================================================================== */
.agent-details-three-column {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary, #1a1a2e);
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    overflow: hidden; /* CRITICAL: Prevent overflow */
}

/* When agent list is collapsed, show details */
.agents-top-section.agent-selected .agent-details-three-column {
    opacity: 1;
    pointer-events: auto;
}

/* Details header */
.agent-details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border-color, #374151);
    flex-shrink: 0;
    background: var(--bg-secondary, #16213e);
}

.agent-details-title {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Status header */
.agent-status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 24px;
    background: var(--bg-tertiary, #0f172a);
    border-bottom: 1px solid var(--border-color, #374151);
    flex-shrink: 0;
    font-size: 13px;
}

/* Details content area - MUST NOT OVERFLOW */
#agentDetailsContent {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%; /* Enforce max width */
}

/* =====================================================================
   EXPAND/COLLAPSE TOGGLE BUTTON
   ===================================================================== */
.btn-show-agents {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 200;
    width: 32px;
    height: 80px;
    background: var(--accent, #3b82f6);
    border: none;
    border-radius: 0 8px 8px 0;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, background 0.2s ease;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.3);
}

.btn-show-agents:hover {
    background: var(--accent-hover, #60a5fa);
}

/* Show button when agent list is collapsed */
.agents-top-section.agent-selected .btn-show-agents {
    opacity: 1;
    pointer-events: auto;
}

/* Hide button inside agent list header (for going back) */
.btn-back-to-list {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-secondary, #16213e);
    border: 1px solid var(--border-color, #374151);
    border-radius: 6px;
    color: var(--text, #e5e7eb);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
}

.btn-back-to-list:hover {
    background: var(--bg-tertiary, #0f172a);
    border-color: var(--accent, #3b82f6);
}

/* =====================================================================
   SUB-TAB LAYOUT - FIXED WIDTH
   ===================================================================== */
.agents-detail-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    max-width: 100%; /* Prevent overflow */
    overflow: hidden;
}

#agentsSubTabBar {
    display: flex;
    gap: 4px;
    padding: 8px 24px;
    background: var(--bg-secondary, #16213e);
    border-bottom: 1px solid var(--border-color, #374151);
    flex-shrink: 0;
}

#agentsSubTabBar .sub-tab-button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-muted, #9ca3af);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
}

#agentsSubTabBar .sub-tab-button:hover {
    background: var(--bg-primary, #1a1a2e);
    color: var(--text, #e5e7eb);
}

#agentsSubTabBar .sub-tab-button.active {
    background: var(--bg-primary, #1a1a2e);
    border-color: var(--accent, #3b82f6);
    color: var(--text, #e5e7eb);
}

.sub-tab-content-area {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
}

.sub-tab-panel {
    display: none;
    height: 100%;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.sub-tab-panel.active {
    display: flex;
    flex-direction: column;
}

/* =====================================================================
   THREE-COLUMN LAYOUT - FIXED TO 100% WIDTH
   ===================================================================== */
.three-column-container {
    display: flex;
    height: 100%;
    width: 100%;
    max-width: 100%; /* CRITICAL */
    overflow: hidden; /* CRITICAL */
}

.column {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    min-width: 0; /* Allow flex items to shrink below content size */
}

.column-left {
    flex: 0 0 280px;
    min-width: 200px;
    max-width: 400px;
    border-right: 1px solid var(--border-color, #374151);
}

.column-center {
    flex: 1 1 auto;
    min-width: 300px;
    overflow: hidden;
}

.column-right {
    flex: 0 0 320px;
    min-width: 250px;
    max-width: 450px;
    border-left: 1px solid var(--border-color, #374151);
}

/* Panel inside columns */
.column .panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.column .panel-header {
    flex-shrink: 0;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color, #374151);
    background: var(--bg-secondary, #16213e);
}

/* Scrollable content areas */
.code-viewer-container,
.program-display,
.intent-details-content {
    flex: 1;
    overflow: auto;
    min-height: 0; /* Allow shrinking */
}

/* =====================================================================
   RESIZE HANDLES
   ===================================================================== */
.resize-handle {
    width: 4px;
    background: var(--border-color, #374151);
    cursor: col-resize;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.resize-handle:hover {
    background: var(--accent, #3b82f6);
}

/* =====================================================================
   OBSERVATORY PANEL - FULL WIDTH
   ===================================================================== */
.sub-tab-panel[data-subtab-panel="observatory"] {
    width: 100%;
    max-width: 100%;
}

.observatory-container {
    width: 100%;
    max-width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* =====================================================================
   RESPONSIVE ADJUSTMENTS
   ===================================================================== */
@media (max-width: 1200px) {
    .column-left {
        flex: 0 0 220px;
    }
    
    .column-right {
        flex: 0 0 280px;
    }
}

@media (max-width: 900px) {
    .three-column-container {
        flex-direction: column;
    }
    
    .column-left,
    .column-center,
    .column-right {
        flex: none;
        width: 100%;
        max-width: 100%;
        height: auto;
        min-height: 200px;
        border-right: none;
        border-left: none;
        border-bottom: 1px solid var(--border-color, #374151);
    }
    
    .resize-handle {
        display: none;
    }
}