/* Right Sidebar (Interface Manager) */
.right-sidebar-header {
    padding: var(--md-sys-spacing-4);
    background-color: var(--md-sys-color-surface-variant);
    border-bottom: 1px solid var(--md-sys-color-outline);
    display: flex;
    flex-direction: column;
    gap: var(--md-sys-spacing-3);
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.icons-row {
    justify-content: flex-start;
    gap: var(--md-sys-spacing-3);
    padding-top: var(--md-sys-spacing-1);
    position: relative;
    overflow: visible;
}

.header-title {
    font-size: var(--md-sys-typescale-title-small);
    font-weight: 700;
    text-transform: uppercase;
    color: var(--md-sys-color-on-surface-strong);
    letter-spacing: 0.8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
}

.badge {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    font-size: var(--md-sys-typescale-body-small);
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: var(--md-sys-spacing-3);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Modern Search Wrapper Styles */
.search-wrapper {
    display: flex;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--md-sys-shape-corner-medium);
    padding: 6px 10px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    gap: 8px;
}

.search-wrapper:focus-within {
    border-color: rgba(25, 127, 230, 0.6);
    background-color: rgba(255, 255, 255, 0.07);
    box-shadow: 0 0 8px rgba(25, 127, 230, 0.25);
}

.search-wrapper .search-icon {
    font-size: 16px;
    color: var(--md-sys-color-on-surface-variant);
    user-select: none;
}

.search-wrapper .search-input {
    background: transparent;
    border: none;
    color: var(--md-sys-color-on-surface);
    font-family: inherit;
    font-size: var(--md-sys-typescale-body-large);
    width: 100%;
    outline: none;
    padding: 0;
}

.search-wrapper .clear-icon {
    font-size: 16px;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    user-select: none;
    transition: color 0.2s ease;
}

.search-wrapper .clear-icon:hover {
    color: var(--md-sys-color-on-surface-strong);
}

/* Mappings list container & items styling */
#tab-interfaces {
    overflow: hidden !important;
    height: calc(100vh - 40px);
    display: none;
    flex-direction: column;
}

#tab-interfaces.active {
    display: flex;
}

#interface-mappings-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 12px;
    flex: 0 1 auto;
    max-height: 220px;
    overflow-y: auto;
    border-bottom: 1px solid var(--md-sys-color-outline);
}

.mapping-item {
    padding: 6px 10px;
    background-color: var(--md-sys-color-surface-variant);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-medium);
    cursor: pointer;
    font-size: var(--md-sys-typescale-body-medium);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--md-sys-color-on-surface);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.mapping-item.active {
    background-color: var(--md-sys-color-surface-active);
    color: var(--md-sys-color-on-surface-strong);
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 0 0 1px var(--md-sys-color-primary);
}

.mapping-item.active.fluid-mapping {
    border-color: var(--md-sys-color-tertiary);
    box-shadow: 0 0 0 1px var(--md-sys-color-tertiary);
}

.mapping-item:hover:not(.active) {
    background-color: var(--md-sys-color-surface-hover);
    border-color: var(--md-sys-color-outline-variant);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Mapping badges */
.mapping-badge {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
}

.mapping-badge.fluid {
    background-color: rgba(255, 107, 0, 0.12);
    color: var(--md-sys-color-tertiary);
    border: 1px solid rgba(255, 107, 0, 0.25);
}

.mapping-badge.static {
    background-color: rgba(0, 240, 255, 0.12);
    color: var(--md-sys-color-primary);
    border: 1px solid rgba(0, 240, 255, 0.25);
}

/* Mapping item action icons */
.mapping-actions {
    display: flex;
    gap: 2px;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    transform: translateX(5px);
}

.mapping-item:hover .mapping-actions,
.mapping-item.active .mapping-actions {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

.mapping-actions span {
    font-size: 14px;
    padding: 2px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--md-sys-color-on-surface-variant);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.mapping-actions span:hover {
    background-color: var(--md-sys-color-surface-hover);
    color: var(--md-sys-color-on-surface-strong);
}

.mapping-actions span.delete-mapping:hover {
    color: var(--md-sys-color-error);
    background-color: rgba(244, 71, 71, 0.15);
}

#interface-tree-view {
    flex: 1 1 0%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 150px;
}

.tree-content {
    flex: 1 1 0%;
    overflow-y: auto;
    padding: 0 12px 12px 12px;
}

/* Robust Right Sidebar Toggle Styles (Restored from old ide.css) */
#right-sidebar.collapsed {
    width: 30px !important;
}

#right-sidebar.collapsed .right-sidebar-header {
    padding: 10px 0 !important;
}

#right-sidebar.collapsed .right-sidebar-header .header-row:first-child,
#right-sidebar.collapsed .right-sidebar-header .search-container,
#right-sidebar.collapsed #interface-mappings-list,
#right-sidebar.collapsed #interface-tree-view {
    display: none !important;
}

.icons-row {
    justify-content: flex-start;
    gap: var(--md-sys-spacing-3);
    padding-top: var(--md-sys-spacing-1);
    position: relative;
    overflow: visible;
}

#right-sidebar.collapsed .sidebar-btn {
    background: transparent !important;
    border: none !important;
    width: 100% !important;
    opacity: 0.6;
    height: 40px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

#right-sidebar.collapsed .sidebar-btn:hover {
    opacity: 1;
}

#right-sidebar.collapsed #add-interface-btn {
    font-size: 24px;
}

#right-sidebar.collapsed #toggle-right-sidebar svg {
    width: 20px;
    height: 20px;
    transform: rotate(180deg);
}

#right-sidebar-resizer.collapsed {
    display: none !important;
}
