/* =============================================================================
   UNIFIED DROPDOWN STYLING SYSTEM
   ============================================================================= */

/* Base dropdown container styling - applies to all dropdowns */
.search-suggestions-dropdown,
.branch-dropdown,
.mode-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: calc(100% - 2px) !important;
    background: #000000;
    border: 1px solid var(--border-default);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 4px;
    display: none;
    box-sizing: border-box;
}

/* Show state for dropdowns */
.search-suggestions-dropdown.show,
.branch-dropdown.show,
.mode-dropdown.show {
    display: block;
}

/* Base dropdown item styling - applies to all dropdown items */
.search-suggestion-item,
.branch-item,
.mode-item {
    padding: 8px 12px;
    color: var(--accent-primary);
    background: #000000;
    cursor: pointer;
    border-bottom: 1px solid var(--border-subtle);
    transition: background-color 0.2s ease;
    font-size: 14.4px;
    font-family: 'Space Grotesk', Roboto, sans-serif;
    line-height: 1.4;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Remove border from last item */
.search-suggestion-item:last-child,
.branch-item:last-child,
.mode-item:last-child {
    border-bottom: none;
}

/* Hover state for all dropdown items */
.search-suggestion-item:hover,
.search-suggestion-item.highlighted,
.branch-item:hover,
.mode-item:hover {
    background: rgba(240, 246, 252, 0.1);
    color: var(--accent-primary);
}

/* Special styling for current/active items */
.branch-item.current,
.mode-item.current {
    background: rgba(88, 166, 255, 0.15);
    color: var(--accent-primary);
}

.branch-item.current:hover,
.mode-item.current:hover {
    background: rgba(88, 166, 255, 0.2);
}

/* Branch dropdown specific positioning (center-aligned and viewport-safe) */
.branch-selector .branch-dropdown {
    left: 50%;
    right: auto;
    min-width: 300px;
    max-width: 400px;
    width: auto !important;
    /* Center the dropdown and ensure it stays within viewport */
    transform: translateX(-50%);
    /* Fallback positioning to prevent off-screen issues */
    max-width: calc(100vw - 32px);
}

/* Ensure dropdown doesn't overflow on small screens */
@media (max-width: 768px) {
    .branch-selector .branch-dropdown {
        left: -50px;
        transform: none;
        max-width: calc(100vw - 64px);
    }
}

/* Mode selector container for proper spacing */
.mode-selector-container {
    margin-bottom: 8px;
    position: relative;
}

/* Mode selector main button styling - matches branch selector */
.mode-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    height: 40px;
    border: 1px solid var(--border-default);
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14.4px;
    font-family: 'Space Grotesk', Roboto, sans-serif;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    min-width: fit-content;
    white-space: nowrap;
    box-sizing: border-box;
    justify-content: space-between;
    width: 100%;
}

.mode-selector:hover {
    border-color: var(--border-hover, var(--border-default));
}

.mode-selector.open {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 1px var(--accent-primary);
}

.mode-name {
    font-family: 'Space Grotesk', Roboto, sans-serif;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 14.4px;
}

.mode-arrow {
    width: 12px;
    height: 12px;
    transition: transform 0.2s ease;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23f0f6fc'><path d='M2 4 L6 8 L10 4'/></svg>");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mode-selector.open .mode-arrow {
    transform: rotate(180deg);
}

/* Disabled state for mode selector */
.mode-selector:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.mode-selector:disabled .mode-name,
.mode-selector:disabled .mode-arrow {
    opacity: 0.6;
}

/* Branch selector main button styling */
.branch-current {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    height: 32px; /* Match version indicator height */
    border: 1px solid var(--border-default);
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14.4px;
    font-family: 'Space Grotesk', Roboto, sans-serif;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    min-width: fit-content;
    white-space: nowrap;
    box-sizing: border-box;
}

.branch-current:hover {
    border-color: var(--border-hover, var(--border-default));
}

.branch-current.open {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 1px var(--accent-primary);
}

.branch-name {
    font-family: 'Space Grotesk', Roboto, sans-serif;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 14.4px;
}

.branch-arrow {
    width: 12px;
    height: 12px;
    transition: transform 0.2s ease;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23f0f6fc'><path d='M2 4 L6 8 L10 4'/></svg>");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.branch-current.open .branch-arrow {
    transform: rotate(180deg);
}

/* Branch item text elements */
.branch-item-name {
    font-family: 'Space Grotesk', Roboto, sans-serif;
    font-weight: 500;
    color: var(--accent-primary);
    font-size: 14.4px;
    line-height: 1.4;
}

.branch-item-desc {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-left: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    text-align: left;
    opacity: 0.8;
}

.branch-current-indicator,
.mode-current-indicator {
    font-size: 12px;
    color: #238636;
    font-weight: 600;
}

/* Ensure search box matches other inputs */
.sidebar-search .search-box {
    height: 40px;
    border: 1px solid var(--border-default);
    border-radius: 8px;
    color: var(--text-secondary);
    font-family: 'Space Grotesk', Roboto, sans-serif;
    font-size: 14.4px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sidebar-search .search-box:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 1px var(--accent-primary);
}

/* Scrollbar styling for dropdowns */
.search-suggestions-dropdown::-webkit-scrollbar,
.branch-dropdown::-webkit-scrollbar,
.mode-dropdown::-webkit-scrollbar {
    width: 6px;
}

.search-suggestions-dropdown::-webkit-scrollbar-track,
.branch-dropdown::-webkit-scrollbar-track,
.mode-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.search-suggestions-dropdown::-webkit-scrollbar-thumb,
.branch-dropdown::-webkit-scrollbar-thumb,
.mode-dropdown::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 3px;
}

.search-suggestions-dropdown::-webkit-scrollbar-thumb:hover,
.branch-dropdown::-webkit-scrollbar-thumb:hover,
.mode-dropdown::-webkit-scrollbar-thumb:hover {
    background: #484f58;
}

/* Firefox scrollbar support */
.search-suggestions-dropdown,
.branch-dropdown,
.mode-dropdown {
    scrollbar-width: thin;
    scrollbar-color: #30363d transparent;
}
