/* ===== Drawer/Sidebar Styles ===== */

/* Icon placeholders - make them transparent to layout */
#drawer .icon-placeholder {
    display: contents;
}

/* App Layout - Horizontal flex container */
#app-layout {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

/* Main content area takes remaining space */
#main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    background: var(--neutral-900, #000009);
}

/* ----- Drawer Base Styles ----- */
#drawer {
    width: 240px;
    min-width: 240px;
    max-width: 360px;
    height: 100%;
    background: var(--bg-surface, #0A0A0A);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease, min-width 0.25s ease, transform 0.25s ease;
    z-index: var(--z-drawer, 90);
    /* Fixed position to overlay workflow instead of pushing it */
    position: fixed;
    left: 0;
    top: 0;
    overflow: hidden;
}

/* Collapsed State - Icon Strip Mode */
#drawer.collapsed {
    width: 45px;
    min-width: 45px;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
}

#drawer.collapsed .drawer-header,
#drawer.collapsed .drawer-search,
#drawer.collapsed .drawer-content {
    display: none;
}

/* Expand button - only visible when collapsed */
.drawer-expand-btn {
    display: none;
    width: 100%;
    padding: 10px 6px;
    background: var(--bg-elevated, #151515);
    border: none;
    border-bottom: 1px solid var(--border-subtle, #252525);
    color: var(--text-muted, #6A6A6A);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.drawer-expand-btn:hover {
    background: var(--neutral-700, #252525);
    color: var(--text-primary, #FAFAFA);
}

.drawer-expand-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

#drawer.collapsed .drawer-expand-btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hide expand button when drawer is open */
#drawer:not(.collapsed) .drawer-expand-btn {
    display: none;
}

/* Footer in collapsed mode - vertical stack of icons */
#drawer.collapsed .drawer-footer {
    flex: 1;
    justify-content: flex-end;
    padding: 5px;
    gap: 3px;
}

#drawer.collapsed .drawer-footer-buttons {
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

#drawer.collapsed .drawer-footer-btn {
    width: 32px;
    min-width: 32px;
    height: 32px;
    padding: 6px;
    justify-content: center;
    border-radius: 6px;
}

#drawer.collapsed .drawer-footer-btn svg {
    width: 22px !important;
    height: 22px !important;
}

/* Hide labels in collapsed mode */
#drawer.collapsed .drawer-footer-btn .btn-label {
    display: none;
}

/* ----- Drawer Header ----- */
.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 13px;
    background: var(--bg-elevated, #151515);
    border-bottom: 1px solid var(--border-subtle, #252525);
    flex-shrink: 0;
}

.drawer-title {
    color: var(--text-primary, #FAFAFA);
    font-size: var(--font-size-body-md);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.drawer-toggle-btn {
    background: none;
    border: none;
    color: var(--text-muted, #6A6A6A);
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.drawer-toggle-btn:hover {
    background: var(--neutral-700, #252525);
    color: var(--text-primary, #FAFAFA);
}

.drawer-chevron {
    width: 21px;
    height: 21px;
    fill: currentColor;
    transition: transform 0.25s ease;
}

#drawer.collapsed .drawer-chevron {
    transform: rotate(180deg);
}

/* ----- Drawer Search ----- */
.drawer-search {
    padding: 10px 13px;
    border-bottom: 1px solid var(--border-subtle, #252525);
    flex-shrink: 0;
}

#drawer-search-input {
    width: 100%;
    padding: 11px 13px;
    background: var(--bg-primary, #000000);
    border: 1px solid var(--border-subtle, #252525);
    border-radius: 6px;
    color: var(--text-primary, #FAFAFA);
    font-size: var(--font-size-body-md);
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s ease;
}

#drawer-search-input:focus {
    border-color: var(--accent-main, #3B82F6);
}

#drawer-search-input::placeholder {
    color: var(--text-muted, #6A6A6A);
}

/* ----- Drawer Content ----- */
.drawer-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 0;
    background: var(--bg-surface, #0A0A0A);
}

.drawer-content::-webkit-scrollbar {
    width: 6px;
}

.drawer-content::-webkit-scrollbar-track {
    background: transparent;
}

.drawer-content::-webkit-scrollbar-thumb {
    background: var(--neutral-600, #3A3A3A);
    border-radius: 3px;
}

.drawer-content::-webkit-scrollbar-thumb:hover {
    background: var(--neutral-500, #6A6A6A);
}

/* ----- Section Header Styles ----- */
.drawer-section {
    margin-bottom: 4px;
}

.section-header {
    padding: 7px 10px;
    color: var(--text-muted, #6A6A6A);
    font-size: var(--font-size-body-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-bottom: 1px solid var(--border-subtle, #252525);
    margin-bottom: 3px;
}

/* ----- Category Styles ----- */
.drawer-category {
    margin-bottom: 2px;
}

.category-header {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}

.category-header:hover {
    background: var(--neutral-800, #1A1A1A);
}

.category-chevron {
    color: var(--text-muted, #6A6A6A);
    font-size: var(--font-size-body-sm);
    margin-right: 6px;
    transition: transform 0.2s ease;
    display: inline-block;
}

.drawer-category.expanded .category-chevron {
    transform: rotate(90deg);
}

.category-title {
    color: var(--text-secondary, #9A9A9A);
    font-size: var(--font-size-body-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.category-items {
    display: none;
    padding-left: 10px;
}

.drawer-category.expanded .category-items {
    display: block;
}

/* ----- Subcategory Styles ----- */
.drawer-subcategory {
    margin: 2px 0;
}

.subcategory-header {
    display: flex;
    align-items: center;
    padding: 5px 8px;
    cursor: pointer;
    user-select: none;
    border-radius: 4px;
    margin: 0 5px;
    transition: background 0.15s ease;
}

.subcategory-header:hover {
    background: var(--neutral-800, #1A1A1A);
}

.subcategory-chevron {
    width: 3px;
    height: 3px;
    margin-right: 6px;
    border-right: 2px solid var(--text-muted, #6A6A6A);
    border-bottom: 2px solid var(--text-muted, #6A6A6A);
    transform: rotate(-45deg);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.drawer-subcategory.expanded > .subcategory-header > .subcategory-chevron {
    transform: rotate(45deg);
}

.subcategory-title {
    color: var(--text-primary, #FAFAFA);
    font-size: var(--font-size-body-sm);
    font-weight: 500;
}

.subcategory-items {
    display: none;
    padding-left: 8px;
}

.drawer-subcategory.expanded > .subcategory-items {
    display: block;
}

/* ----- Node Button Styles ----- */
.drawer-node-btn {
    display: flex;
    align-items: center;
    width: calc(100% - 10px);
    margin: 1px 5px;
    padding: 5px 8px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-secondary, #9A9A9A);
    font-size: var(--font-size-body-sm);
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.drawer-node-btn:hover {
    background: var(--neutral-800, #1A1A1A);
    color: var(--text-primary, #FAFAFA);
}

.drawer-node-btn:active {
    transform: scale(0.98);
}

/* ----- Drawer Footer ----- */
.drawer-footer {
    padding: 4px 6px;
    border-top: 1px solid var(--border-subtle, #252525);
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
    background: var(--bg-surface, #0A0A0A);
}

/* Footer buttons row - horizontal layout */
.drawer-footer-buttons {
    display: flex;
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px 16px;
}

/* Connection status in drawer footer - aligned with buttons */
.drawer-status {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 7px;
    font-size: var(--font-size-body-md);
    color: var(--text-muted, #6A6A6A);
    border-top: 1px solid var(--border-subtle, #252525);
    margin-top: 3px;
}

.drawer-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--destructive-500, #EF4444);
    flex-shrink: 0;
    margin-left: 3px;
    margin-right: 3px;
}

.drawer-status.connected .status-dot {
    background: var(--success-500, #22C55E);
    box-shadow: 0 0 6px var(--success-500, #22C55E);
}

.drawer-status .status-text {
    flex: 1;
}

/* Status becomes icon-only in collapsed mode */
#drawer.collapsed .drawer-status {
    padding: 4px;
    justify-content: center;
    border-top: none;
    margin-top: 0;
}

#drawer.collapsed .drawer-status .status-text {
    display: none;
}

#drawer.collapsed .drawer-status .status-dot {
    width: 9px;
    height: 9px;
}

.drawer-footer-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 31px;
    height: auto;
    padding: 4px 6px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted, #6A6A6A);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

/* Text labels under icons */
.drawer-footer-btn .btn-label {
    font-size: var(--font-size-ui-sm);
    font-weight: 500;
    text-align: center;
}

.drawer-footer-btn:hover {
    background: var(--neutral-800, #1A1A1A);
    color: var(--text-primary, #FAFAFA);
}

.drawer-footer-btn svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

/* Apply fill to footer buttons except Flow button */
.drawer-footer-btn:not(#sg-btn) svg path {
    fill: currentColor;
}

/* Flow button SVG - preserve original colors and ensure full icon visible */
#sg-btn .flow-icon {
    width: 13px;
    height: 13px;
}

/* Drawer footer button overrides - higher specificity */
#drawer .drawer-footer-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 38px;
    height: auto;
    padding: 5px 7px;
    background: transparent;
    border: none;
    border-radius: 5px;
    color: var(--text-muted, #6A6A6A);
}

#drawer .drawer-footer-btn svg {
    width: 22px;
    height: 22px;
}

/* ----- Animation for items appearing ----- */
@keyframes drawerItemSlideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Apply to newly visible items */
.drawer-category.expanded .drawer-node-btn {
    animation: drawerItemSlideIn 0.2s ease forwards;
}
